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: fix custom port handling for drainer on importing #806

Merged
merged 2 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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