Skip to content

Commit b4fee75

Browse files
committed
Fix the issues in watchKubesharkConfigMap
1 parent 30438b1 commit b4fee75

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pkg/kubernetes/watcher.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,27 @@ func (watcher *Watcher) watchKubesharkConfigMap(ctx context.Context) error {
5555
select {
5656
case event := <-w.ResultChan():
5757
if event.Object == nil {
58-
return errors.New("error in kubeshark configmap watch")
58+
continue
5959
}
6060

6161
// Only consider the Added or Modified events
6262
if event.Type != watch.Added && event.Type != watch.Modified {
63-
return nil
63+
continue
6464
}
6565

66-
oldRegex := watcher.regex.String()
67-
oldNamespaces := watcher.namespaces
66+
var oldRegex string
67+
var oldNamespaces []string
68+
if watcher.regex != nil {
69+
oldRegex = watcher.regex.String()
70+
}
71+
oldNamespaces = watcher.namespaces
6872
watcher.regex, watcher.namespaces = SyncConfig(event.Object.(*v1.ConfigMap))
6973

7074
// No change in pod regex or targeted namespaces
71-
if watcher.regex.String() == oldRegex && strings.Join(watcher.namespaces, ",") == strings.Join(oldNamespaces, ",") {
72-
return nil
75+
if watcher.regex != nil {
76+
if watcher.regex.String() == oldRegex && strings.Join(watcher.namespaces, ",") == strings.Join(oldNamespaces, ",") {
77+
continue
78+
}
7379
}
7480

7581
err = updateCurrentlyTargetedPods(ctx, watcher.clientSet, watcher.regex, watcher.namespaces, watcher.callback)

0 commit comments

Comments
 (0)