diff --git a/internal/controller/eventing/nats.go b/internal/controller/eventing/nats.go index 65031b37..d261754d 100644 --- a/internal/controller/eventing/nats.go +++ b/internal/controller/eventing/nats.go @@ -34,6 +34,10 @@ func (r *Reconciler) reconcileNATSSubManager(ctx context.Context, eventing *v1al if err := r.stopNATSSubManager(false, log); err != nil { return err } + } else if eventing.Status.BackendConfigHash != specHash { + // in case spec is change and subManager is not started yet (e.g. due to error) + // make natsSubManager nil to create a subManager with new values + r.natsSubManager = nil } if r.natsSubManager == nil { diff --git a/internal/controller/eventing/nats_test.go b/internal/controller/eventing/nats_test.go index ced1a7b6..c7005a14 100644 --- a/internal/controller/eventing/nats_test.go +++ b/internal/controller/eventing/nats_test.go @@ -131,7 +131,7 @@ func Test_reconcileNATSSubManager(t *testing.T) { name: "it should retry to start subscription manager when subscription manager was " + "successfully initialized but failed to start", givenIsNATSSubManagerStarted: false, - givenHashBefore: int64(0), + givenHashBefore: int64(-7550677537009891034), givenNATSSubManagerMock: func() *submanagermocks.Manager { jetStreamSubManagerMock := new(submanagermocks.Manager) jetStreamSubManagerMock.On("Init", mock.Anything).Return(nil).Once() @@ -156,7 +156,7 @@ func Test_reconcileNATSSubManager(t *testing.T) { wantAssertCheck: true, givenShouldRetry: true, wantError: errors.New("failed to start"), - wantHashAfter: int64(0), + wantHashAfter: int64(-7550677537009891034), }, { name: "it should update the subscription manager when the backend config changes",