Skip to content

Conversation

@flemzord
Copy link
Member

Summary

  • Add brokers.Watch[*v1beta1.Orchestration]() to the Orchestrations controller to fix a bug where Orchestration wasn't being reconciled when broker.dsn setting was added after the resource was created

This is a follow-up to #378 which fixed the same issue for Webhooks.

Problem

When Orchestration is created before the broker.dsn setting exists:

  1. The BrokerConsumer is created but not ready (no broker configured)
  2. The reconciler returns with "waiting for consumers to be ready" without creating the deployment
  3. Later, when broker.dsn is added, the Broker becomes ready
  4. BrokerConsumer becomes ready
  5. But Orchestration was 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 watch wasn't sufficient

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

Solution

Add brokers.Watch[*v1beta1.Orchestration]() to directly watch for Broker status changes, ensuring Orchestration is reconciled when the Broker becomes ready.

This follows the same pattern used by:

Test plan

  • All existing tests pass
  • Manual testing: Create Orchestration before broker.dsn, then add broker.dsn - Orchestration should automatically reconcile and create its deployment

…roker changes

Similar to the webhooks fix, the orchestrations module also uses
brokerconsumers.CreateOrUpdateOnAllServices and checks consumer.Status.Ready
before creating its deployment.

When the Orchestration 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 Orchestration was not being notified of this change.

The existing brokertopics.Watch[*v1beta1.Orchestration]("orchestration") only
triggers when the "orchestration" BrokerTopic changes, which only happens when
another consumer wants to consume from Orchestration. This is not sufficient
when Orchestration is the first/only module consuming broker events.

This adds brokers.Watch[*v1beta1.Orchestration]() to directly watch for
Broker status changes, ensuring Orchestration is reconciled when the Broker
becomes ready.
@flemzord flemzord requested a review from a team as a code owner January 12, 2026 08:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

Walkthrough

This change adds an import for the brokers package and registers a new broker watch dependency for Orchestration resources in the initialization configuration.

Changes

Cohort / File(s) Summary
Broker Watch Configuration
internal/resources/orchestrations/init.go
Added brokers package import and registered brokers.Watch[*v1beta1.Orchestration]() as a watch dependency in the Init configuration

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Suggested reviewers

  • gfyrag
  • sylr

Poem

🐰 A watch for orchestrations, so fine,
Brokers now in the loop, all aligned,
Two lines of code, yet the connection is deep,
As rabbits and orchestras gracefully leap! 🎭

🚥 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 specifically describes the main change: adding brokers.Watch to fix reconciliation on broker changes in the orchestrations controller.
Description check ✅ Passed The description is directly related to the changeset, providing detailed context about the bug being fixed, why the existing watch was insufficient, and how the solution aligns with similar fixes.

✏️ 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/orchestrations-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 3b5724b and 780df53.

📒 Files selected for processing (1)
  • internal/resources/orchestrations/init.go
🧰 Additional context used
🧬 Code graph analysis (1)
internal/resources/orchestrations/init.go (2)
internal/resources/brokers/watch.go (1)
  • Watch (13-31)
api/formance.com/v1beta1/orchestration_types.go (1)
  • Orchestration (47-53)
🔇 Additional comments (2)
internal/resources/orchestrations/init.go (2)

27-27: LGTM!

The import is correctly added and properly ordered alphabetically with the other broker-related imports.


104-106: LGTM! This correctly addresses the reconciliation gap.

The brokers.Watch ensures Orchestration is reconciled when Broker status changes (e.g., becomes ready after broker.dsn is configured). This complements the existing brokertopics.Watch which only triggers on BrokerTopic changes—insufficient when Orchestration is the first/only consumer and the topic doesn't exist yet.

The fix follows the established pattern used by databases.Watch and aligns with similar fixes in other controllers.


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

@flemzord flemzord enabled auto-merge (squash) January 12, 2026 08:31
@flemzord flemzord merged commit 4851b3f into main Jan 12, 2026
10 of 11 checks passed
@flemzord flemzord deleted the fix/orchestrations-broker-watch branch January 12, 2026 08:52
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.

3 participants