Skip to content

Commit

Permalink
Merge branch 'master' into typos
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden authored Jan 6, 2022
2 parents 0c71c35 + e97056e commit 2f889f3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
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 @@ -403,6 +403,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 disable
if compSpec.Type().Field(i).Name == "NgPort" && (port == -1 || port == 0) {
continue
}
if port < 1 || port > 65535 {
Expand Down

0 comments on commit 2f889f3

Please sign in to comment.