Skip to content

Commit

Permalink
use *int64 for commitTS
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar committed Jan 6, 2022
1 parent dea9ebd commit 9d9ab6c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/cluster/ansible/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,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)
newIns.Config = make(map[string]interface{})
newIns.Config["initial_commit_ts"] = int64(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" validate:"commit_ts:editable"` // do not use it anymore, exist for compatibility
CommitTS *int64 `yaml:"commit_ts,omitempty" validate:"commit_ts:editable"` // do not use it anymore, exist for compatibility
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
8 changes: 4 additions & 4 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func (s *Specification) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
}

// --initial-commit-ts should not be recorded at run_drainer.sh #1682
// --initial-commit-ts should not be recorded at run_drainer.sh #1682
s.removeCommitTS()

return s.Validate()
Expand Down Expand Up @@ -865,12 +865,12 @@ func (s *Specification) removeCommitTS() {
_, ok1 := s.ServerConfigs.Drainer["initial_commit_ts"]
for _, spec := range s.Drainers {
_, ok2 := spec.Config["initial_commit_ts"]
if !ok1 && !ok2 && spec.CommitTS != -1 {
if !ok1 && !ok2 && spec.CommitTS != nil && *spec.CommitTS != -1 {
if spec.Config == nil {
spec.Config = make(map[string]interface{})
}
spec.Config["initial_commit_ts"] = spec.CommitTS
spec.Config["initial_commit_ts"] = *spec.CommitTS
}
spec.CommitTS = 0
spec.CommitTS = nil
}
}

0 comments on commit 9d9ab6c

Please sign in to comment.