Merge pull request #79 from hippoley/fix/agent-session-renewal
Release / Prepare Scheduled Release (push) Has been skipped
Release / Publish Release (push) Failing after 1s

fix: renew agent session expiry on each heartbeat
This commit is contained in:
Qingshan Chen
2026-04-21 18:52:51 +08:00
committed by GitHub
@@ -229,6 +229,13 @@ func (s *instanceAgentService) Heartbeat(session *AgentSession, req AgentHeartbe
session.Agent.Status = agentStatusOnline
session.Agent.LastHeartbeatAt = &now
session.Agent.LastSeenIP = optionalString(strings.TrimSpace(clientIP))
// Renew session expiry on each successful heartbeat (rolling window).
// Without this, the 24-hour session token issued at Register() silently
// expires and the agent is permanently locked out until pod restart.
newExpiry := now.Add(24 * time.Hour)
session.Agent.SessionExpiresAt = &newExpiry
if err := s.agentRepo.Update(session.Agent); err != nil {
return nil, err
}