fix: Container update command incorrectly removes Docker host and revokes token

When a container update command completed successfully, the server was
incorrectly returning shouldRemove=true, which caused the Docker host to
be removed and its API token revoked. This caused 401 Unauthorized errors
for subsequent agent reports.

The fix ensures shouldRemove is only true for "stop" commands, not for
"update_container" or "check_updates" commands.

Related to #1020
This commit is contained in:
rcourtman
2026-01-03 19:05:18 +00:00
parent 233278a9d2
commit abccbcafb6

View File

@@ -362,7 +362,11 @@ func (m *Monitor) acknowledgeDockerCommand(commandID, hostID, status, message st
case DockerCommandStatusCompleted:
cmd.markAcknowledged(message)
cmd.markCompleted(message)
shouldRemove = true
// Only remove the Docker host if this was a "stop" command.
// Other commands (update_container, check_updates) should not remove the host.
if cmd.status.Type == DockerCommandTypeStop {
shouldRemove = true
}
case DockerCommandStatusFailed:
cmd.markFailed(message)
m.state.SetDockerHostPendingUninstall(resolvedHostID, false)