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: 2 additions & 0 deletions embed/examples/cluster/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ monitoring_servers:
# ssh_port: 22
# # Prometheus Service communication port.
# port: 9090
# # ng-monitoring servive communication port
# ng_port: 12020
# # Prometheus deployment file, startup script, configuration file storage directory.
# deploy_dir: "/tidb-deploy/prometheus-8249"
# # Prometheus data storage directory.
Expand Down
2 changes: 2 additions & 0 deletions embed/examples/cluster/multi-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ monitoring_servers:
# ssh_port: 22
# # Prometheus Service communication port.
# port: 9090
# # ng-monitoring servive communication port
# ng_port: 12020
# # Prometheus deployment file, startup script, configuration file storage directory.
# deploy_dir: "/tidb-deploy/prometheus-8249"
# # Prometheus data storage directory.
Expand Down
2 changes: 2 additions & 0 deletions embed/examples/cluster/topology.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ monitoring_servers:
# ssh_port: 22
# # Prometheus Service communication port.
# port: 9090
# # ng-monitoring servive communication port
# ng_port: 12020
# # Prometheus deployment file, startup script, configuration file storage directory.
# deploy_dir: "/tidb-deploy/prometheus-8249"
# # Prometheus data storage directory.
Expand Down
5 changes: 5 additions & 0 deletions pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func (m *Manager) Upgrade(name string, clusterVersion string, opt operator.Optio
topo := metadata.GetTopology()
base := metadata.GetBaseMeta()

// Adjust topo by new version
if clusterTopo, ok := topo.(*spec.Specification); ok {
clusterTopo.AdjustByVersion(clusterVersion)
}

var (
downloadCompTasks []task.Task // tasks which are used to download components
copyCompTasks []task.Task // tasks which are used to copy components to remote host
Expand Down
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
5 changes: 2 additions & 3 deletions pkg/cluster/spec/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,8 @@ func (s *Specification) portInvalidDetect() error {
for i := 0; i < compSpec.NumField(); i++ {
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" {
// for NgPort, 0 means default and -1 means diable
nexustar marked this conversation as resolved.
Show resolved Hide resolved
if compSpec.Type().Field(i).Name == "NgPort" && (port == -1 || port == 0) {
continue
}
if port < 1 || port > 65535 {
nexustar marked this conversation as resolved.
Show resolved Hide resolved
Expand Down