Repository navigation
Enqueue only a resolver's own ResolutionRequests - #10548
Conversation
|
/kind bug |
|
|
|
@somaz94 thank you for opening this PR to make this feature furthermore performant using the selector, looking forward to this once ready for review |
|
Marked this ready for review, thanks @waveywaves. One thing that needs a maintainer click: the For reference, on the draft run everything substantive passed, including the full e2e suite, |
|
@somaz94 you will have to rebase this PR looks like. Please do so. |
On leader promotion the resolver framework listed ResolutionRequests with labels.Everything() and enqueued every one of them into every resolver's workqueue. The reconciler has no label guard of its own, so whichever resolver dequeued a request first ran Validate() and Resolve() on it regardless of its resolution.tekton.dev/type label. A request addressed to the http resolver could therefore be failed by the hub resolver with "missing required hub resolver params", and since the request is then already done the http resolver skips it. The informer's event handler was already filtered by FilterResolutionRequestsBySelector; only the promote path was not. Pass the resolver's selector into LeaderAwareFuncs and list with labels.SelectorFromSet, which applies the same AND-of-equality match the event handler uses. Both frameworks now read the selector once and share it between the two paths so they cannot drift. This answers the TODO that has sat on LeaderAwareFuncs since it was introduced. Fixes #10484
6ae12cb to
fc51fdc
Compare
|
@waveywaves rebased on latest Re-ran both resolver framework suites locally after the rebase: Ready for |
waveywaves
left a comment
There was a problem hiding this comment.
The promotion filtering and regression test look good. I am requesting changes for source compatibility and fail-closed selector handling. The resolver test suites, race tests, and go vet passed locally after rebasing onto current main.
| // selector must be non-empty: labels.SelectorFromSet treats an empty set as | ||
| // labels.Everything(). Callers get this from ValidateResolver, which rejects a | ||
| // selector without a resolution.tekton.dev/type label. | ||
| func LeaderAwareFuncs(lister rrlister.ResolutionRequestLister, selector map[string]string) reconciler.LeaderAwareFuncs { |
There was a problem hiding this comment.
LeaderAwareFuncs is exported, so changing its arguments breaks external callers. Please keep the existing function and add LeaderAwareFuncsWithSelector for internal use.
There was a problem hiding this comment.
Done in 42e5b5a. LeaderAwareFuncs is back to the original one-argument signature and still lists with labels.Everything(), so callers outside the repo keep compiling and behave exactly as before. The filtered listing moved to a new LeaderAwareFuncsWithSelector. I also added a test that pins the old function to enqueueing everything, so it cannot get quietly narrowed later.
| // The promote path and the informer's event handler below must filter | ||
| // ResolutionRequests with the same selector, or a resolver reconciles | ||
| // requests that are not addressed to it. | ||
| selector := resolver.GetSelector(ctx) |
There was a problem hiding this comment.
This selector is fetched again after validation. If it is empty, SelectorFromSet matches every request. Please validate this exact value in both controllers.
There was a problem hiding this comment.
Good catch — that second GetSelector really was unchecked. Both controllers now call ValidateResolver on the exact value they hand to the promote path and the event handler, inside the closure. The existing call at NewController entry runs with a different context and before Initialize, so it cannot stand in for it.
| return reconciler.LeaderAwareFuncs{ | ||
| PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { | ||
| all, err := lister.List(labels.Everything()) | ||
| all, err := lister.List(labels.SelectorFromSet(selector)) |
There was a problem hiding this comment.
SelectorFromSet(nil) matches everything. Please fail closed when the resolver type selector is missing and add a nil/empty test case.
There was a problem hiding this comment.
Done in 42e5b5a. promotionSelector maps an empty set to labels.Nothing() rather than letting SelectorFromSet widen it to Everything(). Added nil and empty selector cases to the table test — I checked both fail if I take the guard back out.
Addresses review feedback on the promote-path selector. Restore the exported LeaderAwareFuncs to its original one-argument signature and its original labels.Everything() behaviour, and add LeaderAwareFuncsWithSelector for the filtered listing. Changing the arguments of an exported function breaks callers outside this repository without them touching a line of their own code, so the old entry point stays and is marked deprecated instead. A test pins its behaviour. Fail closed when the selector is empty. labels.SelectorFromSet maps the empty set to labels.Everything(), so a resolver reaching promotion without a selector would re-enqueue every ResolutionRequest in the cluster -- the exact bug the filtering exists to fix. promotionSelector maps the empty set to labels.Nothing(), and nil and empty selector cases cover it. Validate the exact selector both paths use, in both controllers. The ValidateResolver call at NewController entry runs with a different context and before Initialize, then GetSelector is called a second time inside the closure and that value was never checked. Re-validate it where it is used rather than assume the two calls agree.
|
@waveywaves all three points are addressed in Short version: One thing that needs a click from your side: the push queued 7 workflow runs and all of them came back Locally on the rebased branch: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10548 +/- ##
===========================================
+ Coverage 51.19% 87.36% +36.16%
===========================================
Files 334 291 -43
Lines 40495 25101 -15394
===========================================
+ Hits 20733 21929 +1196
+ Misses 18801 2265 -16536
+ Partials 961 907 -54
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Filters leader-promotion requeues by resolver selector, preventing cross-resolver failures.
Changes:
- Shares one validated selector across promotion and informer paths.
- Preserves the legacy helper while adding a selector-aware replacement.
- Adds tests for matching, nonmatching, and empty selectors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pkg/resolution/resolver/framework/controller.go |
Adds selector-aware promotion filtering. |
pkg/resolution/resolver/framework/controller_test.go |
Tests promotion filtering and compatibility behavior. |
pkg/remoteresolution/resolver/framework/controller.go |
Uses the shared selector for both controller paths. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| func LeaderAwareFuncs(lister rrlister.ResolutionRequestLister) reconciler.LeaderAwareFuncs { | ||
| return leaderAwareFuncs(lister, labels.Everything()) |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@waveywaves — could I get another look when you have a moment? I addressed your review in 42e5b5a back on 21 Aug and the full suite is green now, including all the e2e legs. I've also corrected the Compatibility section, which still described the earlier source-breaking version. @vdemeester approved on 27 Aug, so I think this just needs an lgtm. |
|
/lgtm |
Changes
On leader promotion the resolver framework listed ResolutionRequests with
labels.Everything()and enqueued every one of them into every resolver's workqueue. The reconciler has no label guard of its own, so whichever resolver dequeued a request first ranValidate()andResolve()on it regardless of itsresolution.tekton.dev/typelabel. A request addressed to the http resolver could therefore be failed by the hub resolver withmissing required hub resolver params: name, version, and since the request is then already done the correct resolver skips it.The informer's event handler was already filtered by
FilterResolutionRequestsBySelector. Only the promote path was not.This passes the resolver's selector into
LeaderAwareFuncsand lists withlabels.SelectorFromSet, which applies the same AND-of-equality match the event handler uses. Both frameworks now read the selector once and share it between the two paths, so the two filters cannot drift apart. It also answers theTODO(sbwsg)that has sat onLeaderAwareFuncssince it was introduced ("Should we use the filter selector from above in the call tolister.Listhere?"), which is yes.Compatibility
No exported signature changes.
LeaderAwareFuncskeeps its original one-argument form and itslabels.Everything()behaviour, now marked deprecated; the filtered listing is a newLeaderAwareFuncsWithSelector, which is what the two in-treeNewControllerfuncs call. Out-of-tree resolvers keep compiling untouched.One behaviour note: an empty label set now maps to
labels.Nothing()rather thanlabels.Everything(), and both controllers validate the selector and panic on an invalid one.Validation
go build ./..., and every test binary under./pkg/...and./cmd/...compilesgo test ./pkg/resolution/... ./pkg/remoteresolution/..., 21 packages passpre-commit runon the changed files, includingmake test-unitover the whole repolint-gohook could not run because the install script rejects the golangci-lint v2.12.2 darwin/arm64 tarball on a checksum mismatch (c8debe3b...vs the expecteda9c54498...). I installed that same pinned v2.12.2 withgo installinstead and ran it over both framework packages: 0 issues. Worth knowing if others hit it.TestLeaderAwareFuncsPromoteFiltersBySelectorfails on all three table rows when the fix is reverted tolabels.Everything(), withhttp-requestandunlabeled-requestleaking into the git resolver's queue.Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepFixes #10484
Relates to #
Release Notes