-
Notifications
You must be signed in to change notification settings - Fork 717
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
Improve ES pods comparison using a hash of the spec #1103
Conversation
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.
Looks good to me! I like it I think it is a step in the right direction even though we still have to do the mental leap of adding a placeholder first and replacing it later. But you commented that well enough so 👍
jenkins test this please |
2 similar comments
jenkins test this please |
jenkins test this please |
// MapSubsetComparison returns ComparisonMatch if the expected labels (keys and values) are present in the | ||
// actual map. The actual map may contain more entries: this will not cause a mismatch. | ||
// This allows user to add additional labels or annotations to pods, while not causing the pod to be replaced. | ||
func MapSubsetComparison(expected map[string]string, actual map[string]string, mismatchMsg string) Comparison { |
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 have a concern here because usually with deployments
or statefulset
user is allowed to change the value of an annotation (or remove the annotation) without triggering a new deployment.
It may sound weird but it might be used by a mutation webhook or an external system to store some informations on the pods that are running in a K8S cluster. (tbh this is what happen for me, I'm playing with MutatingWebhook
which updates a annotation)
I don't know if we want to be compatible with that but it is just to point out that we may still have some issues with MutatingWebhook
or any external system that would addupdate/delete some annotations while it is fine with deployments
or statefulset
.
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.
Good point!
Should we maybe include the initial labels & annotations the pod was created with into the hash computation? A user may update/remove/add any label/annotation on a running pod: since we would compare with the initially created labels & annotations and not the current ones, we would not trigger a pod replacement, unless we want to change that initial set of labels?
jenkins test this please |
I added some commits to make sure we take labels (and maybe future annotations) we build into the pod spec into consideration when computing the hash. |
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.
LGTM! 👍
I did some manual tests with a custom MutatingWebhook
which adds a pod as a sidecar, a new env. variable and changes the annotations. Everything worked fine. I'm wondering if we should not add a e2e test with such a MutatingWebhook deployed (in an other PR of course)
Compare the entire pod while looking for a matching pod, instead of just looking at a few fields.
Comparison is performed this way:
ObjectMeta
PodSpec
I had to refactor some bits of the pod creation code to make things cleaner:
Fixes #1046.
Should help with #851 since we don't take injected pod environment variables into consideration for pod comparison, but I did not perform any test on AKS.