Skip to content

server: remove user-project mappings when delete a project - #14150

Draft
weizhouapache wants to merge 1 commit into
apache:4.20from
weizhouapache:fix-12601-project-account-cleanup
Draft

server: remove user-project mappings when delete a project#14150
weizhouapache wants to merge 1 commit into
apache:4.20from
weizhouapache:fix-12601-project-account-cleanup

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

Description

This PR fixes #12601

When an account is added to a project with a project role (e.g. via addUserToProject), the resulting project_account row has a non-null user_id. Project cleanup (deleteProject ... cleanup=true) unassigns every account from the project via ProjectAccountDaoImpl#findByProjectIdUserId(projectId, accountId, null), expecting a null userId to mean "match this account regardless of which user_id the row has".

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Verified on a live 2-node management server deployment:

  • Built and deployed the patched jar to both management nodes.
  • Reproduced the original issue with the pre-fix code: created an account, created a project, added the account's user to the project with addUserToProject roletype=Admin (producing a project_account row with a non-null user_id), deleted the project with cleanup=true (reported success), then attempted deleteAccount — reproduced the exact errorcode 431 failure from Unable to delete account if the project is removed #12601.
  • Repeated the same steps against the fixed jar: deleteProject cleanup=true followed by deleteAccount both succeeded, and the account no longer appeared in listAccounts.
  • Confirmed both management nodes ended up running the identical fixed build.

How did you try to break this feature and the system with this change?

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.37%. Comparing base (a4d3c66) to head (506fbc0).
⚠️ Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
.../com/cloud/projects/dao/ProjectAccountDaoImpl.java 0.00% 3 Missing ⚠️
...in/java/com/cloud/projects/ProjectManagerImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #14150      +/-   ##
============================================
- Coverage     16.37%   16.37%   -0.01%     
+ Complexity    13614    13613       -1     
============================================
  Files          5669     5669              
  Lines        501527   501528       +1     
  Branches      60922    60923       +1     
============================================
- Hits          82148    82142       -6     
- Misses       410171   410179       +8     
+ Partials       9208     9207       -1     
Flag Coverage Δ
uitests 4.14% <ø> (ø)
unittests 17.24% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant