Skip to content

Commit c2b2fe6

Browse files
committed
controller: only listen to attachment list events
Signed-off-by: Miguel Duarte Barroso <[email protected]>
1 parent 6268447 commit c2b2fe6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pkg/controller/pod.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package controller
33
import (
44
"encoding/json"
55
"fmt"
6-
"reflect"
76
"strings"
87
"time"
98

@@ -192,7 +191,7 @@ func (pnc *PodNetworksController) handlePodUpdate(oldObj interface{}, newObj int
192191
remove DynamicAttachmentRequestType = "remove"
193192
)
194193

195-
if reflect.DeepEqual(oldPod.Annotations, newPod.Annotations) {
194+
if !didNetworkSelectionElementsChange(oldPod, newPod) {
196195
return
197196
}
198197
podNamespace := oldPod.GetNamespace()
@@ -473,3 +472,14 @@ func serializeNetAttachDefWithDefaults(netAttachDef *nadv1.NetworkAttachmentDefi
473472
}
474473
return netAttachDefWithDefaults, nil
475474
}
475+
476+
func didNetworkSelectionElementsChange(oldPod *corev1.Pod, newPod *corev1.Pod) bool {
477+
oldNetworkSelectionElementsString, didPodHaveExtraAttachments := oldPod.Annotations[nadv1.NetworkAttachmentAnnot]
478+
newNetworkSelectionElementsString, doesPodHaveExtraAttachmentsNow := newPod.Annotations[nadv1.NetworkAttachmentAnnot]
479+
480+
if didPodHaveExtraAttachments != doesPodHaveExtraAttachmentsNow ||
481+
oldNetworkSelectionElementsString != newNetworkSelectionElementsString {
482+
return true
483+
}
484+
return false
485+
}

0 commit comments

Comments
 (0)