[4.20] Fix account deletion blocked by deleted project admin mappings#12615
[4.20] Fix account deletion blocked by deleted project admin mappings#12615SURYAS1306 wants to merge 10 commits intoapache:4.20from
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #12615 +/- ##
=============================================
- Coverage 16.27% 4.15% -12.12%
=============================================
Files 5662 404 -5258
Lines 500033 32965 -467068
Branches 60717 5893 -54824
=============================================
- Hits 81368 1370 -79998
+ Misses 409591 31419 -378172
+ Partials 9074 176 -8898
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This PR backports the fix from #12607 to the 4.20 branch. It contains the same change and unit test as the main/4.22 fix, adjusted for the 4.20 codebase. Please let me know if any additional changes are needed for the backport. |
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Co-authored-by: dahn <[email protected]>
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16761 |
|
@SURYAS1306 please check the build error. |
|
Hi @sureshanaparti , The build issue was caused by incorrect mocks in AccountManagerImplTest. Could you please re-run the workflows when convenient? |
|
The previous build failure was due to missing imports (ProjectAccountDao, ProjectDao, InjectMocks) in AccountManagerImplTest. I’ve added the required imports and pushed the fix in the latest commit. Could you please re-run the workflows when possible? |
|
@SURYAS1306 , a new error. please see https://github.com/apache/cloudstack/actions/runs/21867500572/job/63118078002?pr=12615#step:7:11366 ? |
…bing internal methods
|
Hi @DaanHoogland, I see the new failure is a Mockito NotAMockException caused by an incorrect @SPY and @Injectmocks annotation order in AccountManagerImplTest. I’m re-checking the remaining test failures locally and will follow up shortly. |
|
Hi @DaanHoogland, I’ve updated the spy initialization in AccountManagerImplTest to ensure proper injection order and pushed the fix. |
|
sorry @SURYAS1306 , another lint/checkstyle error: https://github.com/apache/cloudstack/actions/runs/21910909861/job/63274656053?pr=12615#step:11:6378 |
|
Thanks @DaanHoogland , |
|
Hi @DaanHoogland, I'm still seeing persistent NotMock errors in AccountManagerImplTest. All failures point to: AccountManagerImplTest.beforeTest:164 NotMock So far I’ve:
I suspect this might be due to:
Would you recommend consolidating the @before methods into one, or removing the manual Mockito.mock() calls and relying only on @mock annotations? Since this test extends AccountManagetImplTestBase, I want to ensure I’m aligning with the existing pattern. I’ll update based on your feedback. |
One of them should probably be @before and the other @BeforeClass
I think no explicit Mocks should have to be created. @InitMocks should take care of injections.
no and yes, see above.
The existing pattern may have gone through Mockito upgrades and is not necessarily the best. @vishesh92 , could you have a look as well? |
|
Hi @DaanHoogland, |
Don't, one of them should be a @BeforeClass method! |
|
Hi @DaanHoogland, |
Description
Backport of #12607 to the 4.20 branch.
This change fixes an issue where account deletion was blocked if the account
was listed as an administrator of projects that were already removed
(removed is not null).
The fix ensures that only active projects are considered when checking
whether an account manages projects, allowing deletion when only deleted
projects are associated.
Includes the same defensive check and unit test added in the main branch.
Rebased to 4.20 as requested by @DaanHoogland
Fixes #12601
Types of changes