Skip to content

Conversation

@flemzord
Copy link
Member

@flemzord flemzord commented Jan 9, 2026

Summary

  • Add brokers.Watch[]() to the Webhooks and Orchestrations controllers to fix a bug where these modules weren't being reconciled when broker.dsn setting was added after the resource was created

Problem

When Webhooks or Orchestration resources are created before the broker.dsn setting exists:

  1. The BrokerConsumer is created but not ready (no broker configured)
  2. The reconciler returns without creating the deployment (waiting for consumer to be ready)
  3. Later, when broker.dsn is added, the Broker becomes ready
  4. BrokerConsumer becomes ready
  5. But Webhooks/Orchestration were not being notified of this change, so the deployment was never created
  6. Restarting the operator was required to fix the issue

Why the existing watches weren't sufficient

For Webhooks:

  • Only had WithWatchSettings and WithOwn[*v1beta1.Webhooks](&v1beta1.BrokerConsumer{})
  • The ownership watch might not reliably propagate status changes
  • No brokertopics.Watch since Webhooks doesn't publish events (no "webhooks" topic exists)

For Orchestration:

  • Had brokertopics.Watch[*v1beta1.Orchestration]("orchestration")
  • This only triggers when the "orchestration" BrokerTopic changes
  • The "orchestration" BrokerTopic is only created when another consumer wants to consume from Orchestration
  • If Orchestration is the only/first module, no one creates that topic

Solution

Add brokers.Watch[]() to both modules. This ensures that when the Broker status changes (becomes ready), these modules are directly reconciled and can create their deployments with the proper broker configuration.

This follows the same pattern used by other broker-dependent resources:

  • BrokerConsumer uses brokers.Watch[*v1beta1.BrokerConsumer]()
  • BrokerTopic uses brokers.Watch[*v1beta1.BrokerTopic]()
  • Benthos uses brokers.Watch[*v1beta1.Benthos]()

Test plan

  • All existing tests pass
  • Manual testing: Create Webhooks/Orchestration before broker.dsn, then add broker.dsn - modules should automatically reconcile and create their deployments

…changes

When the Webhooks resource is created before the broker.dsn setting exists,
the BrokerConsumer is created but not ready. Later, when broker.dsn is added,
the Broker becomes ready, but Webhooks was not being notified of this change.

This adds brokers.Watch[*v1beta1.Webhooks]() to the Webhooks controller,
ensuring that when the Broker status changes, Webhooks is reconciled and
can create its deployment with the proper broker configuration.

This follows the same pattern used by other broker-dependent resources
like BrokerConsumer, BrokerTopic, and Benthos.
@flemzord flemzord requested a review from a team as a code owner January 9, 2026 15:17
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

Walkthrough

The webhooks initialization file is updated to import the brokers package and register a watch dependency on the Webhooks broker type during initialization, enabling reactive updates to Webhooks resources.

Changes

Cohort / File(s) Summary
Webhooks watch dependency setup
internal/resources/webhooks/init.go
Added brokers package import and registered watch dependency on v1beta1.Webhooks broker type

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A watch upon the webhooks placed,
Where brokers dance in synchronized grace,
Dependencies now tied with care,
Reactive patterns fill the air! 🔔

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding brokers.Watch to fix Webhooks reconciliation on broker status changes.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, solution, and providing context through pattern consistency with other resources.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/webhooks-broker-watch

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 16c53b0 and a6bce63.

📒 Files selected for processing (1)
  • internal/resources/webhooks/init.go
🧰 Additional context used
🧬 Code graph analysis (1)
internal/resources/webhooks/init.go (1)
internal/resources/brokers/watch.go (1)
  • Watch (13-31)
🔇 Additional comments (2)
internal/resources/webhooks/init.go (2)

27-27: LGTM! Import is necessary for the broker watch.

The import follows the existing pattern for internal resource packages and is required for the brokers.Watch call added in the initialization.


93-93: LGTM! This correctly addresses the broker readiness notification issue.

The addition of brokers.Watch[*v1beta1.Webhooks]() ensures that when a Broker's status changes (e.g., when broker.dsn is configured), all Webhooks resources in the same stack will be reconciled. This resolves the issue where Webhooks created before the broker was ready would never create their deployment, even after the broker became ready.

The implementation follows the same pattern consistently used across BrokerConsumer, BrokerTopic, and Benthos components, ensuring architectural consistency and solving the described problem where an operator restart was previously required.


Comment @coderabbitai help to get the list of available commands and usage tips.

@flemzord flemzord enabled auto-merge (squash) January 9, 2026 15:53
@flemzord flemzord requested review from gfyrag and sylr January 9, 2026 15:53
@flemzord flemzord merged commit 3b5724b into main Jan 9, 2026
6 checks passed
@flemzord flemzord deleted the fix/webhooks-broker-watch branch January 9, 2026 15:55
@flemzord flemzord changed the title fix(webhooks): add brokers.Watch to trigger reconciliation on broker changes fix(webhooks,orchestrations): add brokers.Watch to trigger reconciliation on broker changes Jan 12, 2026
@flemzord flemzord added the bug Something isn't working label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants