Skip to content

Commit

Permalink
cluster: fix custom port handling for drainer on importing (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis authored Sep 23, 2020
1 parent 251998a commit ab2232a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/cluster/ansible/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ func parseGroupVars(dir, ansCfgFile string, clsMeta *spec.ClusterMeta, inv *aini
if port, ok := grpVarsAll["drainer_port"]; ok {
tmpIns.Port, _ = strconv.Atoi(port)
}
// apply values from the host
if port, ok := srv.Vars["drainer_port"]; ok {
tmpIns.Port, _ = strconv.Atoi(port)
}

log.Debugf("Imported %s node %s:%d.", tmpIns.Role(), tmpIns.Host, tmpIns.GetMainPort())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package ansible
import (
"fmt"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -183,6 +184,11 @@ func parseDirs(user string, ins spec.InstanceSpec, sshTimeout int64, sshType exe
newIns.LogDir = logDir
continue
}
if strings.Contains(line, "--initial-commit-ts=") {
tsArg := strings.Split(line, " ")[4] // 4 whitespaces ahead
tmpTs, _ := strconv.Atoi(strings.TrimPrefix(tsArg, "--initial-commit-ts="))
newIns.CommitTS = int64(tmpTs)
}
}
return newIns, nil
case spec.ComponentPrometheus:
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion pkg/cluster/ansible/test-data/inventory.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ TiDB-PD-218 ansible_host=172.16.1.218 ansible_port=30000
## Binlog Part
[pump_servers]
172.16.1.219
172.16.1.220
172.16.1.220 pump_port=8333

[drainer_servers]
172.16.1.220 drainer_port=8444
172.16.1.221

[tiflash_servers]
Expand Down
14 changes: 11 additions & 3 deletions pkg/cluster/ansible/test-data/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,20 @@ topology:
- host: 172.16.1.220
ssh_port: 9999
imported: true
port: 8250
deploy_dir: /home/tiopsimport/ansible-deploy/pump-8250
data_dir: data/pump-8250
port: 8333
deploy_dir: /home/tiopsimport/ansible-deploy/pump-8333
data_dir: data/pump-8333
arch: amd64
os: linux
drainer_servers:
- host: 172.16.1.220
ssh_port: 9999
imported: true
port: 8444
deploy_dir: /home/tiopsimport/ansible-deploy/drainer-8444
data_dir: data/drainer-8444
arch: amd64
os: linux
- host: 172.16.1.221
ssh_port: 9999
imported: true
Expand Down

0 comments on commit ab2232a

Please sign in to comment.