Skip to content

Commit

Permalink
watcher: Don't start watcher in NewK8sWatcher
Browse files Browse the repository at this point in the history
Since Start() is now an exported method of K8sWatcher, it makes sense to
separate responsibilities of creating and starting the watcher.

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
  • Loading branch information
lambdanis committed Feb 29, 2024
1 parent 177bddd commit 2a2a2dd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/tetragon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ func tetragonExecute() error {
log.Info("Disabling Kubernetes API")
k8sWatcher = watcher.NewFakeK8sWatcher(nil)
}
k8sWatcher.Start()
_, err = cilium.InitCiliumState(ctx, option.Config.EnableCilium)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/process/podinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestK8sWatcher_GetPodInfo(t *testing.T) {

k8sClient := fake.NewSimpleClientset(&pod)
watcher := watcher.NewK8sWatcher(k8sClient, time.Hour)
watcher.Start()
pid := uint32(1)
podInfo := getPodInfo(watcher, "abcd1234", "curl", "cilium.io", 1)
assert.True(t, proto.Equal(podInfo, &tetragon.Pod{
Expand Down
2 changes: 0 additions & 2 deletions pkg/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ func NewK8sWatcher(k8sClient kubernetes.Interface, stateSyncIntervalSec time.Dur

podhooks.InstallHooks(podInformer)

k8sWatcher.Start()

return k8sWatcher
}

Expand Down

0 comments on commit 2a2a2dd

Please sign in to comment.