Skip to content

Commit 1a82db7

Browse files
committed
fix(NPC): check if new pod is actionable
Previously, kube-router would do a full sync on a new pod whether or not the pod was in an actionable state. This led to needless syncs as many pods were missing PodIP addresses or other items necessary to apply policy. If a pod is missing these items it is better to wait for the next message that comes via the UpdateFunc below so that we know that the pod has all of the necessary items to apply policy to it.
1 parent 3dc5c3f commit 1a82db7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/controllers/netpol/pod.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ import (
1414
func (npc *NetworkPolicyController) newPodEventHandler() cache.ResourceEventHandler {
1515
return cache.ResourceEventHandlerFuncs{
1616
AddFunc: func(obj interface{}) {
17-
npc.OnPodUpdate(obj)
18-
17+
if podObj, ok := obj.(*api.Pod); ok {
18+
// If the pod isn't yet actionable there is no action to take here anyway, so skip it. When it becomes
19+
// actionable, we'll get an update below.
20+
if isNetPolActionable(podObj) {
21+
npc.OnPodUpdate(obj)
22+
}
23+
}
1924
},
2025
UpdateFunc: func(oldObj, newObj interface{}) {
2126
newPodObj := newObj.(*api.Pod)

0 commit comments

Comments
 (0)