Repository navigation
fix(logging): Log galactic-cni and fabric-config-agent as JSON - #1170
Conversation
|
Both reviewers returned merge on f32dbad, the head before the fix phase.
What was checked: pr-adversary reproduced the cited runs and ran the new test at the head. The conventions review covered the body, the commit conventions, and the test comment, against the parent ea783e8. Applied: the PR body now opens with a three-sentence summary, with the file list removed, and carries a four-item test plan with the lab item unchecked. The unmanagedBinaries comment no longer makes an unchecked claim about the CNI plugins' log files, in 0cc1ca6. CI: 21 checks passed on 0cc1ca6, including E2E Tests. publish-service-api skipped under its own condition. Open #1168 touches the same two files. A trial merge-tree of this branch onto #1168's head and onto origin/main is clean both ways, and #1168's checker keeps no list of binaries, so either PR can land first. Auto-merge uses the merge method, because main allows only merge. The main ruleset requires one approval, code owner review, and a fresh approval after the last push, so the PR waits for a human approval before it lands. The repository names no human reviewer, so the code owners team networking was requested when the PR went ready. |
ecv
left a comment
There was a problem hiding this comment.
Request changes.
The branch predates #1168, and on current main this PR fails TestBinariesListsEveryCaller. Merged onto main (06950df), go test ./internal/logging/ reports commands importing internal/logging = [... fabric-config-agent ... galactic-cni ...] against Binaries without those two. CI is green only because it ran on the old base.
internal/logging/logging.go: addfabric-config-agentandgalactic-cnitoBinaries. The list is whathack/check-log-settingsuses to find containers whoseLOG_LEVEL/LOG_FORMAT/--log-level/--log-formatvalues it validates, so without them a bad value in thegalactic-cniorfabric-config-agentmanifests would still crash-loop the init container or sidecar at startup without failing CI. Both images are published under those names, so the image-repository match works. Rebase onto main first.- No log line reaches a CNI plugin's stdout:
galactic-cniis the installer and daemon, not a plugin invoked per CNI call, andinternal/loggingwrites toos.Stderr. The onlyfmt.Print*calls are--build-infoand--version. - The
log.Fatalfreplacement is equivalent: it logs one JSONerrorline, thenos.Exit(1).SilenceErrorsstops cobra printing a second copy, andSilenceUsageis kept.
Both binaries logged through slog's default handler, which nothing configured, so their lines were Go's default text and they had no --log-level or --log-format. galactic-cni also exited through log.Fatalf and printed its full usage on every runtime error. Both now bind logging.Options on the root command and call Setup from PersistentPreRunE, as the controller-runtime binaries do since #1155. They default to JSON at info and read LOG_LEVEL and LOG_FORMAT. A startup error is logged through the installed handler and the process exits 1; cobra's own error and usage output is silenced. TestLongRunningBinariesInstallTheHandler fails when a command under cmd/ doesn't import internal/logging. The CNI plugins and galactic-usid are listed as exempt with the reason. Fixes #1165
The exemption comment said the CNI plugins log as JSON to their own file. Nothing checks that, and the test only checks that a binary imports the shared handler. The comment now says only how each exempt command runs.
…gent #1168 added logging.Binaries, the list hack/check-log-settings uses to find the containers whose LOG_LEVEL, LOG_FORMAT, --log-level and --log-format it validates, and TestBinariesListsEveryCaller, which fails once galactic-cni and fabric-config-agent import internal/logging without being listed. Both are now listed. galactic-cni matches by image name. fabric-config-agent has no image of its own: it ships in the fabric-router image, runs as the config-agent container's command and from frr-init's shell script, so a name in the list alone would never match it. The checker now also treats a container as Galactic when a word of its command is a listed binary, which covers both containers and leaves the frr container alone.
0cc1ca6 to
035084c
Compare
|
@ecv thanks, addressed in 035084c after rebasing onto main.
|
ecv
left a comment
There was a problem hiding this comment.
Approve.
The hold is resolved. The branch is rebased onto main after #1168, and Binaries now lists fabric-config-agent and galactic-cni, so TestBinariesListsEveryCaller matches on the merge and the manifest check covers both binaries' LOG_LEVEL, LOG_FORMAT and flags.
hack/check-log-settingsand its test change with the list, so the check knows both images.- The rest of the PR is as reviewed before: logs go to stderr, and the replaced
log.Fatalfstill prints its error and exits 1.
galactic-cniandfabric-config-agentlog JSON at info by default, like the binaries #1155 moved. Both take--log-leveland--log-format, orLOG_LEVELandLOG_FORMAT, to change that.The manifest log-settings check from #1168 now covers both.
fabric-config-agentruns from thefabric-routerimage, so the check also matches a container by the binary its command runs.A bad flag still prints Go's default text, because it fails before the logger exists.
Fixes #1165
Test plan
--log-format textgives texttask test:manifestsand Kind e2e passLOG_LEVEL=debugadds debug lines