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 cannot use exec command when hostname contain '-' #1794

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion components/cluster/command/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func newAuditCleanupCmd() *cobra.Command {
Use: "cleanup",
Short: "cleanup cluster audit logs",
RunE: func(cmd *cobra.Command, args []string) error {

if retainDays < 0 {
return errors.Errorf("retain-days cannot be less than 0")
}
Expand Down
1 change: 0 additions & 1 deletion components/dm/command/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func newAuditCleanupCmd() *cobra.Command {
Use: "cleanup",
Short: "cleanup dm audit logs",
RunE: func(cmd *cobra.Command, args []string) error {

if retainDays < 0 {
return errors.Errorf("retain-days cannot be less than 0")
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/cluster/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func GetAuditList(dir string) ([]Item, error) {

// OutputAuditLog outputs audit log.
func OutputAuditLog(dir, fileSuffix string, data []byte) error {

auditID := base52.Encode(time.Now().UnixNano() + rand.Int63n(1000))
if customID := os.Getenv(EnvNameAuditID); customID != "" {
auditID = fmt.Sprintf("%s_%s", auditID, customID)
Expand Down Expand Up @@ -223,7 +222,6 @@ type deleteAuditLog struct {

// DeleteAuditLog cleanup audit log
func DeleteAuditLog(dir string, retainDays int, skipConfirm bool, displayMode string) error {

if retainDays < 0 {
return errors.Errorf("retainDays cannot be less than 0")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/manager/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (m *Manager) Exec(name string, opt ExecOptions, gOpt operator.Options) erro
var shellTasks []task.Task
uniqueHosts := map[string]set.StringSet{} // host-sshPort -> {command}
topo.IterInstance(func(inst spec.Instance) {
key := fmt.Sprintf("%s-%d", inst.GetHost(), inst.GetSSHPort())
key := fmt.Sprintf("%s:%d", inst.GetHost(), inst.GetSSHPort())
if _, found := uniqueHosts[key]; !found {
if len(gOpt.Roles) > 0 && !filterRoles.Exist(inst.Role()) {
return
Expand All @@ -80,7 +80,7 @@ func (m *Manager) Exec(name string, opt ExecOptions, gOpt operator.Options) erro
})

for hostKey, i := range uniqueHosts {
host := strings.Split(hostKey, "-")[0]
host := strings.Split(hostKey, ":")[0]
for _, cmd := range i.Slice() {
shellTasks = append(shellTasks,
task.NewBuilder(m.logger).
Expand Down