Skip to content
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

Merged
merged 4 commits into from
Nov 10, 2017

Conversation

aanm
Copy link
Member

@aanm aanm commented Nov 7, 2017

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

Implemented deep copy functionality when receiving events from kubernetes watcher #1885

@aanm aanm added the wip label Nov 7, 2017
@aanm aanm requested a review from a team November 7, 2017 14:15
@aanm aanm requested review from a team as code owners November 7, 2017 14:15
@aanm aanm requested review from a team November 7, 2017 14:15
@aanm aanm requested a review from a team as a code owner November 7, 2017 14:15

// +k8s:deepcopy-gen=package

// Package api defines the API of the Cilium network policy interface

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

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

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

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

@aanm aanm force-pushed the creating-deep-copy-in-k8s-watcher-2 branch from 17ccda8 to 9600030 Compare November 7, 2017 14:53
logfields.K8sAPIVersion: oldk8sNP.TypeMeta.APIVersion,
logfields.K8sNetworkPolicyName + ".old": oldk8sNP.ObjectMeta.Name,
logfields.K8sNamespace + ".old": oldk8sNP.ObjectMeta.Namespace,
logfields.K8sNetworkPolicyName + ".new": newk8sNP.ObjectMeta.Name,
Copy link
Contributor

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.

Copy link
Member Author

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

@aanm aanm force-pushed the creating-deep-copy-in-k8s-watcher-2 branch 2 times, most recently from f4c8423 to c31c22f Compare November 9, 2017 22:53
@aanm aanm added sig/k8s Impacts the kubernetes API, or kubernetes -> cilium internals translation layers. kind/bug This is a bug in the Cilium logic. kind/enhancement This would improve or streamline existing functionality. pending-review release-note/bug This PR fixes an issue in a previous release of Cilium. and removed wip labels Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
@cilium cilium deleted a comment from houndci-bot Nov 9, 2017
Copy link
Member

@ianvernon ianvernon left a 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.

@ianvernon
Copy link
Member

Just remembered this - can you please document how to generate DeepCopy functions?

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
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@aanm aanm force-pushed the creating-deep-copy-in-k8s-watcher-2 branch from c31c22f to 096cb81 Compare November 10, 2017 08:58
func (in *CiliumNetworkPolicyList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {

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 {

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>
@aanm aanm force-pushed the creating-deep-copy-in-k8s-watcher-2 branch from 096cb81 to af10b7f Compare November 10, 2017 09:20
@aanm aanm requested a review from tgraf November 10, 2017 12:46
@tgraf tgraf merged commit 28fc671 into master Nov 10, 2017
@tgraf tgraf deleted the creating-deep-copy-in-k8s-watcher-2 branch November 10, 2017 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is a bug in the Cilium logic. kind/enhancement This would improve or streamline existing functionality. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/k8s Impacts the kubernetes API, or kubernetes -> cilium internals translation layers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants