Skip to content

Commit

Permalink
pkg/k8s: ignore status field in CNP DeepEqual
Browse files Browse the repository at this point in the history
The status field should be ignored when comparing 2 CNPs as this field
does not matter to the policy enforcement of the CNP.

This fixes a bug introduced by 134fdb5 which make Cilium to process
all CNP events from k8s including the ones where a status was the only
field modified. This made a cluster with 2 or more nodes to concurrently
trying the update its own status in the CNP causing the other node to
receive and process the CNP event.

Fixes: 134fdb5 ("k8s/watchers: fix missing missing CNP/CCNP updates")
Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed Jun 18, 2020
1 parent 753d315 commit 82e36cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/k8s/apis/cilium.io/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ type CiliumNetworkPolicy struct {

// Status is the status of the Cilium policy rule
// +optional
// +deepequal-gen=false
Status CiliumNetworkPolicyStatus `json:"status"`
}

// DeepEqual compares 2 CNPs while ignoring the LastAppliedConfigAnnotation and
// ignoring the Status field of the CNP.
func (in *CiliumNetworkPolicy) DeepEqual(other *CiliumNetworkPolicy) bool {
switch {
case (in == nil) != (other == nil):
Expand Down
4 changes: 0 additions & 4 deletions pkg/k8s/apis/cilium.io/v2/zz_generated.deepequal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 82e36cd

Please sign in to comment.