-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
update labels/annotations_as_tags on value change #3253
update labels/annotations_as_tags on value change #3253
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.
Digests associated to a pod entity should be removed when the latter expires. This is also something we will want to include in test scenarios.
releasenotes/notes/update-pod-labels-annotations-as-tags-on-value-change-eec756434e21ed64.yaml
Outdated
Show resolved
Hide resolved
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
tagsDigests map[string]digests | ||
} | ||
|
||
type digests struct { |
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.
Is there a good reason for those hashes to be separate, or can we make a digest of both, get rid of the type, and make tagsDigests
be a map[string]string
instead?
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.
that's right, we can calculate a single digest of both labels and annotations and store it in a map[string]string
👍
|
||
// digestMap return a unique hash for a map | ||
// used to track changes in labels and annotations values | ||
func digestMap(m map[string]string) string { |
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 this could take both annotations and labels, or even the whole metadata object, and return a single string for the pod (and it could be named digestPodMeta
in this case). That's just a proposal, might not be the best, but the name digestMap confused me at first because I expected it to digest the whole map and it actually hashes values only.
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.
what I suggest:
- rename the function to
digestMapValues
- add another function
digestPodMeta
which takes a metadata object as an argument digestPodMeta
callsdigestMapValues
twice to calculate digests for labels and annotationsdigestPodMeta
returns a single pod digest from both labels and annotations digests
I'd keep the digestMapValues
logic (keys sorting and map values hash calculation) in a separate function to avoid duplicating it for 2 maps (labels and annotations) in digestPodMeta
.
WDYT?
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.
That sounds great 👍 let's just make sure to define explicitly in the comment of the digestPodMeta
in which order we write annotation and label hashes.
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.
done 👍
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.
💯
What does this PR do?
Currently, pod
labels_as_tags
/annotations_as_tags
get collected and set on pod/container creation. FR to be able to update theselabels_as_tags
/annotations_as_tags
when the pod label/annotations values update.Motivation
Feature request: update the labels programmatically and monitors them using tags