opamp-go fixes retry delays, HTTP headers and agent state

opamp-go implements the Open Agent Management Protocol in Go for remote agent management. This week’s main branch changes honor server retry delays and refresh HTTP headers on every attempt. They also let agent callbacks refresh state before requested reports.

WebSocket clients honor server retry delays

The merged WebSocket retry change handles RetryInfo in an UNAVAILABLE response over an established connection. The client schedules AgentDisconnect and closes the connection. It then waits for the supplied delay before the next connection attempt. This gives an unavailable server control over when the client reconnects.

The client still calls OnError for the response. The delay applies when the error type is UNAVAILABLE and the response contains RetryInfo. This condition matters for servers that send other error responses over the same connection.

The regression test in the commit checks the delay between closure and reconnection. It also checks that a stop during the delay prevents another connection attempt.

HTTP retries refresh authentication headers

The HeaderFunc fix moves header generation into attemptRequest. The HTTP client now invokes HeaderFunc for each attempt, including retries. The old retry loop reused headers from the first request. If a token expired during that sequence, later attempts repeated the expired credentials.

Application code still supplies the token through the callback. The change gives that callback another opportunity to return valid credentials. It also preserves the OpAMP instance UID when the client rebuilds the headers.

The HTTP regression test returns HTTP 503 twice, then HTTP 200. It checks three distinct Authorization values and the same instance UID across all three attempts.

Callbacks can refresh requested agent reports

The callback API change adds MessageData.Flags. Applications can inspect ReportFullState and ReportAvailableComponents through OnMessage.

The order matters here. In client/internal/receivedprocessor.go, OnMessage runs before rcvFlags prepares the requested report. A callback can call SetHealth or SetAvailableComponents before that preparation uses the stored state. Agents with dynamic component inventories can refresh their data in response to the server’s request.

Configuration hashes and structured values compare correctly

The example server fix corrects an inverted hash comparison in internal/examples/server/data/agent.go. During configuration reevaluation, a different LastRemoteConfigHash triggers a resend of the current configuration. A matching hash does not trigger a resend by itself. If your server copied this example, check the equivalent comparison.

Separately, the array and key value comparison fix repairs IsEqualAnyValue in protobufshelpers. Equal element pairs incorrectly caused false results. Arrays with every element different could compare equal. An identical element pointer also ended the whole array comparison too early.

The corrected loop checks the remaining elements after an identical pointer. Its tests include arrays that differ after a nil first element. These cases deserve attention in code that uses the helpers to detect changes in structured values.

What to watch

  • For WebSocket clients, test UNAVAILABLE with RetryInfo and a stop during the retry delay. Check both reconnection timing and shutdown.
  • For HTTP clients, test token expiry across retries. A HeaderFunc that returns an expired cached token still needs correct refresh logic.
  • These changes describe main activity. Before an upgrade, confirm that your selected module version contains the relevant commits.

← All updates