Skip to content

Write warnings to stderr in quiet mode - #2734

Open
yuminn-k wants to merge 5 commits into
buildpacks:mainfrom
yuminn-k:quiet-warnings-to-stderr
Open

yuminn-k wants to merge 5 commits into
buildpacks:mainfrom
yuminn-k:quiet-warnings-to-stderr

Conversation

@yuminn-k

@yuminn-k yuminn-k commented Nov 3, 2026

Copy link
Copy Markdown

Summary

In quiet mode the log level is Warn, and LogWithWriters.WriterForLevel sent warnings to stdout. On a daemon using the containerd image store, pack build -q <image> therefore printed the containerd-storage warning (#2272) before the image reference, so ref=$(pack build -q ...) captured three lines instead of one.

This change makes WriterForLevel return the error writer for warnings when quiet is set, so stdout carries only the command result. Non-quiet output is unchanged (warnings still go to stdout).

Tests:

  • pkg/logging: the quiet-mode test now asserts warnings go to the error writer and nothing goes to the standard writer.
  • pkg/client: the build tests use separate stdout/stderr buffers, and the Quiet mode / local test is back to the exact-match assertion that test: only assert the last line of quiet-mode local build output #2730 relaxed. Against a containerd-store daemon, that test fails without the logger change (the warning appears before some/app@sha256:...) and passes with it.

Note: this applies to every warning in quiet mode, not only the containerd one, which matches the option suggested in the issue.

Output

Illustrative (not captured from a real pack run; the behavior is what the pkg/client quiet-mode test checks):

Before

$ ref=$(pack build -q some/app); echo "$ref"
Warning: Exporting to docker daemon (building without --publish) and daemon uses containerd storage; performance may be significantly degraded.
For more information, see https://github.com/buildpacks/pack/issues/2272.
some/app@sha256:...

After

$ ref=$(pack build -q some/app); echo "$ref"
some/app@sha256:...

The warning is still printed, but on stderr, so $ref contains only some/app@sha256:....

Documentation

  • Should this change be documented?
    • Yes, see #___
    • No

Related

Resolves #2733

🤖 Generated with Claude Code

In quiet mode stdout should only carry the command result (for
`pack build -q`, the image reference), but warnings were still written
to stdout. On a daemon using the containerd image store, the
containerd-storage warning ended up in front of the image reference, so
`ref=$(pack build -q ...)` captured three lines instead of one.

Send warnings to the error writer when quiet is set, and restore the
exact-match assertion in the quiet-mode local build test that was
relaxed in buildpacks#2730.

Signed-off-by: YuMin Kim <yuminkim.dev@gmail.com>
@yuminn-k
yuminn-k requested review from a team as code owners November 3, 2026 07:00
@github-actions github-actions Bot added the type/enhancement Issue that requests a new feature or improvement. label Nov 3, 2026
@github-actions github-actions Bot added this to the 0.41.0 milestone Nov 3, 2026

@ToniAdreal ToniAdreal left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified locally against the reported issue (#2733).

The fix is the first of the two options the issue proposes, and it is the right one: in quiet mode stdout is reserved for command output, so warnings belong on stderr rather than being suppressed. WriterForLevel now routes WarnLevel to errOut when the logger level is quietLevel; the non-quiet path is untouched (warnings still go to stdout by default).

What I checked, locally:

  • RED: base cddf381 + only the PR's two test files applied — go test ./pkg/logging/ -run TestLogWithWriters gives 18 passed / 1 failed. The single failure is the new quiet is set to true / logs warnings to error writer assertion: stdout held "Warning: warn_\nWarning: warnf\n" instead of being empty. That is exactly the reported bug.
  • GREEN: PR head dd36b6b — full go test ./pkg/logging/ passes, including the renamed quiet-mode warnings test and the default-context test that still asserts warnings go to the standard writer when not quiet.
  • GREEN (verified 04:12–04:16): go test ./pkg/client/ -run TestBuild on PR head dd36b6b — 137 passed / 0 failed / 15 skipped (152 total, 180.7s). Both quiet-mode specs pass, including Quiet_mode/local/only_prints_app_name_and_sha (the restored exact-match assertion on stdout). First attempt failed only because /tmp was 100% full (test writes buildpack tars via os.MkdirTemp); rerun with TMPDIR on the home disk passed. Log: hidden_files/pack-2734/test-client-11090410.log.
  • Sibling check: the only non-test caller of WriterForLevel outside pkg/logging is pkg/image/fetcher.go:322, and it requests InfoLevel, so this change cannot affect it. ErrorLevel already went to stderr; Debug/Info are still discarded in quiet mode.
  • CI on the head is all green (test linux/macos/windows, acceptance-combo, CodeQL, DCO).

Two non-blocking notes: the PR has no description text (the linked issue carries the context, so nothing is lost), and mergeable_state is behind — the base has moved since 2026-11-03, so a rebase will be needed before merge.

@jjbustamante jjbustamante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you @yuminn-k

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement Issue that requests a new feature or improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pack build --quiet prints the containerd-storage warning on stdout

3 participants