Skip to content

CA: Fix potential race/deadlock in CAPI unstructured handling#9173

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
joelsmith:k8smaster
Feb 4, 2026
Merged

CA: Fix potential race/deadlock in CAPI unstructured handling#9173
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
joelsmith:k8smaster

Conversation

@joelsmith
Copy link
Copy Markdown
Contributor

@joelsmith joelsmith commented Feb 4, 2026

The change to add the mutex was introduced after 1.34 branched so it has never landed in a CA release. This fix should probably be cherry-picked to the CA 1.35 release branch, ideally prior to the release of 1.35.0.

What type of PR is this?

/kind bug

What this PR does / why we need it:

Since unstructuredScalableResource contains a sync.RWMutex, it should be
passed by reference so that all locks/unlocks can be performed against a
single mutex instance (and not a copy of the mutex)

Before:

$ go vet ./cloudprovider/clusterapi/
# k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi
# [k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi]
cloudprovider/clusterapi/clusterapi_unstructured.go:55:9: ID passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:59:9: MaxSize passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:63:9: MinSize passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:67:9: Kind passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:71:9: GroupVersionResource passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:84:9: Name passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:88:9: Namespace passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:92:9: ProviderIDs passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:101:9: Replicas passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:118:9: SetSize passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:169:9: UnmarkMachineForDeletion passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:183:9: MarkMachineForDeletion passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:204:9: Labels passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:230:9: Taints passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:249:9: CanScaleFromZero passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:266:9: InstanceCapacity passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:340:9: InstanceSystemInfo passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:349:9: InstanceResourceSlices passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:389:9: InstanceEphemeralDiskCapacityAnnotation passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:393:9: InstanceCPUCapacityAnnotation passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:397:9: InstanceMemoryCapacityAnnotation passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:401:9: InstanceGPUCapacityAnnotation passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:405:9: InstanceGPUTypeAnnotation passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:409:9: InstanceMaxPodsCapacityAnnotation passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:413:9: InstanceDRADriver passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:421:9: InstanceCSINode passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex
cloudprovider/clusterapi/clusterapi_unstructured.go:438:9: readInfrastructureReferenceResource passes lock by value: k8s.io/autoscaler/cluster-autoscaler/cloudprovider/clusterapi.unstructuredScalableResource contains sync.RWMutex

After:

$ go vet ./cloudprovider/clusterapi/

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

Since unstructuredScalableResource contains a sync.RWMutex, it should be
passed by reference so that all lock/unlocks can be perfromed against a
singale mutex instance (and not a copy of the mutex)
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-area Indicates that a PR should not merge because it lacks an area label. area/cluster-autoscaler Issues or PRs related to the Cluster Autoscaler component area/provider/cluster-api Issues or PRs related to Cluster API provider labels Feb 4, 2026
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-area Indicates that a PR should not merge because it lacks an area label. labels Feb 4, 2026
Copy link
Copy Markdown
Contributor

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

thanks Joel!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 4, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: elmiko, joelsmith

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 4, 2026
@k8s-ci-robot k8s-ci-robot merged commit d63a15f into kubernetes:master Feb 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler Issues or PRs related to the Cluster Autoscaler component area/provider/cluster-api Issues or PRs related to Cluster API provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants