Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement of tenant deletion #1882

Closed
wants to merge 7 commits into from

Conversation

Thumimku
Copy link

@Thumimku Thumimku commented Dec 4, 2018

Purpose

When we delete a tenant(with existing methods) we didn't delete the caches and the entry in globalCacheManagerMap. So when ever we try to create a new tenant with same domain name it checks with map and instead of creating new cache managers it returns existing entry value which owns by previous tenant. This cause the error mentioned in issue given below.

Goals

Fix for the Issue :- Security exception occurred when try to create a tenant with deleted tenant's domain name

Approach

While deleting a tenant delete

  • clear all the caches
  • shutdown all the cachemanagers
  • remove the entry from globalCacheManagerMap

Documentation

Tenant Deletion Doc

@@ -727,4 +729,21 @@ public boolean accept(File userStores, String name) {
private void clearTenantCache(int tenantId) {
tenantCacheManager.clearCacheEntry(new TenantIdKey(tenantId));
}

private void deleteCachemanager(String tenantDomain, int tenantId) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better name would be "clearCacheManager" or "purgeCacheManager"


Caching.getCacheManagerFactory().close();
} catch (Exception e) {
log.error("Unable to delete cache for tenant :"+tenantDomain);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.error("Unable to delete cache for tenant :"+tenantDomain, e);

Prints the stacktrace upon error, so that finding root cause is easy.

} finally {
PrivilegedCarbonContext.endTenantFlow();
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of this empty lines.

deleteCacheManager method name changed as clearCachemanager
Cleared empty lines
* @param tenantDomain tenant domain
* @param tenantId tenant id
*/
private void clearCachemanager(String tenantDomain, int tenantId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming has to be "clearCacheManager"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@jsdjayanga jsdjayanga added the C4 label Jun 13, 2019
@IsuraD
Copy link

IsuraD commented Jun 14, 2019

This is already fixed in another PR.

@IsuraD IsuraD closed this Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants