Skip to content

Commit

Permalink
Fix nats stream replica update
Browse files Browse the repository at this point in the history
  • Loading branch information
muralov committed Nov 16, 2023
1 parent 0ec74bd commit 98210c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions internal/controller/eventing/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/eventing/nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
Expand Down

0 comments on commit 98210c1

Please sign in to comment.