Skip to content

Conversation

@jajeffries
Copy link
Contributor

This pull request refactors how the agent's ID and MQTT topics are managed and used throughout the fleet manager and heartbeater components. The changes remove legacy topic configuration fields, introduce a dedicated agent_id field, and update how topics are generated and passed between components. Unit tests are updated to reflect these changes and ensure correct agent ID handling in heartbeat messages.

Configuration and Topic Management Updates:

  • Removed legacy topic configuration fields (HeartbeatTopic, CapabilitiesTopic, TopicName) from the FleetManager struct and added a new AgentID field for explicit agent identification. (agent/config/types.go)
  • Refactored topic generation: now topics are derived using a new template function based on JWT claims and the configured agent_id, instead of merging configuration and token response values. (agent/configmgr/fleet.go)

Heartbeater and Fleet Manager Refactoring:

  • Updated sendSingleHeartbeat and sendHeartbeats methods to accept and use the agentID parameter, ensuring heartbeats carry the correct agent identity. (agent/configmgr/fleet.go) [1] [2]
  • Changed fleet manager connection logic to propagate agentID through all relevant calls, including MQTT connection setup. (agent/configmgr/fleet.go) [1] [2] [3]

Token Response Structure Changes:

  • Removed the Topics field from the tokenResponse struct, as topic information is now generated separately from JWT and configuration. (agent/configmgr/fleet.go)

Unit Test Updates:

@github-actions
Copy link

github-actions bot commented Sep 3, 2025

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 0.01s github.com/netboxlabs/orb-agent/agent 0.0% 0 0 0
🟢 PASS 0.01s github.com/netboxlabs/orb-agent/agent/backend 0.0% 0 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/devicediscovery 76.0% 3 0 0
🟢 PASS 0.00s github.com/netboxlabs/orb-agent/agent/backend/mocks 0.0% 0 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/networkdiscovery 75.8% 3 0 0
🟢 PASS 4.02s github.com/netboxlabs/orb-agent/agent/backend/otel 76.4% 2 0 0
🟢 PASS 3.02s github.com/netboxlabs/orb-agent/agent/backend/pktvisor 65.6% 2 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/snmpdiscovery 75.8% 3 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/worker 76.0% 3 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/config 100.0% 6 0 0
🟢 PASS 61.49s github.com/netboxlabs/orb-agent/agent/configmgr 59.8% 66 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/policies 100.0% 15 0 0
🟢 PASS 1.03s github.com/netboxlabs/orb-agent/agent/policymgr 70.3% 10 0 0
🟢 PASS 24.57s github.com/netboxlabs/orb-agent/agent/secretsmgr 45.7% 45 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/version 100.0% 1 0 0

Total coverage: 59.9%

Copy link
Contributor

@leoparente leoparente left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jajeffries jajeffries merged commit f53b170 into fleet_manager Sep 4, 2025
2 checks passed
@jajeffries jajeffries deleted the feat/OBS-1397-topics branch September 4, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants