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
labels, ipcache: Introduce convenience NewFrom() #23218
labels, ipcache: Introduce convenience NewFrom() #23218
Conversation
cc @joestringer @gandro, this is related to 46d09ac. |
/test Job 'Cilium-PR-K8s-1.25-kernel-4.19' failed: Click to show.Test Name
Failure Output
If it is a flake and a GitHub issue doesn't already exist to track it, comment |
This new function is a convenience and safe wrapper for creating a copy of a Labels object from another. This is especially useful going forward with the IPcache rework (cilium#21142), where many call sites are being converted from using raw identities over to labels. Being able to create copies of labels without accidentally copying the reference to the backing slice is crucial to avoid very subtle and hard to find bugs. For example: ``` // Node 1 comes online. node1Labels := labels.LabelRemoteNote // Detect that node1 also has the kube-apiserver deployed on it, so add // its label. node1Labels.MergeLabels(labels.LabelKubeAPIServer) ... // Node 2 comes onlne. node2Labels := labels.LabelRemoteNote // Now node2Labels contains the kube-apiserver label as well because // node1Labels was set to the reference of labels.LabelRemoteNote. ``` Signed-off-by: Chris Tarazi <chris@isovalent.com>
bcdaf19
to
c80bc1d
Compare
/test |
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 find! Thanks
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.
Thanks for the context in the commit description.
Runtime test hit: #22373 |
/test-runtime |
This new function is a convenience and safe wrapper for creating a copy
of a Labels object from another.
This is especially useful going forward with the IPcache rework
(#21142), where many call sites
are being converted from using raw identities over to labels. Being able
to create copies of labels without accidentally copying the reference to
the backing slice is crucial to avoid very subtle and hard to find bugs.
For example:
Signed-off-by: Chris Tarazi chris@isovalent.com