diff --git a/internal/dockeragent/agent.go b/internal/dockeragent/agent.go index c7b5f97..ade465e 100644 --- a/internal/dockeragent/agent.go +++ b/internal/dockeragent/agent.go @@ -1536,7 +1536,7 @@ func detectHostRemovedError(body []byte) string { func (a *Agent) checkForUpdates(ctx context.Context) { // Skip updates if disabled via config if a.cfg.DisableAutoUpdate { - a.logger.Debug().Msg("Skipping update check - auto-update disabled") + a.logger.Info().Msg("Skipping update check - auto-update disabled") return } diff --git a/internal/dockeragent/agent_log_test.go b/internal/dockeragent/agent_log_test.go new file mode 100644 index 0000000..00b492a --- /dev/null +++ b/internal/dockeragent/agent_log_test.go @@ -0,0 +1,40 @@ +package dockeragent + +import ( + "bytes" + "context" + "strings" + "testing" + + "github.com/rs/zerolog" +) + +func TestCheckForUpdatesLog(t *testing.T) { + // Create a buffer to capture logs + var buf bytes.Buffer + logger := zerolog.New(&buf) + + // Create an agent with DisableAutoUpdate set to true + agent := &Agent{ + cfg: Config{ + DisableAutoUpdate: true, + }, + logger: logger, + } + + // Call checkForUpdates + agent.checkForUpdates(context.Background()) + + // Check logs + output := buf.String() + expected := "Skipping update check - auto-update disabled" + if !strings.Contains(output, expected) { + t.Errorf("expected log message %q not found in output:\n%s", expected, output) + } + + // Verify log level is INFO (zerolog default level is debug? no, default global is info, but logger.Info() writes regardless) + // Zerolog JSON output contains "level":"info" + if !strings.Contains(output, `"level":"info"`) { + t.Errorf("expected log level info, got output:\n%s", output) + } +} diff --git a/scripts/install-docker-agent.sh b/scripts/install-docker-agent.sh index 366a2ae..57f2992 100755 --- a/scripts/install-docker-agent.sh +++ b/scripts/install-docker-agent.sh @@ -1805,7 +1805,7 @@ if command -v curl &> /dev/null || command -v wget &> /dev/null; then if [[ -n "$SERVER_INFO" ]] && echo "$SERVER_INFO" | grep -q '"isDevelopment"[[:space:]]*:[[:space:]]*true'; then NO_AUTO_UPDATE_FLAG=" --no-auto-update" - log_info 'Development server detected – auto-update disabled' + log_warn "Server is in development mode; disabling agent auto-update" fi if [[ -n "$NO_AUTO_UPDATE_FLAG" ]] && ! "$AGENT_PATH" --help 2>&1 | grep -q -- '--no-auto-update'; then