Skip to content

Commit

Permalink
fix: add missing default service imports on reload
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Quevedo <wally@nats.io>
  • Loading branch information
wallyqs committed Aug 2, 2023
1 parent 13cb62e commit 62d51c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 26 additions & 1 deletion server/reload_test.go
Expand Up @@ -2719,15 +2719,40 @@ func TestConfigReloadAccountWithNoChanges(t *testing.T) {
}
}
`))
s, _ := RunServerWithConfig(conf)
s, opts := RunServerWithConfig(conf)
defer s.Shutdown()

ncA, err := nats.Connect(fmt.Sprintf("nats://a:@%s:%d", opts.Host, opts.Port))
if err != nil {
t.Fatalf("Error on connect: %v", err)
}
defer ncA.Close()

// Confirm service imports are ok.
resp, err := ncA.Request("$SYS.REQ.ACCOUNT.PING.CONNZ", nil, time.Second)
if err != nil {
t.Error(err)
}
if resp == nil || !strings.Contains(string(resp.Data), `"num_connections":1`) {
t.Fatal("unexpected data in connz response")
}

before := s.NumSubscriptions()
s.Reload()
after := s.NumSubscriptions()
if before != after {
t.Errorf("Number of subscriptions changed after reload: %d -> %d", before, after)
}

// Confirm this still works...
resp, err = ncA.Request("$SYS.REQ.ACCOUNT.PING.CONNZ", nil, time.Second)
if err != nil {
t.Fatal(err)
}
if resp == nil || !strings.Contains(string(resp.Data), `"num_connections":1`) {
t.Fatal("unexpected data in connz response")
}

before = s.NumSubscriptions()
s.Reload()
after = s.NumSubscriptions()
Expand Down
3 changes: 3 additions & 0 deletions server/server.go
Expand Up @@ -900,6 +900,9 @@ func (s *Server) configureAccounts(reloading bool) (map[string]struct{}, error)
c.processUnsub(sid)
}
acc.addAllServiceImportSubs()
s.mu.Unlock()
s.registerSystemImports(acc)
s.mu.Lock()
}

// Set the system account if it was configured.
Expand Down

0 comments on commit 62d51c7

Please sign in to comment.