Skip to content

fix(dir): recognize registry not-found and unsupported errors by type - #2252

Merged
lgecse merged 4 commits into
mainfrom
fix/oci-ready-404-match
Oct 1, 2026
Merged

lgecse merged 4 commits into
mainfrom
fix/oci-ready-404-match

Conversation

@muscariello

@muscariello muscariello commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #2251.

Why

The OCI store and the reconciler's indexer read a registry's answer from the error text. That text carries the registry's address, so a registry at an address containing 404 or 405 was misread on every failure. Example addresses: port 4040 or 40445, or a host like registry404.example.com.

  • Readiness: IsReady reported a registry ready while it answered 5xx or rejected credentials.
  • Deletes: deleting a record or a referrer from a registry that refused it was reported as "already deleted", while it was still there.
  • Unsupported deletes: at an address containing 405, a refused delete was reported as the registry not supporting deletes.
  • Indexer: a refusal mentioning "not found" from such a registry was read as an empty repository.

The readiness case also made TestIsReady_RemoteRegistry/registry_unavailable flaky. Its test server gets a random port, and about 1 in 100 Linux runs picks one containing 404; it failed on #2249. The other cases were found in review.

Fix

Two helpers in server/store/oci now decide from oras-go's typed errors, never the text:

  • IsNotFound: errdef.ErrNotFound (a missing manifest, blob or tag target), or an error response with status 404 (a missing repository).
  • isDeleteUnsupported: errdef.ErrUnsupported, a 405 response, or an UNSUPPORTED error code.

They're used by IsReady, both delete paths, the tag retry and the reconciler's indexer. Nothing in the store matches error text any more.

Testing

  • Typed errors: both helpers are tested on oras-go's error values. That includes a 500 response from an address containing 404 or 405, and text that merely says "404" or "unsupported", none of which count.
  • Real registries: test registries on local ports containing 404 and 405, driven through oras-go:
    • readiness: 500 and 401 are not ready; 200 and 404 are;
    • tag listing: a missing repository is recognized and a refusal is not;
    • record and referrer deletes: deleted, already gone, not allowed (405), and refused at either kind of address.
  • Checked against main's code: these tests fail there exactly where the bugs are. Refused deletes are reported deleted or unsupported, and failing registries are reported ready.
  • Existing tests: server/store/... and the reconciler module pass, and both vet clean.

IsReady treated a failed ping as "registry reachable" whenever the error
text contained "404". The text carries the registry's address, so a
registry at an address containing 404 (port 4040 or 40445, a host like
registry404.example.com) was reported ready while answering 5xx or
rejecting credentials. It also made TestIsReady_RemoteRegistry flaky:
its test server's random port contains 404 about once in a hundred
Linux runs.

oras-go's Registry.Ping already reports a 404 as errdef.ErrNotFound, so
that alone now counts. A test serving the registry on a port containing
404 checks that 500 and 401 are not ready, and 200 and 404 are.

Fixes #2251

Signed-off-by: Luca Muscariello <[email protected]>
@muscariello
muscariello requested a review from a team as a code owner October 1, 2026 07:08
@muscariello muscariello added area/dir/server kind/bug Categorizes issue or PR as related to a bug. labels Oct 1, 2026
@github-actions github-actions Bot added the size/S Denotes a PR that changes 50-199 lines label Oct 1, 2026

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

The same pattern is still live in reconciler/tasks/indexer/task.go:304 and server/store/oci/internal.go:193,260. Maybe it would worth to unify them.

Comment thread server/store/oci/oci.go Resolved
Review of the IsReady fix found the same flaw at every other place that
read a registry's answer from the error text. The text carries the
registry's address, so a registry at an address containing 404 or 405
was misread on every failure:

- deleting a record or a referrer from a registry that refused reported
  it deleted, while it was still there;
- a refused delete at an address containing 405 was reported as the
  registry not supporting deletes;
- the indexer read any refusal mentioning "not found" from such a
  registry as an empty repository.

IsNotFound and isDeleteUnsupported now decide from oras-go's typed
errors: errdef.ErrNotFound or a 404 error response, and
errdef.ErrUnsupported, a 405 response or an UNSUPPORTED error code. The
indexer and the tag retry use IsNotFound too, so nothing in the store
matches error text any more. Tests drive real oras-go errors from
registries on ports containing 404 and 405; against the old code, the
refused deletes there are reported deleted or unsupported.

Refs #2251

Signed-off-by: Luca Muscariello <[email protected]>
@github-actions github-actions Bot added size/M Denotes a PR that changes 200-999 lines and removed size/S Denotes a PR that changes 50-199 lines labels Oct 1, 2026
The test ran in parallel but its subtests did not (tparallel). Each subtest serves its own registry on a free port, so they run in parallel too.

Refs #2251

Signed-off-by: Luca Muscariello <[email protected]>

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

LGTM. Thanks!

@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@lgecse
lgecse added this pull request to the merge queue Oct 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 1, 2026
@lgecse
lgecse added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit 489afb6 Oct 1, 2026
34 checks passed
@lgecse
lgecse deleted the fix/oci-ready-404-match branch October 1, 2026 09:17
@muscariello muscariello changed the title fix(dir): count only a real 404 as a reachable registry in IsReady fix(dir): recognize registry not-found and unsupported errors by type Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dir/server kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: store readiness reports ready for a failing registry whose address contains "404"

4 participants