Skip to content

Commit

Permalink
cluster: exclude spark from start/stop actions
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Jul 1, 2020
1 parent a28c450 commit 50aaf3b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
41 changes: 41 additions & 0 deletions pkg/cluster/operation/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,19 @@ func RestartComponent(getter ExecutorGetter, instances []spec.Instance, timeout
log.Infof("Restarting component %s", name)

for _, ins := range instances {
// tispark need to be started manually by user
switch ins.Role() {
case spec.RoleTiSparkMaster:
log.Warnf(
"TiSpark need to be restarted manually, please login to the server and execute stop-master.sh and start-master.sh in %s",
ins.DeployDir(), ins.DeployDir())
continue
case spec.RoleTiSparkSlave:
log.Warnf(
"TiSpark need to be restarted manually, please login to the server and execute stop-slave.sh and start-slave.sh in %s",
ins.DeployDir(), ins.DeployDir())
continue
}
e := getter.Get(ins.GetHost())
log.Infof("\tRestarting instance %s", ins.GetHost())

Expand Down Expand Up @@ -427,6 +440,20 @@ func RestartComponent(getter ExecutorGetter, instances []spec.Instance, timeout
}

func startInstance(getter ExecutorGetter, ins spec.Instance, timeout int64) error {
// tispark need to be started manually by user
switch ins.Role() {
case spec.RoleTiSparkMaster:
log.Warnf(
"TiSpark need to be started manually, please login to the server and execute %s/start-master.sh",
ins.DeployDir(), ins.DeployDir())
return nil
case spec.RoleTiSparkSlave:
log.Warnf(
"TiSpark need to be started manually, please login to the server and execute %s/start-slave.sh",
ins.DeployDir(), ins.DeployDir())
return nil
}

e := getter.Get(ins.GetHost())
log.Infof("\tStarting instance %s %s:%d",
ins.ComponentName(),
Expand Down Expand Up @@ -561,6 +588,20 @@ func StopMonitored(getter ExecutorGetter, instance spec.Instance, options spec.M
}

func stopInstance(getter ExecutorGetter, ins spec.Instance) error {
// tispark need to be stopped manually by user
switch ins.Role() {
case spec.RoleTiSparkMaster:
log.Warnf(
"TiSpark need to be stopped manually, please login to the server and execute %s/stop-master.sh",
ins.DeployDir(), ins.DeployDir())
return nil
case spec.RoleTiSparkSlave:
log.Warnf(
"TiSpark need to be stopped manually, please login to the server and execute %s/stop-slave.sh",
ins.DeployDir(), ins.DeployDir())
return nil
}

e := getter.Get(ins.GetHost())
log.Infof("\tStopping instance %s", ins.GetHost())

Expand Down
4 changes: 3 additions & 1 deletion pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const (

// general role names
var (
RoleMonitor = "monitor"
RoleMonitor = "monitor"
RoleTiSparkMaster = "tispark-master"
RoleTiSparkSlave = "tispark-slave"
)

type (
Expand Down
8 changes: 4 additions & 4 deletions pkg/cluster/spec/tispark.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type TiSparkMasterSpec struct {

// Role returns the component role of the instance
func (s TiSparkMasterSpec) Role() string {
return ComponentTiSpark
return RoleTiSparkMaster
}

// SSH returns the host and SSH port of the instance
Expand Down Expand Up @@ -75,7 +75,7 @@ type TiSparkSlaveSpec struct {

// Role returns the component role of the instance
func (s TiSparkSlaveSpec) Role() string {
return ComponentTiSpark
return RoleTiSparkSlave
}

// SSH returns the host and SSH port of the instance
Expand Down Expand Up @@ -122,7 +122,7 @@ func (c *TiSparkMasterComponent) Instances() []Instance {
s.DeployDir,
},
statusFn: func(_ ...string) string {
return "-"
return "N/A"
},
},
})
Expand Down Expand Up @@ -243,7 +243,7 @@ func (c *TiSparkSlaveComponent) Instances() []Instance {
s.DeployDir,
},
statusFn: func(_ ...string) string {
return "-"
return "N/A"
},
},
})
Expand Down

0 comments on commit 50aaf3b

Please sign in to comment.