Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unique_tag to JetStreamConfig for varz/jsz visibility #3617

Merged
merged 3 commits into from Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions server/jetstream.go
Expand Up @@ -43,6 +43,7 @@ type JetStreamConfig struct {
StoreDir string `json:"store_dir,omitempty"`
Domain string `json:"domain,omitempty"`
CompressOK bool `json:"compress_ok,omitempty"`
UniqueTag string `json:"unique_tag,omitempty"`
}

// Statistics about JetStream for this server.
Expand Down Expand Up @@ -174,10 +175,10 @@ func (s *Server) EnableJetStream(config *JetStreamConfig) error {

s.Noticef("Starting JetStream")
if config == nil || config.MaxMemory <= 0 || config.MaxStore <= 0 {
var storeDir, domain string
var storeDir, domain, uniqueTag string
var maxStore, maxMem int64
if config != nil {
storeDir, domain = config.StoreDir, config.Domain
storeDir, domain, uniqueTag = config.StoreDir, config.Domain, config.UniqueTag
maxStore, maxMem = config.MaxStore, config.MaxMemory
}
config = s.dynJetStreamConfig(storeDir, maxStore, maxMem)
Expand All @@ -187,6 +188,9 @@ func (s *Server) EnableJetStream(config *JetStreamConfig) error {
if domain != _EMPTY_ {
config.Domain = domain
}
if uniqueTag != _EMPTY_ {
config.UniqueTag = uniqueTag
}
s.Debugf("JetStream creating dynamic configuration - %s memory, %s disk", friendlyBytes(config.MaxMemory), friendlyBytes(config.MaxStore))
} else if config.StoreDir != _EMPTY_ {
config.StoreDir = filepath.Join(config.StoreDir, JetStreamStoreDir)
Expand Down
12 changes: 11 additions & 1 deletion server/monitor_test.go
Expand Up @@ -4116,13 +4116,15 @@ func TestMonitorJsz(t *testing.T) {
max_mem_store: 10Mb
max_file_store: 10Mb
store_dir: '%s'
unique_tag: az
}
cluster {
name: cluster_name
listen: 127.0.0.1:%d
routes: [nats-route://127.0.0.1:%d]
}
server_name: server_%d `, test.port, test.mport, tmpDir, test.cport, test.routed, test.port)))
server_name: server_%d
server_tags: [ "az:%d" ] `, test.port, test.mport, tmpDir, test.cport, test.routed, test.port, test.port)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Not showing in my editor. I cloned the branch from origin to a fresh directory and also not showing. Will research further.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabs vs spaces

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy tabs from line above and paste.

defer removeFile(t, cf)

s, _ := RunServerWithConfig(cf)
Expand Down Expand Up @@ -4393,6 +4395,14 @@ func TestMonitorJsz(t *testing.T) {
}
}
})
t.Run("unique-tag-exists", func(t *testing.T) {
for _, url := range []string{monUrl1, monUrl2} {
info := readJsInfo(url)
if len(info.Config.UniqueTag) == 0 {
t.Fatalf("expected unique_tag to be returned by %s but got %v", url, info)
}
}
})
}

func TestMonitorReloadTLSConfig(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Expand Up @@ -1769,6 +1769,7 @@ func (s *Server) Start() {
MaxStore: opts.JetStreamMaxStore,
Domain: opts.JetStreamDomain,
CompressOK: true,
UniqueTag: opts.JetStreamUniqueTag,
}
if err := s.EnableJetStream(cfg); err != nil {
s.Fatalf("Can't start JetStream: %v", err)
Expand Down