Skip to content

Skip lifecycle vendor keychains when pack supplies every credential - #2732

Open
herder wants to merge 1 commit into
buildpacks:mainfrom
herder:skip-vendor-keychains
Open

herder wants to merge 1 commit into
buildpacks:mainfrom
herder:skip-vendor-keychains

Conversation

@herder

@herder herder commented Oct 29, 2026

Copy link
Copy Markdown

Summary

When the credentials pack puts in CNB_REGISTRY_AUTH cover the registry of every image a phase uses, pack now also sets CNB_REGISTRY_AUTH_KEYCHAIN_SKIP_AMAZON=true and CNB_REGISTRY_AUTH_KEYCHAIN_SKIP_AZURE=true (added in buildpacks/lifecycle#1315). In that case the lifecycle's vendor keychains can only look up the same credentials again. They do it eagerly for every image, and from inside the phase container the ECR and ACR helpers wait on instance metadata before giving up. That costs about 15s per analyzer and exporter run when the images are on ECR, or minutes on ACR (buildpacks/lifecycle#1007).

If pack has no credentials for any one of the registries, the vendor keychains stay on. Builds that depend on them, such as an instance role with no docker login, behave as before.

WithRegistryAccess now takes the images and decides; the four call sites pass the images they already resolve credentials for. The verbose-log redaction now matches CNB_REGISTRY_AUTH= exactly, so the skip variables appear in the output. Before, each one showed up as an extra CNB_REGISTRY_AUTH=<redacted>.

Output

pack build --publish --verbose, untrusted builder (5 phases), run image on ECR via a registry mirror, app and cache images in a password-protected registry; same build both times with the stock lifecycle 0.21.26.

Before

14:00:23.901945 [analyzer] Ensuring privileges...
14:00:38.317692 [analyzer] Executing command...
14:00:50.906668 [exporter] Ensuring privileges...
14:01:06.178098 [exporter] Executing command...

After

14:04:27.589915 [analyzer] Ensuring privileges...
14:04:27.590030 [analyzer] Executing command...
14:04:39.966984 [exporter] Ensuring privileges...
14:04:39.967209 [exporter] Executing command...

Earlier, with a lifecycle image that had the variable baked in, an otherwise identical warm build went from 71s to 39s.

Documentation

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

Related

Resolves #2731

Tested: go test ./internal/... passes, with new tests for the covered, partly-covered and no-credentials cases and for the log output. In pkg/client, one quiet-mode test fails locally because my Docker daemon uses containerd image storage and pack prints its warning; that's unrelated to this change. golangci-lint v2.0.2 reports the same typecheck errors on main here, so I'm relying on CI for lint, and for the acceptance tests, which I didn't run.

@herder
herder requested review from a team as code owners October 29, 2026 13:19
@github-actions github-actions Bot added this to the 0.41.0 milestone Oct 29, 2026
@github-actions github-actions Bot added the type/enhancement Issue that requests a new feature or improvement. label Oct 29, 2026
@herder

herder commented Nov 2, 2026

Copy link
Copy Markdown
Author

Depends on #2730

@herder
herder force-pushed the skip-vendor-keychains branch from 7a5ef51 to 1b219d8 Compare November 2, 2026 19:35
When the credentials pack resolves for CNB_REGISTRY_AUTH cover the
registry of every image a phase uses, also set
CNB_REGISTRY_AUTH_KEYCHAIN_SKIP_AMAZON and _AZURE. The lifecycle's
vendor keychains could only look up the same credentials again, and the
ECR and ACR helpers do so slowly, via instance metadata: about 15s per
analyzer and exporter run when the images are on ECR.

If any registry is not covered, the vendor keychains stay on, so builds
that rely on them (e.g. an instance role without docker login) keep
working.

The log redaction now matches CNB_REGISTRY_AUTH= exactly, so the skip
variables show up in verbose output instead of as a second redacted
CNB_REGISTRY_AUTH.

Resolves buildpacks#2731

Signed-off-by: Niklas Herder <niklas.herder@gmail.com>
@herder
herder force-pushed the skip-vendor-keychains branch from 1b219d8 to f686b92 Compare November 16, 2026 14:49

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.

Set CNB_REGISTRY_AUTH_KEYCHAIN_SKIP_AMAZON/AZURE when pack provides CNB_REGISTRY_AUTH

1 participant