Fixes to service system imports on reload also when using custom system account (#4372)

Adds back the fix from #4369 and also fixes the export that was going
missing in dev branch when a custom system account was being used.
This commit is contained in:
Waldemar Quevedo
2023-08-07 09:02:48 -07:00
committed by GitHub
3 changed files with 12 additions and 8 deletions

View File

@@ -1935,7 +1935,7 @@ func (s *Server) registerSystemImports(a *Account) {
return
}
sacc := s.SystemAccount()
if sacc == nil {
if sacc == nil || sacc == a {
return
}
// FIXME(dlc) - make a shared list between sys exports etc.

View File

@@ -2509,7 +2509,6 @@ func TestConfigReloadClusterPermsOldServer(t *testing.T) {
}
func TestConfigReloadAccountUsers(t *testing.T) {
t.Skip("fix for this needs to be revisited for v2.10 release")
conf := createConfFile(t, []byte(`
listen: "127.0.0.1:-1"
accounts {
@@ -2727,7 +2726,6 @@ func TestConfigReloadAccountUsers(t *testing.T) {
}
func TestConfigReloadAccountWithNoChanges(t *testing.T) {
t.Skip("fix for this needs to be revisited for v2.10 release")
conf := createConfFile(t, []byte(`
listen: "127.0.0.1:-1"
system_account: sys

View File

@@ -1112,7 +1112,7 @@ func (s *Server) configureAccounts(reloading bool) (map[string]struct{}, error)
a.mu.Lock()
acc.shallowCopy(a)
a.mu.Unlock()
// Will be a no-op in case of the global account since it is alrady registered.
// Will be a no-op in case of the global account since it is already registered.
s.registerAccountNoLock(a)
}
// The `acc` account is stored in options, not in the server, and these can be cleared.
@@ -1202,6 +1202,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.
@@ -1214,10 +1217,6 @@ func (s *Server) configureAccounts(reloading bool) (map[string]struct{}, error)
if err == nil && s.sys != nil && acc != s.sys.account {
// sys.account.clients (including internal client)/respmap/etc... are transferred separately
s.sys.account = acc
s.mu.Unlock()
// acquires server lock separately
s.addSystemAccountExports(acc)
s.mu.Lock()
}
if err != nil {
return awcsti, fmt.Errorf("error resolving system account: %v", err)
@@ -1247,6 +1246,13 @@ func (s *Server) configureAccounts(reloading bool) (map[string]struct{}, error)
}
}
// Add any required exports from system account.
if s.sys != nil {
s.mu.Unlock()
s.addSystemAccountExports(s.sys.account)
s.mu.Lock()
}
return awcsti, nil
}