Skip to content

fix(cluster): ARO-20041 handle empty SubnetID in WorkerProfiles during update operations - #4978

Open
nikhil-thomas wants to merge 1 commit into
Azure:masterfrom
nikhil-thomas:ARO-20041/fix-empty-workerprofile-subnetid
Open

fix(cluster): ARO-20041 handle empty SubnetID in WorkerProfiles during update operations#4978
nikhil-thomas wants to merge 1 commit into
Azure:masterfrom
nikhil-thomas:ARO-20041/fix-empty-workerprofile-subnetid

Conversation

@nikhil-thomas

@nikhil-thomas nikhil-thomas commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Which issue this PR addresses:

Fixes ARO-20041

What this PR does / why we need it:

The worker profile enricher creates WorkerProfilesStatus entries with empty SubnetID when a MachineSet is unhealthy (zero ready replicas, nil/un-parseable ProviderSpec).

Multiple code paths assume SubnetID is always populated and crash during admin-update and customer update operations, leaving clusters stuck in a Failed provisioning state.

This PR guards all SubnetID consumers to skip empty values during update operations while preserving the existing error behavior during cluster creation.

Test plan for issue:

  • Unit tests added for ensureServiceEndpoints: empty SubnetID errors on create, skips on update
  • Unit tests added for createOrUpdateRouterIPEarly: first-worker-empty-uses-second, all-workers-empty-errors
  • Unit tests added for _attachNSGs: same pattern as above
  • Unit tests added for NetworkSecurityGroupID : empty-first-in-list and all-empty SubnetIDs
  • adminupdate_test.go updated for renamed step
  • make unit-test-go passes (0 new failures)

Is there any documentation that needs to be updated for this PR?

No. Bug fix with no API or user-facing behavior change.

How do you know this will function as expected in production?

  • The existing error "WorkerProfile '%s' has no SubnetID" in RP logs should stop appearing for update operations, confirming the fix is active
  • Clusters previously stuck in Failed state due to this issue will complete admin-update successfully
  • Create operations retain the existing error path, so genuinely missing SubnetIDs at creation time are still caught

…g update operations

- Split ensureServiceEndpoints into create/update variants; skip empty SubnetIDs on update, error on create
- Guard _attachNSGs and createOrUpdateRouterIPEarly to find first non-empty worker SubnetID instead of blindly using [0]
- Skip empty SubnetIDs in dynamic validation (openshiftcluster_validatedynamic.go) to unblock customer updates
- Skip empty SubnetIDs in monitor (clusterwideproxystatus.go) to prevent parse failures
- Skip empty SubnetIDs in NetworkSecurityGroupID lookup to avoid false matches
- Add unit tests for all empty-SubnetID code paths

Signed-off-by: Nikhil Thomas <nikthoma@redhat.com>

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 hardens cluster update/admin-update paths against enriched WorkerProfilesStatus entries that have an empty SubnetID, avoiding failures when MachineSets are unhealthy while keeping stricter behavior during create/bootstrapping where appropriate.

Changes:

  • Skip empty SubnetID entries when iterating enriched worker profiles in dynamic validation and monitoring.
  • Split ensureServiceEndpoints into create vs update wrappers, skipping empty worker subnets during update but preserving create-time error behavior.
  • Update cluster networking helpers (createOrUpdateRouterIPEarly, _attachNSGs, NetworkSecurityGroupID) and add unit tests covering empty-first / all-empty subnet scenarios.

Reviewed changes

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

Show a summary per file
File Description
pkg/validate/openshiftcluster_validatedynamic.go Skips empty worker SubnetID entries when building the subnet list for dynamic validation.
pkg/monitor/cluster/clusterwideproxystatus.go Avoids parsing/processing empty worker subnet IDs in CWP status emission.
pkg/cluster/ipaddresses.go Selects the first non-empty worker subnet ID for early router IP logic; errors if none found.
pkg/cluster/ipaddresses_test.go Adds coverage for empty-first and all-empty worker subnet ID cases.
pkg/cluster/install.go Routes create to ensureServiceEndpointsForCreate and admin-update to ensureServiceEndpointsForUpdate.
pkg/cluster/ensureendpoints.go Introduces create/update wrappers and update-time skipping of empty worker subnet IDs.
pkg/cluster/ensureendpoints_test.go Adds update-mode test ensuring empty worker subnet IDs are skipped.
pkg/cluster/deploybaseresources.go Uses first non-empty worker subnet ID in _attachNSGs; errors if none found.
pkg/cluster/deploybaseresources_test.go Adds coverage for empty-first and all-empty worker subnet ID cases in _attachNSGs.
pkg/cluster/adminupdate_test.go Updates expected admin-update step name after renaming.
pkg/api/util/subnet/subnet.go Ignores empty worker subnet IDs when determining worker-vs-master for NSG ID selection.
pkg/api/util/subnet/subnet_test.go Adds tests for empty-first and all-empty worker subnet IDs in NetworkSecurityGroupID.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +135 to +137
if workerSubnetID == "" {
return fmt.Errorf("no valid worker subnet found: all worker profiles have empty subnetId; set properties.workerProfiles[].subnetId")
}
Comment on lines +368 to +370
if workerSubnetID == "" {
return fmt.Errorf("no valid worker subnet found: all worker profiles have empty subnetId")
}
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