avoid saving the azuremachine CR too often #1367
Conversation
Are you sure this is triggering new reconciliation loops? We were checking a case like this before, and it should not happen, as update should basically be a noop if there were no changes. If it is triggering new reconciliation loops without CR being actually changed, it might be a bug in operatorkit cc @giantswarm/sig-operator |
I might be wrong about operatorkit bug, but we did have few discussions about the topic and it came down to these updates without actual changes not having any effect. |
100% sure I can provide CRs and logs |
There might be some issue in the func called few lines above then:
https://github.com/giantswarm/azure-operator/blob/master/pkg/helpers/azuremachine.go#L16 |
BTW I copied what you did in another place where you use the same function |
Touche :) Forgot now why I did that, it wasn't for avoiding reconciliation loops though. My only concern here is that there might be an issue/bug somewhere in code that is causing infinite reconciliation loops (maybe caused by me in that func 😬), and this might hide it temporarily. |
Like I possibly did with that other "changed" check. |
I'm not sure right now but I think that's the only piece of code where we actually edit the Azure machine cr. If that's true it has to be it causing the reconciliation madness |
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.
Nice 👍
if changed { | ||
err = r.ctrlClient.Update(ctx, &azureMachine) | ||
if errors.IsConflict(err) { | ||
r.logger.Debugf(ctx, "conflict trying to save object in k8s API concurrently", "stack", microerror.JSON(microerror.Mask(err))) |
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.
This handler was calling
Update
on theAzureMachine
CR at every reconciliation loop, regardless of any changes being made to the CR.This triggered a loop in the handler that was running in an infinite sequence.
This PR check for changes in the CR and avoid saving if there isn't any