-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Set GCPMachinepoolMachine.Status.LatestModelApplied to false if some labels applied to node are not same as expected #25
fix: Set GCPMachinepoolMachine.Status.LatestModelApplied to false if some labels applied to node are not same as expected #25
Conversation
…odelApplied to false if additionalLabels attached to node is not the same as ones set in gcpmachinepool.spec.additionallabels
cloud/scope/machinepoolmachine.go
Outdated
func (m *MachinePoolMachineScope) HasLatestModelApplied(_ context.Context, instance *compute.Disk) (bool, error) { | ||
func (m *MachinePoolMachineScope) HasLatestModelApplied(ctx context.Context, instance *compute.Disk, labels map[string]string) (bool, error) { | ||
log := log.FromContext(ctx) | ||
|
||
image := "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if an explicit var declaration will help with the check failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a change, please check
log.Error(err, "Error checking the AdditonalLabels") | ||
return false, err | ||
} | ||
if image == instanceImage && hasAdditionalLabelsDiff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name hasAdditionalLabelsDiff
is a bit confusing here. Ideally it should mean doesNotHaveAdditionalLabelsDiff
or noAdditionalLabelsDiff
in the above context, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added a change here 761d5d7, please check
return false, nil | ||
} | ||
|
||
// hasAdditionalLabelsDiff Checks if the Labels applied to the instance are the latest as in the Instance Template. | ||
// two keys of `capg-role` and `capg-cluster-<CLUSTER-NAME>` as they are added by default by CAPG | ||
// ref: https://github.com/newrelic-forks/cluster-api-provider-gcp/blob/ef2e7f1e64ebeeb5389c446fe4cf89026fcb8a8a/cloud/services/compute/instances/reconcile_test.go#L244-L24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a one-liner to say we need to ignore the 2 labels?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added a change here 761d5d7, please check
lint is passing. https://github.com/newrelic-forks/cluster-api-provider-gcp/actions/runs/9715896835/job/26818326647?pr=25 |
@tasdikrahman go ahead and reopen this |
instancegroupinstances: set
gcpmachinepoolmachine.status.LatestModelApplied
tofalse
if additionalLabels attached to node is not the same as ones set ingcpmachinepool.spec.additionallabels
Which would mark it for cleanup in graceful way ifcluster.x-k8s.io/replicas-managed-by: "true"
is not present on theMachinePool
, and the flow of https://github.com/newrelic-forks/cluster-api-provider-gcp/blob/v1.6.0-nr5/cloud/scope/machinepool.go#L278 would be called.What type of PR is this?
/kind bug
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
TODOs:
Release note: