fix(orchestrations): provision broker topic for events#447
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR enhances broker topic infrastructure by adding watch wiring that routes ChangesBroker Topic Watch and Orchestration Integration
Sequence DiagramsequenceDiagram
participant BrokerTopicEvent as BrokerTopic Event
participant BrokerWatch as Broker Watch Handler
participant BrokerReconciler as Broker Reconciler
participant OrchestrReconciler as Orchestration Reconciler
participant BrokerTopicAPI as BrokerTopic API
BrokerTopicEvent->>BrokerWatch: BrokerTopic created/updated
activate BrokerWatch
BrokerWatch->>BrokerReconciler: Generate reconcile.Request<br/>(Broker named in topic.Spec.Stack)
deactivate BrokerWatch
OrchestrReconciler->>BrokerTopicAPI: Create BrokerTopic<br/>(service="orchestration")
activate BrokerTopicAPI
BrokerTopicAPI->>BrokerTopicAPI: Set owner refs (owner, stack)
BrokerTopicAPI-->>OrchestrReconciler: Return topic
deactivate BrokerTopicAPI
OrchestrReconciler->>OrchestrReconciler: Check topic.Status.Ready
alt Ready
OrchestrReconciler->>OrchestrReconciler: Continue reconciliation
else Not Ready
OrchestrReconciler-->>OrchestrReconciler: Return PendingError
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| core.WithFinalizer[*v1beta1.Broker]("clear", deleteBroker), | ||
| core.WithOwn[*v1beta1.Broker](&v1.Job{}), | ||
| core.WithWatchSettings[*v1beta1.Broker](), | ||
| core.WithWatch[*v1beta1.Broker, *v1beta1.BrokerTopic](func(ctx core.Context, topic *v1beta1.BrokerTopic) []reconcile.Request { |
There was a problem hiding this comment.
What is the purpose of this change?
There was a problem hiding this comment.
This watch wakes up the Broker reconciler when a BrokerTopic is created or updated.
In one-stream-by-service mode, the Broker reconciler is responsible for listing BrokerTopic objects and creating the matching NATS stream. When a new topic is introduced after the Broker already exists, there may be no Broker event otherwise, so the stream creation can be delayed until some unrelated reconciliation happens.
I also added a short code comment locally to make this dependency explicit.
f307811 to
73d4430
Compare
Summary
Context
A production stack using OneStreamByService had publisher mapping
*:xjqfdgkwngtt-rzbk-orchestrationwith NATS auto-provision disabled, but no matching BrokerTopic/JetStream stream was created. Workflow startup events then failed withnats: no response from stream.Tests
go test ./internal/resources/brokers ./internal/resources/brokertopics ./internal/resources/orchestrations ./internal/resources/brokerconsumersASSETS=$(go run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest use 1.32.0 -p path) && CGO_ENABLED=0 KUBEBUILDER_ASSETS="$ASSETS" go test ./internal/tests -ginkgo.focus 'OrchestrationController|BrokerTopicController|BrokerConsumer'