From 49289477dcb8a07fd628d0215ef6e09195140f86 Mon Sep 17 00:00:00 2001 From: Ritik Jain <60597329+re-Tick@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:27:09 +0530 Subject: [PATCH] fix: adds a nil check before stopping the ebpf hooks (#1635) * fix: adds a nil check before stopping the ebpf hooks * style: formats the changes in loader.go Signed-off-by: re-Tick * style(proxy.go): formats and removes unwanted debug logs in proxy Signed-off-by: re-Tick --------- Signed-off-by: re-Tick --- pkg/hooks/loader.go | 6 ++++++ pkg/proxy/proxy.go | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/hooks/loader.go b/pkg/hooks/loader.go index 3db2b95e7..a121d8afa 100755 --- a/pkg/hooks/loader.go +++ b/pkg/hooks/loader.go @@ -62,6 +62,7 @@ type Hook struct { mutex sync.RWMutex userAppCmd *exec.Cmd userAppShutdownInitiated bool + isHooksLoaded bool mainRoutineId int // ebpf objects and events @@ -583,6 +584,9 @@ func deleteFileIfExists(filename string, logger *zap.Logger) error { } func (h *Hook) Stop(forceStop bool) { + if !h.isHooksLoaded || h.socket == nil { + return + } if !forceStop && !h.IsUserAppTerminateInitiated() { h.logger.Info("Received signal to exit keploy program..") @@ -976,6 +980,8 @@ func (h *Hook) LoadHooks(appCmd, appContainer string, pid uint32, ctx context.Co h.SendAppPid(pid) } + // hooks are loaded so inform the state + h.isHooksLoaded = true return nil } diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index c2f27abf4..be9b44c16 100755 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -356,8 +356,6 @@ func SetupCA(logger *zap.Logger, pid uint32, lang string) error { return err } - fmt.Println("set the certificate path in environment", os.Getenv("NODE_EXTRA_CA_CERTS")) - // for python err = os.Setenv("REQUESTS_CA_BUNDLE", tempCertPath) if err != nil {