Skip to content

Commit

Permalink
cluster: fix wrong default initial-commit-ts in drainer
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar committed Dec 16, 2021
1 parent 3523106 commit 8576194
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 2 additions & 3 deletions pkg/cluster/ansible/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"context"
"fmt"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -195,8 +194,8 @@ func parseDirs(ctx context.Context, user string, ins spec.InstanceSpec, sshTimeo
}
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)
tmpTs := strings.TrimPrefix(tsArg, "--initial-commit-ts=")
newIns.CommitTS = tmpTs
}
}
return newIns, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/spec/drainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type DrainerSpec struct {
DeployDir string `yaml:"deploy_dir,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
LogDir string `yaml:"log_dir,omitempty"`
CommitTS int64 `yaml:"commit_ts,omitempty"`
CommitTS string `yaml:"commit_ts,omitempty"`
Offline bool `yaml:"offline,omitempty"`
NumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
Config map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
Expand Down
10 changes: 6 additions & 4 deletions pkg/cluster/template/scripts/drainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type DrainerScript struct {
DataDir string
LogDir string
NumaNode string
CommitTs int64
CommitTs string
Endpoints []*PDScript
}

Expand All @@ -44,7 +44,7 @@ func NewDrainerScript(nodeID, ip, deployDir, dataDir, logDir string) *DrainerScr
DeployDir: deployDir,
DataDir: dataDir,
LogDir: logDir,
CommitTs: -1,
CommitTs: "-1",
}
}

Expand All @@ -61,8 +61,10 @@ func (c *DrainerScript) WithNumaNode(numa string) *DrainerScript {
}

// WithCommitTs set CommitTs field of DrainerScript
func (c *DrainerScript) WithCommitTs(ts int64) *DrainerScript {
c.CommitTs = ts
func (c *DrainerScript) WithCommitTs(ts string) *DrainerScript {
if ts != "" {
c.CommitTs = ts
}
return c
}

Expand Down

0 comments on commit 8576194

Please sign in to comment.