Skip to content

fix(webhook): allow MutatedImage host to diverge from spec.host#246

Merged
golgoth31 merged 1 commit intomainfrom
fix/imageregistry-webhook-mutated-host-divergence
May 7, 2026
Merged

fix(webhook): allow MutatedImage host to diverge from spec.host#246
golgoth31 merged 1 commit intomainfrom
fix/imageregistry-webhook-mutated-host-divergence

Conversation

@golgoth31
Copy link
Copy Markdown
Owner

Summary

  • The ImageRegistry validating webhook rejected CRs whose MutatedImage host differed from spec.host, which blocked imageinventory reconciliation any time an admission controller (e.g. Artifact Registry pull-through cache) rewrote docker.io/... to europe-docker.pkg.dev/....
  • spec.host is the registry the controller queries for tags (resolve_latest_versions.go). Tightened the invariant to enforce this only on the lookup target:
    • changeType=none → Original and Mutated must both match (equal by definition).
    • changeType=mutated → only OriginalImage (lookup target) must match; MutatedImage may live in a cache/mirror.
    • changeType=injected → only MutatedImage must match (lookup target since OriginalImage is empty).

Observed error before fix

err: upsert ImageRegistry 187ac26a1548: admission webhook "vimageregistry-v1alpha1.kb.io" denied the request:
spec.images[0].mutatedImage: image registry "europe-docker.pkg.dev" does not match spec.host "index.docker.io"

Test plan

  • make helm regenerates manifests cleanly
  • make lint — 0 issues
  • make test — all packages pass; webhook coverage 81.1%
  • New test HostCoherence_MutatedDivergesAllowed covers the regression
  • New test HostCoherence_InjectedMutatedMismatch ensures injected still validates the lookup target
  • Existing HostCoherence_OriginalMismatch keeps rejecting bad lookup targets
  • Deploy and verify imageinventory reconciles successfully on a cluster with Artifact Registry pull-through cache

🤖 Generated with Claude Code

…hangeType=mutated

The ImageRegistry webhook required both OriginalImage and MutatedImage to
match spec.host. This blocked the imageinventory controller whenever an
admission controller (e.g. Artifact Registry pull-through cache) rewrote
docker.io references to europe-docker.pkg.dev: the aggregator groups by
the lookup-target host (OriginalImage), but the rewritten MutatedImage
points elsewhere by design.

spec.host is the registry the controller queries for tags (see
resolve_latest_versions.go). Tighten the invariant to match that intent:

- changeType=none: both images must match (they are equal).
- changeType=mutated: only OriginalImage (the lookup target) must match;
  MutatedImage may live in a cache/mirror.
- changeType=injected: only MutatedImage must match (lookup target by
  default since OriginalImage is empty).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@golgoth31 golgoth31 merged commit a3acfab into main May 7, 2026
2 checks passed
@golgoth31 golgoth31 deleted the fix/imageregistry-webhook-mutated-host-divergence branch May 7, 2026 22:03
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.

1 participant