From a6cac1349f4ce9e2279adebcf635837c3ef46bd8 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 18 Jul 2024 15:03:16 +0100 Subject: [PATCH] Return error if no longer leader when publishing (#3794) Signed-off-by: Chris Martin Co-authored-by: Chris Martin --- internal/scheduler/publisher.go | 2 +- internal/scheduler/publisher_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/scheduler/publisher.go b/internal/scheduler/publisher.go index bc40f42f237..2478983f6cc 100644 --- a/internal/scheduler/publisher.go +++ b/internal/scheduler/publisher.go @@ -125,7 +125,7 @@ func (p *PulsarPublisher) PublishMessages(ctx *armadacontext.Context, events []* return errors.New("One or more messages failed to send to Pulsar") } } else { - ctx.Debugf("No longer leader so not publishing") + return errors.New("Failed to publish as no longer leader") } return nil } diff --git a/internal/scheduler/publisher_test.go b/internal/scheduler/publisher_test.go index c3fa778565c..c1135603cf8 100644 --- a/internal/scheduler/publisher_test.go +++ b/internal/scheduler/publisher_test.go @@ -53,6 +53,7 @@ func TestPulsarPublisher_TestPublish(t *testing.T) { "Don't publish if not leader": { amLeader: false, numSuccessfulPublishes: math.MaxInt, + expectedError: true, eventSequences: []*armadaevents.EventSequence{ { JobSetName: "jobset1",