fix(upgrade): break auto-apply restart loop (0.9.8)
Two bugs in 0.9.6/0.9.7 caused an infinite restart loop after a Force update
signal: the CLI never reported the upgrade outcome, so `upgrade_requested`
stayed `true`; AND `applyAutoUpgrade` called `os.Exit(0)` even when the
target version equalled the current one, so systemd respawned and saw the
flag again.
- new Client.ReportUpgradeResult → POST /api/internal/agent/upgrade-result
- applyAutoUpgrade calls it on success / failure / no-op
- no-op case detected up front (same version) — skips Execute + Exit,
clears server flag instead
This commit is contained in:
parent
7e96976257
commit
2e7cd7e8ed
4 changed files with 77 additions and 2 deletions
|
|
@ -91,6 +91,24 @@ func (c *Client) Deregister(ctx context.Context, agentID string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ReportUpgradeResult tells the server the outcome of a previously requested
|
||||
// upgrade so the server can clear `upgrade_requested`. Without this call the
|
||||
// flag stays sticky and the daemon would re-trigger applyAutoUpgrade on every
|
||||
// sync after upgrade — even for "already on target version" no-ops.
|
||||
func (c *Client) ReportUpgradeResult(ctx context.Context, agentID string, success bool, version, errMsg string) error {
|
||||
req := struct {
|
||||
AgentID string `json:"agentId"`
|
||||
Success bool `json:"success"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}{AgentID: agentID, Success: success, Version: version, Error: errMsg}
|
||||
var resp StatusResponse
|
||||
if err := c.doPost(ctx, "/api/internal/agent/upgrade-result", req, &resp); err != nil {
|
||||
return fmt.Errorf("report upgrade result: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReportStatus reports download progress. Returns server-side flags the CLI must act on.
|
||||
func (c *Client) ReportStatus(ctx context.Context, update StatusUpdate) (*StatusResponse, error) {
|
||||
var resp StatusResponse
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue