From 6a644d0eb2f0fbd27056aa62ecdf56c1e2714249 Mon Sep 17 00:00:00 2001 From: Ryan Currah Date: Fri, 27 Sep 2024 09:29:12 -0400 Subject: [PATCH] feat(sensor): disable leader election for jetstream eventbus Signed-off-by: Ryan Currah --- docs/sensors/ha.md | 8 ++++---- pkg/sensors/listener.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/sensors/ha.md b/docs/sensors/ha.md index 0e1a187174..81c08f26ba 100644 --- a/docs/sensors/ha.md +++ b/docs/sensors/ha.md @@ -12,10 +12,10 @@ behaviors!** ## Kubernetes Leader Election By default, Argo Events will use NATS for the HA leader election except when -using a Kafka Eventbus, in which case a leader election is not required as a -Sensor that uses a Kafka EventBus is capable of horizontally scaling. If using -a different EventBus you can opt-in to a Kubernetes native leader election by -specifying the following annotation. +using a Kafka or JetStream Eventbus, in which case a leader election is not +required as a Sensor that uses a Kafka/JetStream EventBus is capable of +horizontally scaling. If using a different EventBus you can opt-in to a Kubernetes +native leader election by specifying the following annotation. ```yaml annotations: events.argoproj.io/leader-election: k8s diff --git a/pkg/sensors/listener.go b/pkg/sensors/listener.go index a29671b120..27031f7900 100644 --- a/pkg/sensors/listener.go +++ b/pkg/sensors/listener.go @@ -58,9 +58,9 @@ func (sensorCtx *SensorContext) Start(ctx context.Context) error { replicas := int(sensorCtx.sensor.Spec.GetReplicas()) leasename := fmt.Sprintf("sensor-%s", sensorCtx.sensor.Name) - // sensor for kafka eventbus can be scaled horizontally, + // sensor for kafka or jetstream eventbus can be scaled horizontally, // therefore does not require an elector - if sensorCtx.eventBusConfig.Kafka != nil { + if sensorCtx.eventBusConfig.Kafka != nil || sensorCtx.eventBusConfig.JetStream != nil { return sensorCtx.listenEvents(ctx) }