Skip to content

json-proxy: Add GetEngineConfig to advertise retry policy - #951

Open
cgwalters wants to merge 1 commit into
podman-container-tools:mainfrom
cgwalters:proxy-engine-config
Open

cgwalters wants to merge 1 commit into
podman-container-tools:mainfrom
cgwalters:proxy-engine-config

Conversation

@cgwalters

Copy link
Copy Markdown
Contributor

Basically podman as of recently retries by default, but we can't easily replicate that behavior in the proxy - the "client" needs to handle retries.

Expose the engine configuration (with retries) as an API so that projects like containers-image-proxy-rs can honor it.

Assisted-by: https://github.com/cgwalters/#llms

Basically podman as of recently retries by default, but we can't
easily replicate that behavior in the proxy - the "client" needs
to handle retries.

Expose the engine configuration (with retries) as an API so
that projects like containers-image-proxy-rs can honor it.

Assisted-by: https://github.com/cgwalters/#llms
Signed-off-by: Colin Walters <[email protected]>
@github-actions github-actions Bot added the common Related to "common" package label Jun 30, 2026

@mtrmac mtrmac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Expose the engine configuration (with retries) as an API

Hum, that doesn’t work exactly the same either, because c/common/libimage/copier has another level of defaults, setting a default for RetryDelay. I’m not sure how all these pieces are ideally expected to fit together in Podman / Buildah.

(@Luap99 PTAL at least at the config / defaults reading.)

Comment on lines +149 to +150
// A negative delay is meaningless; treat it as unset (exponential
// backoff) rather than advertising a nonsensical value to clients.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • AFAICS the actual behavior of c/common/pkg/retry is to treat this as “no delay” (= wait for $delay immediately complete), not as exponential backoff
  • I’m aesthetically worried about silently replacing invalid data with some other data. It will not be trivial to find out how the value is “lost” if anyone had to dig into it.

@Luap99 Luap99 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.

I am missing the larger picture here, why does the proxy need to care about containers.conf at all? Just use whatever retries you want?

So far containers.conf is used by Podman and Buildah and nothing more.

Comment on lines +132 to +133
// config.Default() memoizes internally, so this is cheap to call here.
cfg, err := config.Default()

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.

I know where little about that proxy but since it is used by skopeo never depended on containers.conf in any way.

This adds a large dependency chain thus to skopeo and makes it care about something it never did before, I do not maintain skopeo so I do not have a strong opinion but it is a design choice that likely should be looked at carefully.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oops, yes. That’s pretty likely to be a big issue.

@cgwalters

Copy link
Copy Markdown
Contributor Author

I am missing the larger picture here, why does the proxy need to care about containers.conf at all? Just use whatever retries you want?

The status quo is documented and I understand the rationale behind it, but from the user PoV at a high level it is kind of confusing (I hope you'd agree) for bootc to read policy.json and registries.conf but not containers.conf where the retries are.

Hmm....we could add retries into containers-registries.conf?


# New global values
retries = 10
retry-delay = "2s"

# Per-registry content
[[registry]]
prefix = "example.com/foo"
location = "internal-registry-for-example.com/bar"

@Luap99

Luap99 commented Jun 30, 2026

Copy link
Copy Markdown
Member

The status quo is documented and I understand the rationale behind it, but from the user PoV at a high level it is kind of confusing (I hope you'd agree) for bootc to read policy.json and registries.conf but not containers.conf where the retries are.

skopeo does not read this either but does expose retry cli options. containers.conf is documented only to work with podman and buildah so I am not sure why a user would think bootc needs to use it?
Why would they care that it uses the same default retry value as podman?

Practically sharing the config files has both benefits and downsides. It sounds good to have all tools use just one file but then it also means you cannot configure different defaults for different tools.

Hmm....we could add retries into containers-registries.conf?

I think the possible concern there would be that retries are driven by external callers outside of the image module so we would add an option that is not used there at all.

@mtrmac

mtrmac commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • Retries generally should exist only at “top levels” (unless there is a structural advantage to immediate retries, such as HTTP range requests allowing resuming without re-downloads); otherwise it’s pretty easy to end up with an exponential amount of retries over N layers each retrying.
  • “How many times to retry” is not really a property of a registry but a cost/benefit balance to be decided by the calling application: Consider latency-sensitive accesses to check for presence of cache images vs. reliability-sensitive accesses to download a primary software package.

@cgwalters

Copy link
Copy Markdown
Contributor Author

Why would they care that it uses the same default retry value as podman?

Because I want to inject a config into our CI that forces on more and longer retries for registry operations, and I want that to affect both podman and bootc.

but then it also means you cannot configure different defaults for different tools.

(One can do so by e.g. injecting BindReadOnlyPaths in a systemd unit, and ideally we honor env vars for all of them consistently)

For a situation in which I'd want them to be different, I think we could also offer CLI flags.

Retries generally should exist only at “top levels” (unless there is a structural advantage to immediate retries, such as HTTP range requests allowing resuming without re-downloads); otherwise it’s pretty easy to end up with an exponential amount of retries over N layers each retrying.

Agree.

“How many times to retry” is not really a property of a registry but a cost/benefit balance to be decided by the calling application: Consider latency-sensitive accesses to check for presence of cache images vs. reliability-sensitive accesses to download a primary software package.

At least in the use case in which I want to bump retries, I can't think of a case where I'd want "okay the registry for caching hasn't been responding for 30 seconds, I'm going to rebuild from source instead".

@mtrmac

mtrmac commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

“How many times to retry” is not really a property of a registry but a cost/benefit balance to be decided by the calling application: Consider latency-sensitive accesses to check for presence of cache images vs. reliability-sensitive accesses to download a primary software package.

Or consider a CI job: When run nightly, users never want registry flakes, so giving it many retries 10 minutes apart is fine. When run against developers work (which they can’t test locally), it’s important for the developer to be told “the registry is unreliable now and you are not going to get this done”.

At least in the use case … I can't think of

My point really is about the proper location of the configuration — at the use case top level, not as a system-wide config file. I’m sure there are deployments where the two collapse into the same thing, but that does not erase the distinction nor the argument against putting the option in global config files. [Yes, we have it in containers.conf now.]

cgwalters-bot added a commit to cgwalters-bot/composefs-rs that referenced this pull request Sep 23, 2026
Pulls through skopeo have no retries at all, so a single 503 or dropped
connection from e.g. quay.io fails the whole pull; this is a regular
source of CI flakes for bootc. The proxy doesn't retry for us: in
podman the retry loop lives in the caller (c/common pkg/retry), and
podman-container-tools/container-libs#951
would only advertise podman's configured retry policy to proxy
clients, which would still need to implement the retrying. So do it
here.

Retries happen per proxy operation (opening the image, fetching the
manifest, the config, and each layer or delta blob), so a failure in
one layer doesn't refetch the others, and there is a single level of
retrying as suggested in the review of that PR. Backoff is exponential
with jitter, defaulting to podman's 3 retries starting at 1s;
PullOptions::retry tunes or disables it. Only registry (docker://)
pulls retry; for local transports such as containers-storage: a failure
would just repeat. Note pull_image() now retries with the default
policy too.

We keep using GetBlob, since it verifies the digest for us, rather than
GetRawBlob, which would classify errors as retryable itself. So apart
from that code, errors are classified by matching the Go error text
from the proxy, modelled on c/common's IsErrorRetryable(), plus the
proxy's "expected N bytes"/"corrupted blob" verdicts for truncated
transfers. Only errors from the proxy are considered; a local failure
to import verified data is never retried.

A layer is still only registered once the proxy has verified the whole
blob, and each attempt starts a fresh request. We now also wait for
the proxy's verdict when the import itself failed, since a broken
transfer is then usually the root cause and decides whether to retry;
its error comes first in the combined message.

Retries are reported as progress messages, which is how cfsctl shows
them, and only logged at debug level so they don't appear twice.

Assisted-by: AI
Closes: composefs#348
cgwalters-bot added a commit to cgwalters-forge/composefs-rs that referenced this pull request Sep 24, 2026
Pulls through skopeo have no retries at all, so a single 503 or dropped
connection from e.g. quay.io fails the whole pull; this is a regular
source of CI flakes for bootc. The proxy doesn't retry for us: in
podman the retry loop lives in the caller (c/common pkg/retry), and
podman-container-tools/container-libs#951
would only advertise podman's configured retry policy to proxy
clients, which would still need to implement the retrying. So do it
here.

Retries happen per proxy operation (opening the image, fetching the
manifest, the config, and each layer or delta blob), so a failure in
one layer doesn't refetch the others, and there is a single level of
retrying as suggested in the review of that PR. Backoff is exponential
with jitter, defaulting to podman's 3 retries starting at 1s;
PullOptions::retry tunes or disables it. Only registry (docker://)
pulls retry; for local transports such as containers-storage: a failure
would just repeat. Note pull_image() now retries with the default
policy too.

We keep using GetBlob, since it verifies the digest for us, rather than
GetRawBlob, which would classify errors as retryable itself. So apart
from that code, errors are classified by matching the Go error text
from the proxy, modelled on c/common's IsErrorRetryable(), plus the
proxy's "expected N bytes"/"corrupted blob" verdicts for truncated
transfers. Only errors from the proxy are considered; a local failure
to import verified data is never retried.

A layer is still only registered once the proxy has verified the whole
blob, and each attempt starts a fresh request. We now also wait for
the proxy's verdict when the import itself failed, since a broken
transfer is then usually the root cause and decides whether to retry;
its error comes first in the combined message. Since each attempt
restarts the transfer, a layer's Started event is sent again per
attempt, and cfsctl replaces that layer's progress bar.

Retries are reported as progress messages, which is how cfsctl shows
them, and only logged at debug level so they don't appear twice.

Generated-by: AI
Closes: composefs#348
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants