(2.15) [ADDED] Domain prefixed JetStream API in the system account - #8429
(2.15) [ADDED] Domain prefixed JetStream API in the system account#8429MauriceVanVeen wants to merge 1 commit into
Conversation
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
|
Claude finished @MauriceVanVeen's task in 10m 24s —— View job PR Review: (2.15) [ADDED] Domain prefixed JetStream API in the system account
Overall AssessmentThe design of this PR is sound: adding One correctness issue was found — see the inline comment on Critical: Domain mapping lost after system-account JWT update
The fix is to also check whether the domain mapping is present in leafnode.go change is correctThe key change is moving Minor observations
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b5b37c6e1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| // Map the domain prefixed API too, so an isolated JetStream is addressable by | ||
| // domain like an account is. Unprefixed always means this server's own JetStream. | ||
| if domain := s.getOpts().JetStreamDomain; domain != _EMPTY_ { |
There was a problem hiding this comment.
Potential bug: domain mapping silently dropped on system-account JWT update.
When a JWT update arrives for the system account, updateAccountClaimsWithRefresh reconciles mappings: any m.src not in the JWT's ac.Mappings is removed — including $JS.<domain>.API.>, which is server-internal and never present in the JWT.
After removal, addSystemAccountExports → checkJetStreamExports is called, but checkJetStreamExports only checks for the jsAllAPI service export. Since that export still exists (se != nil), setupJetStreamExports is not called and the domain mapping is never re-added. The domain-prefixed API silently breaks until server restart.
TestJWTSystemAccountJetStreamDomainMapping is designed to catch exactly this — it pushes a new JWT and asserts the mapping survives — but it should be failing with the current implementation.
checkJetStreamExports needs to also verify the domain mapping is present:
func (s *Server) checkJetStreamExports() {
if sacc := s.SystemAccount(); sacc != nil {
sacc.mu.RLock()
se := sacc.getServiceExport(jsAllAPI)
needsDomainMapping := false
if domain := s.getOpts().JetStreamDomain; domain != _EMPTY_ {
domainAPI := fmt.Sprintf(jsDomainAPI, domain)
needsDomainMapping = true
for _, m := range sacc.mappings {
if m.src == domainAPI {
needsDomainMapping = false
break
}
}
}
sacc.mu.RUnlock()
if se == nil || needsDomainMapping {
s.setupJetStreamExports()
}
}
}AddServiceExport is idempotent (no error when re-adding an existing export), so calling setupJetStreamExports when only the mapping is missing is safe.
There was a problem hiding this comment.
updateAccountClaimsWithRefresh already resets the exports before reconciling mappings. So checkJetStreamExports is guaranteed to find se == nil, to call setupJetStreamExports, and set up both the JS API service export and the domain mapping.
the test should be failing
TestJWTSystemAccountJetStreamDomainMapping passes today, and would only fail if the above invariant were broken.
|
@claude, brief re-review. |
|
Claude finished @MauriceVanVeen's task in 2m 26s —— View job Brief Re-review
Re-review findingsMauriceVanVeen's responses are correct on both points. On the "critical" JWT update bug (now confirmed: not a bug) The previous review incorrectly assumed the service export would still be present (
On the Codex P2 ( The This PR looks good to merge. |
The system account can be shared between a hub and leaf cluster, but having different domains. This ensures they are treated as two separate JetStream meta groups. Before this PR it wasn't possible to administer the leaf cluster from the hub, since the system account's JS API wasn't domain-aware, and the servers added automatic pub/sub denies to
$JS.API.>so JetStreams of different domains don't cross-talk about a system JS API request. This PR preserves the pub/sub denies and adds support for the domain-aware JS API, by allowing the same$JS.<domain>.API.>convention that accounts use.