Skip to content

Log galactic-cni and fabric-config-agent as JSON at info #1165

Closed

Description

@privateip

Parent: #1144

Deliverable: galactic-cni and fabric-config-agent log as JSON at info level and honor LOG_LEVEL and LOG_FORMAT, like the binaries #1155 moved to internal/logging.

Both are long-running and log through slog's default handler, which nothing configures. Their lines are Go's default text format, and --log-level/--log-format don't exist for them.

  • galactic-cni's installer and its credential-refresh daemon log through slog throughout internal/installer, and the command exits through log.Fatalf in plain text.
  • fabric-config-agent, as the frr-init init container and the config-agent sidecar, logs through slog's default as well.

The CNI plugins (galactic-veth, -tap, -ipam, -bgp, -route) already write JSON to their log file and are out of scope. So is galactic-usid, a one-shot codec command in the debug image.

This is an interim step that doesn't wait for the library. #1147 moves these binaries onto the instrumentation library and supersedes this issue if it lands first.

Work items:

  • Call internal/logging from each binary's root command, as the controller-runtime binaries do, and report a startup error through the installed handler.
  • Extend TestBinariesUseThisPackage, or add a sibling test, so it fails when a long-running binary under cmd/ logs without installing the shared handler.
  • Document both binaries in the logging reference.

Dependencies: none.

Acceptance: In the lab, every line from both binaries' pods is JSON at info level by default, and LOG_LEVEL=debug adds debug lines.

Activity

  1. added
    tech-debt
    on Oct 27, 2026
  2. self-assigned this
    on Oct 27, 2026
  3. privateip commented on Oct 27, 2026

    @privateip
    ContributorAuthor

    Confirmed on main at ea783e8.

    Both binaries built from that commit reject the shared flags and write plain text:

    $ galactic-cni init --log-level debug
    2026/10/27 17:05:24 error: unknown flag: --log-level
    $ galactic-cni init
    2026/10/27 17:05:24 error: node name is required (use --node-name flag or GALACTIC_CNI_NODE_NAME env var)
    $ fabric-config-agent init --log-format json
    Error: unknown flag: --log-format

    Two findings beyond the issue text:

    • galactic-cni's root command doesn't set SilenceUsage, so cobra prints the full usage text on every runtime error from init or run, not only on bad flags.
    • None of the fix(logging): Log controller-runtime as JSON at info in every binary #1155 binaries routes its startup error through the installed handler either. cobra prints Error: ... as text and main exits. The fix here logs it through slog for these two binaries.
  4. privateip commented on Oct 27, 2026

    @privateip
    ContributorAuthor

    Plan, taken from the issue's work items:

    1. cmd/galactic-cni/main.go and cmd/fabric-config-agent/main.go bind logging.Options on the root command's persistent flags and call Setup from PersistentPreRunE, as galactic-router does. Both set SilenceErrors and SilenceUsage, and main logs the returned error with slog.Error before exiting 1. That replaces galactic-cni's log.Fatalf.
    2. A sibling of TestBinariesUseThisPackage requires every package under cmd/ to import internal/logging, except the five CNI plugins and galactic-usid, which are listed with the reason. It fails today for both binaries.
    3. docs/observability/logging.md lists both binaries and drops the sentence saying they configure logging separately.

    Risk: both binaries gain --log-level and --log-format and read LOG_LEVEL and LOG_FORMAT. Neither manifest sets those, so pods switch to JSON at info. Debug lines the binaries already emit stay hidden unless LOG_LEVEL=debug is set, which matches Go's default handler today.

  5. added a commit that references this issue on Oct 27, 2026
    37623ad
  6. added
    fabric-config-agent
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

fabric-config-agenttech-debt

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions