Skip to content

fix: improve logs when Ubuntu Pro credentials are not available - #326

Open
cristiangirlea wants to merge 1 commit into
canonical:mainfrom
cristiangirlea:fix/pro-credentials-logs
Open

cristiangirlea wants to merge 1 commit into
canonical:mainfrom
cristiangirlea:fix/pro-credentials-logs

Conversation

@cristiangirlea

Copy link
Copy Markdown
  • Have you signed the CLA?

Fixes #207

When a release defines Ubuntu Pro archives (as ubuntu-24.04 does) and no
credentials are available, chisel cut logged an error-like message for
every Pro archive followed by a per-archive "ignored" line. Users not
using Pro archives at all found this confusing, and nothing tied the
messages to Ubuntu Pro.

As discussed in #207, Chisel now emits a single informative message when
Pro credentials are not available and stays quiet about it otherwise.
When valid credentials are present the logs are unchanged.

Changes

  • internal/archive: a missing credentials directory is treated as the
    normal "no Pro credentials" case and is no longer logged. Any other error
    opening the directory (for example a permission problem) is still logged.
    The doc comment of findCredentialsInDir was also corrected: it claimed
    the function returns empty credentials with a nil error, but it returns
    ErrCredentialsNotFound.
  • cmd/chisel: cut and debug check-release-archives collect the archives
    ignored because of missing credentials and report them once, sorted, via a
    small shared helper.
  • Tests: TestFindCredentialsInDirMissingDir asserts nothing is logged for a
    missing directory, and a new TestRunIgnoresProArchivesWithoutCredentials
    covers the single-message behaviour through debug check-release-archives
    (which has the archiveOpen hook; cut shares the same logic).

Verification

go test ./... passes and go vet ./... reports nothing new (its only
output is pre-existing unkeyed-field warnings in internal/setup tests).
Both new tests fail on main and pass with this change.

Before / after with a real release, no credentials directory:

CHISEL_AUTH_DIR=/nonexistent chisel cut --release ubuntu-24.04 --root /tmp/rootfs base-files_base

Before:

Cannot open credentials directory "/nonexistent": open /nonexistent: no such file or directory
Archive "ubuntu-esm-infra" ignored: credentials not found
Cannot open credentials directory "/nonexistent": open /nonexistent: no such file or directory
Archive "ubuntu-esm-apps" ignored: credentials not found

After:

Ubuntu Pro subscription not available, ignoring archives: ubuntu-esm-apps, ubuntu-esm-infra

The wording follows the suggestion in #207; happy to adjust it.

Assisted-by: AI tools

When a release defines Ubuntu Pro archives and no credentials are
available, Chisel logged an error-like message for every Pro archive
("Cannot open credentials directory ...") followed by one "Archive
... ignored: credentials not found" line per archive. Users not using
Pro archives at all found this confusing.

A missing credentials directory is now handled silently (other errors
opening it are still logged), and the archives ignored because of
missing credentials are reported in a single informative message:

    Ubuntu Pro subscription not available, ignoring archives: ubuntu-esm-apps, ubuntu-esm-infra

When valid credentials are available the logs are unchanged.

Fixes canonical#207

Assisted-by: AI tools
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.

Logs for Cannot open credentials directory "/etc/apt/auth.conf.d" when not using Pro archives

1 participant