Skip to content

Conversation

@joelsmith
Copy link
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 labels Feb 4, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: joelsmith
Once this PR has been reviewed and has the lgtm label, please assign hardikdr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 area/cluster-autoscaler 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 labels Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cluster-autoscaler 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. 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.

2 participants