Skip to content

Commit b6f5e1f

Browse files
committed
add command after repair
1 parent 421ea18 commit b6f5e1f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ type RepairOperation struct {
304304
RepairSteps []RepairStep `json:"repair_steps"`
305305
HealthCheckCommand []string `json:"health_check_command"`
306306
CommandTimeoutSeconds *int `json:"command_timeout_seconds,omitempty"`
307+
SuccessCommand []string `json:"success_command,omitempty"`
308+
SuccessCommandTimeout *int `json:"success_command_timeout,omitempty"`
307309
}
308310

309311
type RepairStep struct {
@@ -319,6 +321,7 @@ const DefaultMaxConcurrentRepairs = 1
319321
const DefaultRepairEvictionTimeoutSeconds = 600
320322
const DefaultRepairHealthCheckCommandTimeoutSeconds = 30
321323
const DefaultRepairCommandTimeoutSeconds = 30
324+
const DefaultRepairSuccessCommandTimeoutSeconds = 30
322325

323326
type Retire struct {
324327
OptionalCommand []string `json:"optional_command,omitempty"`

op/status.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,29 @@ func GetRepairQueueStatus(ctx context.Context, inf cke.Infrastructure, n *cke.No
613613
}
614614
if healthy {
615615
rqs.RepairCompleted[entry.Address] = true
616+
//execute Success command
617+
op, err := entry.GetMatchingRepairOperation(cluster)
618+
if err != nil {
619+
return cke.RepairQueueStatus{}, err
620+
}
621+
if op.SuccessCommand != nil {
622+
err := func() error {
623+
ctx := ctx
624+
timeout := cke.DefaultRepairSuccessCommandTimeoutSeconds
625+
if op.SuccessCommandTimeout != nil {
626+
timeout = *op.SuccessCommandTimeout
627+
}
628+
if timeout != 0 {
629+
var cancel context.CancelFunc
630+
ctx, cancel = context.WithTimeout(ctx, time.Second*time.Duration(timeout))
631+
defer cancel()
632+
}
633+
args := append(op.SuccessCommand[1:], entry.Address)
634+
command := well.CommandContext(ctx, op.SuccessCommand[0], args...)
635+
return command.Run()
636+
}()
637+
return cke.RepairQueueStatus{}, err
638+
}
616639
}
617640
}
618641

0 commit comments

Comments
 (0)