fix: Add clear warning when Docker token is already in use

When a Docker agent tries to register with a token that's already bound
to another agent, the error was logged generically as "Failed to send
docker report". Users had to dig into logs to understand the issue.

Now logs a prominent error message:
"DOCKER REGISTRATION FAILED: This API token is already used by another
Docker agent. Each Docker host requires its own unique token. Generate
a new token in Pulse Settings > Agents and reinstall with the new token."

Related to #1027
This commit is contained in:
rcourtman 2026-01-03 20:56:04 +00:00
parent 22e1cc5613
commit fd7e80ae17

View file

@ -699,6 +699,14 @@ func (a *Agent) sendReportToTarget(ctx context.Context, target TargetConfig, pay
if errMsg == "" {
errMsg = resp.Status
}
// Detect token-already-in-use error and log a clear warning
if strings.Contains(errMsg, "already in use") {
a.logger.Error().
Str("pulseURL", target.URL).
Msg("DOCKER REGISTRATION FAILED: This API token is already used by another Docker agent. " +
"Each Docker host requires its own unique token. " +
"Generate a new token in Pulse Settings > Agents and reinstall with the new token.")
}
return fmt.Errorf("target %s: pulse responded %s: %s", target.URL, resp.Status, errMsg)
}