chore: Add cleanup and update stage for tenant at the server restart#35786
chore: Add cleanup and update stage for tenant at the server restart#35786
Conversation
WalkthroughThe newly added Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TenantConfig.java (1 hunks)
Additional comments not posted (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TenantConfig.java (3)
1-10: Imports are appropriate.The package and import statements are correctly defined and necessary for the functionality of the
TenantConfigclass.
12-14: Class declaration and annotations are appropriate.The
@Configurationand@RequiredArgsConstructorannotations are correctly used for a Spring configuration class.
16-17: Field declarations are appropriate.The
tenantServiceandcacheableRepositoryHelperfields are correctly declared as final, ensuring immutability and proper dependency injection.
app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TenantConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TenantConfig.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TenantConfig.java
|
|
||
| @Configuration | ||
| @RequiredArgsConstructor | ||
| public class TenantConfig { |
There was a problem hiding this comment.
Nit: Can we make this a listener on the Spring context refresh event so that the execution period for this eviction is predictable?
| // Bean to cleanup the cache and update the default tenant policies on every server restart. This will make sure | ||
| // cache will be updated if we update the tenant via migrations. | ||
| @Bean | ||
| public void cleanupAndUpdateRefreshDefaultTenantPolicies() { |
There was a problem hiding this comment.
Does this mean that every time any pod restarts it will reset the cache? Do you see any downside to this with the current stability issue?
There was a problem hiding this comment.
If this is by type, shall we consider making this a conditional eviction instead?
There was a problem hiding this comment.
We are cleaning up the cache so yeah definitely for the first call we will hit the DB, but we will have correct data. Ideally we want to hook this with the DB migrations which updates the default tenant. Any suggestions from your side?
Failed server tests
|
AnaghHegde
left a comment
There was a problem hiding this comment.
Minor nit, rest looks good to me
app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TenantConfig.java
Outdated
Show resolved
Hide resolved
Failed server tests
|
…35786) ## Description PR to add the cleanup and update default tenant at the server restart. This was required because whenever we update tenant via migrations the result gets reverted because the cached tenant is not getting updated as we generally end up updating only the MongoDB state and not the cached entry. /test Sanity ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10471754877> > Commit: e288cfe > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10471754877&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Tue, 20 Aug 2024 13:01:42 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Implemented a mechanism to refresh tenant policies and manage cache cleanup during server restarts, ensuring accurate policy enforcement for multi-tenant applications. <!-- end of auto-generated comment: release notes by coderabbit.ai --> (cherry picked from commit d1de33b)
Description
PR to add the cleanup and update default tenant at the server restart. This was required because whenever we update tenant via migrations the result gets reverted because the cached tenant is not getting updated as we generally end up updating only the MongoDB state and not the cached entry.
/test Sanity
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10471754877
Commit: e288cfe
Cypress dashboard.
Tags:
@tag.SanitySpec:
Tue, 20 Aug 2024 13:01:42 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit