Skip to content

fix: check if any node exists and cleanup nsg resources if in RG#8718

Open
awesomenix wants to merge 1 commit into
mainfrom
fix-anc-wrapper-empty-input
Open

fix: check if any node exists and cleanup nsg resources if in RG#8718
awesomenix wants to merge 1 commit into
mainfrom
fix-anc-wrapper-empty-input

Conversation

@awesomenix

Copy link
Copy Markdown
Contributor
  • Updated E2E cluster reuse cleanup to treat an existing MC_ node resource group with no VMSS as unusable, forcing cluster recreation instead of later proxy/VMSS failures.
  • Also renamed and expanded the subnet cleanup helper to detach both route table and NSG references from the shared subnet when they point to a deleting node resource group.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the E2E cluster reuse/cleanup logic to (1) avoid reusing clusters whose node resource group is in a bad state (deleting or missing expected node resources), and (2) improve shared subnet cleanup by detaching both route table and NSG references when they belong to a deleting node resource group.

Changes:

  • Rename/expand shared subnet cleanup to detach both route table and NSG when they reference the deleting node resource group.
  • Treat an existing node resource group with no VMSS as unusable to force cluster recreation earlier.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
e2e/shared_infra.go Renames and broadens subnet cleanup helper to detach route table + NSG references tied to a deleting node RG.
e2e/cluster.go Adds a VMSS-existence check to decide whether a node RG is usable; updates callers to the renamed subnet cleanup helper.

Comment thread e2e/shared_infra.go
Comment on lines +477 to +481
shouldDetachRouteTable, err := subnetResourceIDInResourceGroup(routeTableID(subnetResp.Properties.RouteTable), nodeResourceGroup)
if err != nil {
return err
}
if !shouldDetach {
return nil
shouldDetachNSG, err := subnetResourceIDInResourceGroup(networkSecurityGroupID(subnetResp.Properties.NetworkSecurityGroup), nodeResourceGroup)
Comment thread e2e/cluster.go
Comment on lines +493 to +503
func hasVMSSInResourceGroup(ctx context.Context, resourceGroupName string) (bool, error) {
pager := config.Azure.VMSS.NewListPager(resourceGroupName, nil)
if !pager.More() {
return false, nil
}
page, err := pager.NextPage(ctx)
if err != nil {
return false, fmt.Errorf("failed to list VMSS in node resource group %q: %w", resourceGroupName, err)
}
return len(page.Value) > 0, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants