-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Creating deep copy functions for k8s watcher #1986
Conversation
|
||
// +k8s:deepcopy-gen=package | ||
|
||
// Package api defines the API of the Cilium network policy interface |
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.
package comment should be of the form "Package labels ..."
} | ||
|
||
var ( | ||
SchemeBuilder runtime.SchemeBuilder |
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.
exported var SchemeBuilder should have comment or be unexported
|
||
// +k8s:deepcopy-gen=package | ||
|
||
// Package api defines the API of the Cilium network policy interface |
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.
package comment should be of the form "Package labels ..."
} | ||
|
||
var ( | ||
SchemeBuilder runtime.SchemeBuilder |
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.
exported var SchemeBuilder should have comment or be unexported
17ccda8
to
9600030
Compare
daemon/k8s_watcher.go
Outdated
logfields.K8sAPIVersion: oldk8sNP.TypeMeta.APIVersion, | ||
logfields.K8sNetworkPolicyName + ".old": oldk8sNP.ObjectMeta.Name, | ||
logfields.K8sNamespace + ".old": oldk8sNP.ObjectMeta.Namespace, | ||
logfields.K8sNetworkPolicyName + ".new": newk8sNP.ObjectMeta.Name, |
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.
IMHO you should avoid creating new log field keys on the fly. When those logs are fed into an ELK stack, this will prevent correlating all the messages for this namespace. You should consistently use the same keys.
I'd suggest only renaming one pair of keys, e.g. keeping only the + ".old"
, or better log 2 messages with the different values.
This comment applies to the other places below where you create new keys like here.
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'll do that later #2006
f4c8423
to
c31c22f
Compare
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! Thanks for taking care of this.
Just remembered this - can you please document how to generate |
k8s.io/kubernetes v1.5.1 | ||
github.com/sasha-s/go-deadlock master | ||
github.com/petermattis/goid 0ded85884ba5c4c9267fcd5a149061f7c3455eee | ||
github.com/google/gops 25312cafb9a191a6d377c480a4666beec3105e4a | ||
github.com/kardianos/osext ae77be60afb1dcacde03767a8c37337fad28ac14 | ||
github.com/kr/text 7cafcd837844e784b526369c9bce262804aebc60 | ||
github.com/kr/pretty cfb55aafdaf3ec08f0db22699ab822c50091b1c4 | ||
github.com/optiopay/kafka 02fdf3fd241af9fe0b226577627e24b7f9a4c8e5 https://github.com/cilium/kafka | ||
github.com/optiopay/kafka 41e2198304524d5f0e0f47724832bcd385229902 https://github.com/cilium/kafka |
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.
Why are you updating kafka in this commit?
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.
02fd no longer exists, I had to update it to 41e21 which is the last one in https://github.com/cilium/kafka
github.com/golang/snappy 553a641470496b2327abcac10b36396bd98e45c9 | ||
github.com/kevinburke/ssh_config db49ba357de1f26c56dac48a5de39c65785bf24a | ||
github.com/onsi/ginkgo 11459a886d9cd66b319dac7ef1e917ee221372c9 | ||
github.com/onsi/gomega 283ed655c6b8238afecd5bea6434bc9b03129f2f | ||
github.com/googleapis/gnostic v0.1.0 |
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 these all new dependencies for k8s?
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.
yes
c31c22f
to
096cb81
Compare
func (in *CiliumNetworkPolicyList) DeepCopyObject() runtime.Object { | ||
if c := in.DeepCopy(); c != nil { | ||
return c | ||
} else { |
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.
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
func (in *CiliumNetworkPolicy) DeepCopyObject() runtime.Object { | ||
if c := in.DeepCopy(); c != nil { | ||
return c | ||
} else { |
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.
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
- Add DeepCopy methods needed for kubernetes CRDs. Signed-off-by: André Martins <andre@cilium.io>
Signed-off-by: André Martins <andre@cilium.io>
Signed-off-by: André Martins <andre@cilium.io>
Signed-off-by: André Martins <andre@cilium.io>
096cb81
to
af10b7f
Compare
This PR adds the proper deepcopy implementations in the structures that need to be deep copied before handling them on the kubernetes watcher callbacks.
Fixes #1885