Skip to content

feat: propogate debug flag to worker backend.#275

Open
unlisted wants to merge 1 commit intodevelopfrom
feat/pass-debug-option-to-discovery-worker
Open

feat: propogate debug flag to worker backend.#275
unlisted wants to merge 1 commit intodevelopfrom
feat/pass-debug-option-to-discovery-worker

Conversation

@unlisted
Copy link

@unlisted unlisted commented Feb 5, 2026

Description

This PR introduces support for a debug flag that propagates from the CLI to the agent and down to the worker backend, enabling the orb-worker process to be started with the --debug flag if supported. The changes include:

  • Adding a debug field to the agent and backend configuration structures.
  • Passing the debug flag from the CLI (main.go) to the agent and worker backend.
  • Implementing logic in the worker backend to check if the orb-worker binary supports the --debug flag before appending it to the command-line arguments.
  • Updating the agent’s constructor and backend configuration to handle the debug flag.
  • Adding unit tests for the worker backend to verify detection of --debug support.
  • Updating .gitignore to include CLAUDE.md.

Testing

Unit Tests

  • Added worker_debug_test.go to test the detection of --debug support in the orb-worker binary.
  • Updated existing agent tests to use the new agent constructor signature with the debug flag.
  • All existing and new tests pass, confirming that the debug flag is correctly handled and that the agent and worker backend behave as expected.Description

Dev Test

Tested locally against with local aci integration against live cisco-aci lab environment.

  • built orb-agent locally
  • installed cisco-aci into local python env
  • installed orb-discover worker with #269 changes into local python env
  • run orb-agent with debug parameter
(venv) ~/local$>DIODE_CLIENT_ID=diode-ingest DIODE_CLIENT_SECRET="***" ./orb-agent run --debug -c orb/agent.yaml
{"time":"2026-02-05T11:25:03.41716-05:00","level":"INFO","msg":"backends loaded","backends":{"common":{"diode":{"agent_name":"agent02","client_id":"${DIODE_CLIENT_ID}","client_secret":"${DIODE_CLIENT_SECRET}","target":"grpc://localhost:8080/diode"}},"worker":{"port":8897}}}
{"time":"2026-02-05T11:25:03.418631-05:00","level":"INFO","msg":"no secrets manager specified or invalid type, skipping"}
{"time":"2026-02-05T11:25:03.418856-05:00","level":"INFO","msg":"agent started","version":"1.0.0","routine":"agentRoutine"}
{"time":"2026-02-05T11:25:03.41886-05:00","level":"INFO","msg":"requested backends","values":{"common":{"diode":{"agent_name":"agent02","client_id":"${DIODE_CLIENT_ID}","client_secret":"${DIODE_CLIENT_SECRET}","target":"grpc://localhost:8080/diode"}},"worker":{"port":8897}}}
{"time":"2026-02-05T11:25:03.419047-05:00","level":"INFO","msg":"registered backends","values":["device_discovery","network_discovery","opentelemetry_infinity","snmp_discovery","pktvisor","worker"]}
{"time":"2026-02-05T11:25:03.419444-05:00","level":"INFO","msg":"worker startup","backend":"worker","arguments":["--diode-target","grpc://localhost:8080/diode","--diode-client-id","${DIODE_CLIENT_ID}","--diode-client-secret","********","--diode-app-name-prefix","agent02","--host","localhost","--port","8897","--debug"]}
{"time":"2026-02-05T11:25:04.127735-05:00","level":"DEBUG","msg":"Debug logging enabled","backend":"worker","module":"worker.main"}
{
...
{"time":"2026-02-05T11:25:05.483668-05:00","level":"DEBUG","msg":"Added site: ACI Fabric","backend":"worker","module":"nbl_cisco_aci.builders.sites"}
{
...
{"time":"2026-02-05T11:25:05.485555-05:00","level":"DEBUG","msg":"Policy custom_policy: Backend execution completed in 0.004 seconds","backend":"worker","module":"worker.policy.runner"}
{

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdc5eee555

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +177 to +179
if d.debug {
dOptions = append(dOptions, "--debug")
}

Choose a reason for hiding this comment

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

P1 Badge Gate debug flag on worker capability check

When --debug is enabled, Start now always appends --debug to the worker command, but this bypasses the newly added compatibility check and can break startup with older orb-worker binaries that do not support that flag. The commit introduces checkWorkerSupportsDebug() specifically to avoid this scenario, so Start should only append --debug when that check succeeds.

Useful? React with 👍 / 👎.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 1.05s github.com/netboxlabs/orb-agent/agent 44.1% 6 0 0
🟢 PASS 31.89s github.com/netboxlabs/orb-agent/agent/backend 75.2% 40 0 0
🟢 PASS 6.04s github.com/netboxlabs/orb-agent/agent/backend/devicediscovery 66.5% 4 0 0
🟢 PASS 0.79s github.com/netboxlabs/orb-agent/agent/backend/mocks 0.0% 0 0 0
🟢 PASS 6.03s github.com/netboxlabs/orb-agent/agent/backend/networkdiscovery 58.3% 4 0 0
🟢 PASS 4.02s github.com/netboxlabs/orb-agent/agent/backend/opentelemetryinfinity 45.2% 2 0 0
🟢 PASS 4.03s github.com/netboxlabs/orb-agent/agent/backend/pktvisor 66.5% 2 0 0
🟢 PASS 6.03s github.com/netboxlabs/orb-agent/agent/backend/snmpdiscovery 58.3% 4 0 0
🟢 PASS 7.04s github.com/netboxlabs/orb-agent/agent/backend/worker 68.0% 7 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/config 100.0% 6 0 0
🟢 PASS 1.37s github.com/netboxlabs/orb-agent/agent/configmgr 48.1% 32 0 0
🟢 PASS 2.72s github.com/netboxlabs/orb-agent/agent/configmgr/fleet 62.9% 145 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/otlpbridge 44.1% 8 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/policies 98.9% 18 0 0
🟢 PASS 1.03s github.com/netboxlabs/orb-agent/agent/policymgr 71.6% 11 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/redact 81.6% 84 0 0
🟢 PASS 21.35s github.com/netboxlabs/orb-agent/agent/secretsmgr 47.1% 65 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/telemetry 81.7% 19 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/version 100.0% 1 0 0

Total coverage: 58.8%

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.

2 participants