Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(tenant): fix delete tenants behavior #6013

Merged
merged 5 commits into from
Dec 4, 2024

Conversation

vicferpoy
Copy link
Member

@vicferpoy vicferpoy commented Dec 4, 2024

Context

When trying to delete a tenant, the related membership would be removed before that and the RLS policy would block the tenant deletion. In addition, users without a tenant membership would exist in the database, preventing from creating a new one for a new tenant.

Description

The DELETE /tenents/<id> endpoint now does the following:

  • During the request, it deletes (leading to immediate impact for the user):
    • Memberships to that tenant.
    • Users without any membership.
  • Creates a background task, agnostic to the user, deleting in batches all the related resources from the tenant and the tenant itself.

As this endpoint applies a system background task, the response will still be a 204.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@vicferpoy vicferpoy added the backport-to-v5.0 Backport PR to the v5.0 branch label Dec 4, 2024
@vicferpoy vicferpoy requested a review from a team as a code owner December 4, 2024 12:51
@vicferpoy vicferpoy requested a review from jfagoagas December 4, 2024 12:56
@vicferpoy vicferpoy merged commit ad7134d into master Dec 4, 2024
11 checks passed
@vicferpoy vicferpoy deleted the PRWLR-5679-fix-delete-tenants-id-behavior branch December 4, 2024 12:57
prowler-bot pushed a commit that referenced this pull request Dec 4, 2024
@prowler-bot prowler-bot added the was-backported The PR was successfully backported to the target branch label Dec 4, 2024
@prowler-bot
Copy link
Collaborator

💚 All backports created successfully

Status Branch Result
v5.0

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 92.90%. Comparing base (32d8da2) to head (25d19c4).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
api/src/backend/api/base_views.py 76.47% 4 Missing ⚠️
api/src/backend/api/v1/views.py 88.88% 1 Missing ⚠️
api/src/backend/tasks/tasks.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6013      +/-   ##
==========================================
- Coverage   92.91%   92.90%   -0.02%     
==========================================
  Files          59       59              
  Lines        5040     5102      +62     
==========================================
+ Hits         4683     4740      +57     
- Misses        357      362       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
backport-to-v5.0 Backport PR to the v5.0 branch component/api was-backported The PR was successfully backported to the target branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants