From 1fad6e8e4456e928f433255a13fd508e977fb1c6 Mon Sep 17 00:00:00 2001 From: dhurley Date: Wed, 28 Jun 2023 11:49:11 +0100 Subject: [PATCH 1/2] Add nil check for controller when agent is shutting down --- Makefile | 2 +- main.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f41ba9e74..9d85f6b15 100644 --- a/Makefile +++ b/Makefile @@ -270,7 +270,7 @@ oss-image: ## Build agent container image for NGINX OSS @echo Building image with $(CONTAINER_CLITOOL); \ $(CONTAINER_BUILDENV) $(CONTAINER_CLITOOL) build -t ${IMAGE_TAG} . \ --no-cache -f ./scripts/docker/nginx-oss/${CONTAINER_OS_TYPE}/Dockerfile \ - --target install-agent-local + --target install-agent-local \ --build-arg PACKAGE_NAME=${PACKAGE_NAME} \ --build-arg PACKAGES_REPO=${OSS_PACKAGES_REPO} \ --build-arg BASE_IMAGE=${BASE_IMAGE} \ diff --git a/main.go b/main.go index fc84bdde4..7004324ea 100644 --- a/main.go +++ b/main.go @@ -137,8 +137,10 @@ func handleSignals( log.Errorf("Error sending AgentStopped event to command channel: %v", err) } - if err := controller.Close(); err != nil { - log.Errorf("Unable to close controller: %v", err) + if controller != nil { + if err := controller.Close(); err != nil { + log.Errorf("Unable to close controller: %v", err) + } } log.Warn("NGINX Agent exiting") From 8d0331acb179177f89efcf295271883319aa7a12 Mon Sep 17 00:00:00 2001 From: dhurley Date: Wed, 28 Jun 2023 13:45:23 +0100 Subject: [PATCH 2/2] Update log message from error to warn --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 7004324ea..5bd5a1c88 100644 --- a/main.go +++ b/main.go @@ -139,7 +139,7 @@ func handleSignals( if controller != nil { if err := controller.Close(); err != nil { - log.Errorf("Unable to close controller: %v", err) + log.Warnf("Unable to close controller: %v", err) } }