Skip to content

Commit

Permalink
watcher: Don't start watcher in NewK8sWatcher
Browse files Browse the repository at this point in the history
[ upstream commit da91e33 ]

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>
Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
  • Loading branch information
lambdanis authored and michi-covalent committed Apr 4, 2024
1 parent 4d52a50 commit 77299db
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 @@ -387,6 +387,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 @@ -146,8 +146,6 @@ func NewK8sWatcher(k8sClient kubernetes.Interface, stateSyncIntervalSec time.Dur

podhooks.InstallHooks(podInformer)

k8sWatcher.Start()

return k8sWatcher
}

Expand Down

0 comments on commit 77299db

Please sign in to comment.