Skip to content

fix(trigger): track the subscriber with the Trigger as observer - #9509

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
lbarrosby:fix-trigger-subscriber-tracking
Nov 6, 2026
Merged

knative-prow[bot] merged 1 commit into
knative:mainfrom
lbarrosby:fix-trigger-subscriber-tracking

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

Related to #5374 (closed without a root cause; same symptom: a Trigger is not re-reconciled when its subscriber becomes ready).

The MT broker Trigger reconciler resolves the subscriber with the Broker as the tracker parent:

subscriberAddr, err := r.uriResolver.AddressableFromDestinationV1(ctx, t.Spec.Subscriber, b)

The tracker records the parent as the observer, so it stores <namespace>/<broker-name>. The tracker callback is the Trigger controller's EnqueueKey, so when the subscriber changes, the Trigger work queue gets a key for a Trigger that does not exist (or for an unrelated Trigger that happens to share the Broker's name), and the real Trigger is not reconciled.

The broker filter dispatches to status.subscriberUri, status.subscriberCACerts and status.subscriberAudience, so this matters beyond readiness:

  • a Trigger created before its subscriber is ready only recovers through the error backoff, not when the subscriber becomes addressable;
  • when the subscriber's address changes (URL, CA bundle rotation, audience), the filter keeps using the old values until something else reconciles the Trigger or the resync period passes.

Every other AddressableFromDestinationV1 call in pkg/reconciler passes the object being reconciled, including the Trigger's own dead letter sink a few lines below.

Proposed Changes

  • 🐛 Pass the Trigger, not the Broker, as the tracker parent when resolving the subscriber

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Testing

TestReconcileTracksSubscriberForTrigger reconciles a Trigger whose subscriber does not exist yet, using a real tracker, and checks the observers recorded for the subscriber. On main it fails with test-namespace/test-broker as the observer; with the fix it is test-namespace/test-trigger. go test ./pkg/reconciler/broker/..., go vet and golangci-lint on the package pass.

Release Note

Triggers of the MT channel based broker are now reconciled when their subscriber changes, so the subscriber URI, CA certs and audience used by the broker filter stay current.

Docs

AI disclosure: written with the help of Claude Code, reviewed and tested by me.

The MT broker Trigger reconciler resolved the subscriber with the Broker
as the tracker parent. The tracker then recorded <namespace>/<broker-name>
as the observer, and since the tracker callback enqueues into the Trigger
work queue, a change to the subscriber enqueued a Trigger key that does
not exist instead of the Trigger itself.

As a result the Trigger was not reconciled when its subscriber became
addressable or changed its address, and the broker filter kept using the
stale status.subscriberUri, CA certs and audience until another event or
a resync reconciled the Trigger.

Pass the Trigger as the parent, as is already done for the Trigger's
dead letter sink.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@knative-prow

knative-prow Bot commented Nov 5, 2026

Copy link
Copy Markdown

Welcome @lbarrosby! It looks like this is your first PR to knative/eventing 🎉

@knative-prow knative-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 5, 2026
@knative-prow

knative-prow Bot commented Nov 5, 2026

Copy link
Copy Markdown

Hi @lbarrosby. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow
knative-prow Bot requested review from Cali0707 and Leo6Leo November 5, 2026 18:56
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.34%. Comparing base (515e11e) to head (395a616).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9509   +/-   ##
=======================================
  Coverage   51.33%   51.34%           
=======================================
  Files         411      411           
  Lines       22187    22187           
=======================================
+ Hits        11389    11391    +2     
+ Misses       9916     9915    -1     
+ Partials      882      881    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Cali0707

Cali0707 commented Nov 5, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 5, 2026

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

/lgtm
/approve

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2026
@knative-prow

knative-prow Bot commented Nov 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, lbarrosby

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 5, 2026
@lbarrosby

Copy link
Copy Markdown
Contributor Author

/retest

@knative-prow
knative-prow Bot merged commit 495a0f9 into knative:main Nov 6, 2026
35 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants