Skip to content

[Go SDK] registerNode hardcodes HeartbeatInterval as 0s #439

@santoshkumarradha

Description

@santoshkumarradha

Summary

registerNode in the Go SDK agent hardcodes HeartbeatInterval: "0s" in the registration payload regardless of the agent's configured LeaseRefreshInterval, silently preventing the control plane from using the agent's intended check-in cadence.

Context

agent.go:684 constructs the node registration request with HeartbeatInterval: "0s". The agent's actual cfg.LeaseRefreshInterval is configured by the caller but never sent to the control plane. The control plane uses the registered heartbeat interval to calculate presence TTLs and schedule lease refresh windows. A hardcoded "0s" either causes the control plane to fall back to its own default (undocumented behavior) or to mark the node as expired immediately. Agents with custom refresh intervals (e.g. long-running batch agents) will have incorrect presence TTLs, causing premature eviction from the active node list.

Scope

In Scope

  • Format a.cfg.LeaseRefreshInterval as a Go duration string (e.g. "30s") and send it as HeartbeatInterval in the registration payload.
  • If LeaseRefreshInterval is zero, fall back to a documented default (e.g. "30s") rather than sending "0s".
  • Document the fallback default in AgentConfig godoc.

Out of Scope

  • Changing the registration API schema on the control plane side (the field already exists).
  • Modifying the lease refresh timer logic — just fix the registration payload.
  • Adding dynamic heartbeat interval negotiation.

Files

  • sdk/go/agent/agent.go:684 — replace HeartbeatInterval: "0s" with HeartbeatInterval: formatDuration(a.cfg.LeaseRefreshInterval)
  • sdk/go/agent/agent.go — add a formatDuration helper (or inline) that formats a time.Duration as a string and returns a default when zero
  • sdk/go/agent/agent_test.go — test: agent registered with LeaseRefreshInterval: 45s sends HeartbeatInterval: "45s" in the registration payload; agent with zero interval sends the documented default

Acceptance Criteria

  • The registration payload reflects the agent's configured LeaseRefreshInterval as HeartbeatInterval
  • Zero or negative LeaseRefreshInterval falls back to a documented non-zero default
  • The hardcoded "0s" is removed
  • Tests pass (go test ./sdk/go/...)
  • Linting passes (make lint)

Notes for Contributors

Severity: LOW

Use time.Duration.String() to format durations — it produces the standard Go duration string format (e.g. "30s", "1m30s") that the control plane's time.ParseDuration can parse back. Cross-check the control plane's registration handler to confirm it accepts this format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsdk:goGo SDK related

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions