From 7f449d30e0eaccae965d8b4ad409613ea66e2096 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 26 Nov 2025 10:23:22 +0000 Subject: [PATCH] fix: cache daemon ID at init to prevent Podman token binding conflicts Podman can return unstable or empty daemon IDs across API calls. When the agent fetched info.ID on every report cycle, this could cause the agent identity to change mid-session, triggering "token already in use" errors on the server. Cache the daemon ID at initialization and use it consistently for all reports. Related to #740 --- internal/dockeragent/agent.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/dockeragent/agent.go b/internal/dockeragent/agent.go index cd0249b..64ae03e 100644 --- a/internal/dockeragent/agent.go +++ b/internal/dockeragent/agent.go @@ -87,6 +87,7 @@ type Agent struct { cfg Config docker *client.Client daemonHost string + daemonID string // Cached at init; Podman can return unstable IDs across calls runtime RuntimeKind runtimeVer string agentVersion string @@ -238,6 +239,7 @@ func New(cfg Config) (*Agent, error) { cfg: cfg, docker: dockerClient, daemonHost: dockerClient.DaemonHost(), + daemonID: info.ID, // Cache at init for stable agent ID runtime: runtimeKind, runtimeVer: info.ServerVersion, agentVersion: agentVersion, @@ -622,7 +624,10 @@ func (a *Agent) buildReport(ctx context.Context) (agentsdocker.Report, error) { agentID := a.cfg.AgentID if agentID == "" { - agentID = info.ID + // Use cached daemon ID from init rather than info.ID from current call. + // Podman can return different/empty IDs across calls, causing token + // binding conflicts on the server. + agentID = a.daemonID } if agentID == "" { agentID = a.machineID