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

cluster: ngm server default enabled during deployment #1699

Merged
merged 10 commits into from
Jan 6, 2022
2 changes: 1 addition & 1 deletion pkg/cluster/spec/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type PrometheusSpec struct {
Patched bool `yaml:"patched,omitempty"`
IgnoreExporter bool `yaml:"ignore_exporter,omitempty"`
Port int `yaml:"port" default:"9090"`
NgPort int `yaml:"ng_port,omitempty" validate:"ng_port:editable"`
NgPort int `yaml:"ng_port,omitempty" validate:"ng_port:editable"` // ng_port is usable since v5.3.0 and default as 12020 since v5.4.0, so the default value is set in spec.go/AdjustByVersion
DeployDir string `yaml:"deploy_dir,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
LogDir string `yaml:"log_dir,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,13 @@ func (s *Specification) AdjustByVersion(clusterVersion string) {
server.DataDir = ""
}
}
if semver.Compare(clusterVersion, "v5.4.0") >= 0 {
for _, m := range s.Monitors {
if m.NgPort == 0 {
m.NgPort = 12020
}
}
}
}

// GetDashboardAddress returns the cluster's dashboard addr
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/spec/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ func (s *Specification) portInvalidDetect() error {
if strings.HasSuffix(compSpec.Type().Field(i).Name, "Port") {
port := int(compSpec.Field(i).Int())
portTags := strings.Split(compSpec.Type().Field(i).Tag.Get("yaml"), ",")
// when use not specify ng_port, its default value is 0
if port == 0 && len(portTags) > 1 && portTags[1] == "omitempty" {
// when port has omitempty tag, it means it is a optional port whice 0 means default and -1 means diable
if len(portTags) > 1 && portTags[1] == "omitempty" {
continue
}
if port < 1 || port > 65535 {
nexustar marked this conversation as resolved.
Show resolved Hide resolved
Expand Down