knative: domain: Require cluster match for claim lookup - #1012
Elvand-Lie wants to merge 1 commit into
Conversation
illume
left a comment
There was a problem hiding this comment.
Thanks for this PR.
A few of the commits don't quite follow the project guidelines. We use Linux kernel style for git commits — have a look at the contributing guide and previous commits with git log.
Commits that need attention
knative: require cluster match for DomainMapping claims— Description must start with a capital letter — e.g.frontend: HomeButton: Fix the buttonnotfrontend: HomeButton: fix the button.
Commit guidelines
- Use atomic commits focused on a single change.
- Use the title format
<area>: <Description of changes>— description must start with a capital letter. - Keep the title under 72 characters (soft requirement).
- Explain the intention and why the change is needed.
- Make commit titles meaningful and describe what changed.
- Do not add code that a later commit rewrites; squash or reorder commits instead.
- Do not include
Fixes #NNin commit messages.
Good examples:
frontend: HomeButton: Fix so it navigates to homebackend: config: Add enable-dynamic-clusters flag
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation correctly addresses the cross-cluster lookup bug and includes comprehensive regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Ensures DomainMappings only match ClusterDomainClaims from the same cluster.
Changes:
- Enforces cluster, hostname, and namespace matching without mutating claims.
- Adds focused regression and edge-case tests.
| File | Description |
|---|---|
knative/src/utils/domain.ts |
Enforces strict cluster-aware claim lookup. |
knative/src/utils/domain.test.ts |
Tests cross-cluster matching and fallback behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Looking up the ClusterDomainClaim for a DomainMapping accepted a claim from any cluster when only one cluster was being viewed. The cluster comparison was skipped whenever the caller passed a single-element cluster list, so a same-host, same-namespace claim belonging to a different cluster could be reported as the DomainMapping's claim and its state shown as present. The lookup also wrote the resolved cluster back onto the claim object it had been handed, mutating data owned by the caller and the query cache. Match on the effective cluster unconditionally, and return the claim without decorating it. The caller cluster is still used when the DomainMapping carries no cluster of its own. Adds regressions for a claim from another cluster, a clusterless claim, a DomainMapping without a cluster, and the unloaded and blank-host cases. Signed-off-by: Elvand Lie Nababan <elvandlie@gmail.com>
ac146b6 to
3dd4e1d
Compare
3dd4e1d to
6e529ea
Compare
|
@illume Rebased and revised to address the review feedback and commit-history requirements. The branch is now a single atomic commit and has been re-verified. Ready for another look. |
Summary
Require a
ClusterDomainClaimto belong to the same cluster as theDomainMappingbefore treating it as the corresponding claim.Problem
The DomainMapping list can display resources from multiple selected clusters.
It also loads ClusterDomainClaims across those clusters.
getClusterDomainClaim()previously decided whether cluster matching wasneeded from a locally created one-element array:
Because that condition was always false, the lookup matched only the hostname
and target namespace.
If cluster A contained a claim for
shop.example.comtargeting namespacestore, an identically named DomainMapping in cluster B could incorrectlydisplay that claim as present. The action for creating the actually missing
claim in cluster B could consequently be hidden.
Fix
Match claims using all three relationship dimensions:
The helper remains compatible with callers where the DomainMapping does not
carry a cluster directly by using the caller-provided cluster as its effective
cluster.
The lookup no longer mutates the returned claim.
Testing
Added focused tests covering:
The cross-cluster regression test fails against the previous implementation
and passes with this change.
Verification
npm run tscnpm run lintnpm run formatnpm run testnpm run buildgit diff --checkAll checks passed.