-
Notifications
You must be signed in to change notification settings - Fork 7.4k
fix: keeping the image consistent for the recreate strategy #39714
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
Conversation
closes: keycloak#39710 Signed-off-by: Steve Hawkins <shawkins@redhat.com>
desired.getMetadata().getAnnotations().put(Constants.KEYCLOAK_MIGRATING_ANNOTATION, Boolean.TRUE.toString()); | ||
desired.getSpec().setReplicas(0); | ||
var currentImage = RecreateOnImageChangeUpdateLogic.extractImage(actual); | ||
kcContainer.setImage(currentImage); |
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.
Instead of modifying the replicas in the desired
, shouldn't we modify the replicas in the actual
?
Edit: I'm asking because I'm concerned that the same incorrect behavior may happen if the user changes the configuration (i.e. the EnvVar)
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.
Instead of modifying the replicas in the desired, shouldn't we modify the replicas in the actual?
desired is what is actually being returned to the operator sdk. We don't want to use the actual as the desired. What we're effectively relying upon the controller behavior that honors the replica count first, then rolls out any changes in the statefulset spec.
Edit: I'm asking because I'm concerned that the same incorrect behavior may happen if the user changes the configuration (i.e. the EnvVar)
I don't follow that concern. This pr reinstates the recreate behavior we've always had. Are you thinking that there is some scenario where a change in the env will somehow be rolled out prior to the replica count being honored?
Alternative behavior would be working against the operator sdk / SSA - that is rather than honoring a desired state we'd have to directly isssue a patch against the actual.
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.
Are you thinking that there is some scenario where a change in the env will somehow be rolled out prior to the replica count being honored?
Yes exactly. Is that possible?
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.
No, the controller will respect the replica reduction first - why restart the pods if you are just going to scale them down anyway.
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.
So, I don't understand why it does not respect the replica count when the image is different. 🤔
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.
The problem is with our logic if we don't keep the old image - the recreate stategy needs to see that difference. If it sees the new image on the actual, it will let the desired logic immediately set the replica count back to what is in the keycloak cr.
You could alternatively try to account for this in the recreate stategy logic - if the images are the same, but the actual statefulset spec has 0 replicas, and the status replicas are greater than 0, then keep using the recreate stategy. It seems simpler to just keep the desired image as the old 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.
Ah! Gotcha! Sorry for being slow 😅 It makes sense now. Thank you.
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.
No problem
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.
Approving based on previous review
closes: #39710