Fix: Move share cleanup to CleanupBeforeVPCDeletion phase to unblock VPC deletion#1272
Merged
zhengxiexie merged 1 commit intovmware-tanzu:mainfrom Oct 29, 2025
Conversation
cf8c1b9 to
480bcba
Compare
wenyingd
reviewed
Oct 24, 2025
wenyingd
reviewed
Oct 24, 2025
23e4497 to
3886c9f
Compare
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (2.85%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1272 +/- ##
==========================================
- Coverage 76.00% 75.66% -0.35%
==========================================
Files 147 147
Lines 19858 19872 +14
==========================================
- Hits 15094 15037 -57
- Misses 3662 3740 +78
+ Partials 1102 1095 -7
🚀 New features to boost your workflow:
|
timdengyun
reviewed
Oct 28, 2025
Contributor
Author
|
/e2e |
wenyingd
reviewed
Oct 28, 2025
…VPC deletion - Add CleanupBeforeVPCDeletion to SecurityPolicyService and LBInfraCleaner - Remove share cleanup from CleanupInfraResources phase Change-Id: Ib6814933c24252eba19483ec3d2abd27fbafa7de
3886c9f to
466e94c
Compare
wenyingd
approved these changes
Oct 29, 2025
Contributor
Author
|
/e2e |
1 similar comment
Contributor
Author
|
/e2e |
zhengxiexie
added a commit
to zhengxiexie/nsx-operator-1
that referenced
this pull request
Oct 31, 2025
…re deletion errors This PR complements PR vmware-tanzu#1272 by applying the same cleanup sequence fix to LoadBalancer infrastructure. Problem: - NSX error 524238 occurs when attempting to delete LB infra shares - Shares are still being referenced by VPC LB Virtual Servers - Error: 'The object path=[/infra/shares/.../LBFastUdpProfile] cannot be deleted since its members are being referenced by [.../vpc-lb-virtual-servers/kube-dns-lb_53_UDP_5zahh]' Root Cause: - LB Virtual Servers were cleaned up in CleanupInfraResources phase (too late) - Share cleanup attempted before Virtual Servers were deleted - This caused reference dependency errors from NSX Solution: - Move DLB Virtual Server cleanup to CleanupBeforeVPCDeletion phase - Move LB infra Share cleanup to CleanupBeforeVPCDeletion phase - Ensures proper deletion order: Virtual Servers → Shares → VPC Changes: - Updated CleanupBeforeVPCDeletion() to first delete DLB virtual servers, then shares - Removed these cleanups from CleanupInfraResources() parallel execution - Updated test cases to reflect new cleanup sequence This ensures shares can be successfully deleted without NSX reference errors. Related: vmware-tanzu#1272 Change-Id: I55fd9aceb9eee3364ab3f051f4fbc07e34d23cd0
zhengxiexie
added a commit
to zhengxiexie/nsx-operator-1
that referenced
this pull request
Oct 31, 2025
…re deletion errors This PR complements PR vmware-tanzu#1272 by applying the same cleanup sequence fix to LoadBalancer infrastructure. Problem: - NSX error 524238 occurs when attempting to delete LB infra shares - Shares are still being referenced by VPC LB Virtual Servers - Error: 'The object path=[/infra/shares/.../LBFastUdpProfile] cannot be deleted since its members are being referenced by [.../vpc-lb-virtual-servers/kube-dns-lb_53_UDP_5zahh]' Root Cause: - LB Virtual Servers were cleaned up in CleanupInfraResources phase (too late) - Share cleanup attempted before Virtual Servers were deleted - This caused reference dependency errors from NSX Solution: - Move DLB Virtual Server cleanup to CleanupBeforeVPCDeletion phase - Move LB infra Share cleanup to CleanupBeforeVPCDeletion phase - Ensures proper deletion order: Virtual Servers → Shares → VPC Changes: - Updated CleanupBeforeVPCDeletion() to first delete DLB virtual servers, then shares - Removed these cleanups from CleanupInfraResources() parallel execution - Updated test cases to reflect new cleanup sequence This ensures shares can be successfully deleted without NSX reference errors. Related: vmware-tanzu#1272 Change-Id: I55fd9aceb9eee3364ab3f051f4fbc07e34d23cd0
zhengxiexie
added a commit
that referenced
this pull request
Nov 3, 2025
…re deletion errors (#1278) This PR complements PR #1272 by applying the same cleanup sequence fix to LoadBalancer infrastructure. Problem: - NSX error 524238 occurs when attempting to delete LB infra shares - Shares are still being referenced by VPC LB Virtual Servers - Error: 'The object path=[/infra/shares/.../LBFastUdpProfile] cannot be deleted since its members are being referenced by [.../vpc-lb-virtual-servers/kube-dns-lb_53_UDP_5zahh]' Root Cause: - LB Virtual Servers were cleaned up in CleanupInfraResources phase (too late) - Share cleanup attempted before Virtual Servers were deleted - This caused reference dependency errors from NSX Solution: - Move DLB Virtual Server cleanup to CleanupBeforeVPCDeletion phase - Move LB infra Share cleanup to CleanupBeforeVPCDeletion phase - Ensures proper deletion order: Virtual Servers → Shares → VPC Changes: - Updated CleanupBeforeVPCDeletion() to first delete DLB virtual servers, then shares - Removed these cleanups from CleanupInfraResources() parallel execution - Updated test cases to reflect new cleanup sequence This ensures shares can be successfully deleted without NSX reference errors. Related: #1272 Change-Id: I55fd9aceb9eee3364ab3f051f4fbc07e34d23cd0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Bug #3603104 - Supervisor disable operations are blocked due to VPC deletion failures. VPCs cannot be deleted because share resources still reference them, causing NSX error 500030.
Root Cause
Share resources are cleaned up in the
CleanupInfraResourcesphase, which runs AFTER VPC deletion attempts. This creates a dependency deadlock where:Solution
Move all share cleanup operations to the
CleanupBeforeVPCDeletionphase to ensure shares are deleted before any VPC deletion attempts.Changes Made
1. SecurityPolicyService (
pkg/nsx/services/securitypolicy/cleanup.go)✅ Added new
CleanupBeforeVPCDeletion()method that cleans both project and infra shares✅ Modified
CleanupInfraResources()to remove share cleanup (now only handles groups)2. LBInfraCleaner (
pkg/clean/clean_lb_infra.go)✅ Added new
CleanupBeforeVPCDeletion()method that cleans LB-related shares and shared resources✅ Modified
CleanupInfraResources()to remove share cleanup callsTesting & Verification
Test Environment Setup
Created SecurityPolicy and NetworkPolicy resources that generate share resources with VPC references:
SecurityPolicy Configuration
NetworkPolicy Configuration
NSX Resource Analysis
Generated Share Resource (Before Fix)
{ "sharedWith": ["/orgs/default/projects/project-quality/vpcs/ns-1_nydws"], // ← VPC reference blocks deletion "sharing_strategy": "NONE_DESCENDANTS", "resource_type": "Share", "id": "project-quality_group_sp-app-access-4a704a42-src_s0rop_share", "display_name": "project-quality_group_sp-app-access_4a704a42_src_share", "tags": [ {"scope": "nsx-op/cluster", "tag": "ddc98cb1-5506-47b3-9197-55cded09f5ce"}, {"scope": "nsx-op/namespace", "tag": "ns-1"}, {"scope": "nsx-op/security_policy_name", "tag": "sp-app-access"} ], "path": "/orgs/default/projects/project-quality/infra/shares/project-quality_group_sp-app-access-4a704a42-src_s0rop_share" }Validation with NSX Clean Tool
Executed clean operation with PR #1275 modifications:
Results
Share Cleanup (New Phase - CleanupBeforeVPCDeletion)
VPC Deletion (Now Successful)
Associated with Precreated VPC in default Project
Security policy can be deleted successfully.
Test Coverage
✅ SecurityPolicy shares: Successfully cleaned before VPC deletion
✅ NetworkPolicy shares: Verified same cleanup pattern works
✅ Multiple shares per VPC: All shares removed in batch operation
✅ VPC deletion: No longer blocked by share references
Impact Analysis
Additional Notes
The fix has been validated against both SecurityPolicy and NetworkPolicy resources that create cross-VPC share references. The cleanup phase reordering ensures proper dependency resolution without introducing any breaking changes to existing cleanup logic.