Skip to content

Commit

Permalink
add command after repair
Browse files Browse the repository at this point in the history
  • Loading branch information
YZ775 committed Oct 24, 2024
1 parent 421ea18 commit b6f5e1f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ type RepairOperation struct {
RepairSteps []RepairStep `json:"repair_steps"`
HealthCheckCommand []string `json:"health_check_command"`
CommandTimeoutSeconds *int `json:"command_timeout_seconds,omitempty"`
SuccessCommand []string `json:"success_command,omitempty"`
SuccessCommandTimeout *int `json:"success_command_timeout,omitempty"`
}

type RepairStep struct {
Expand All @@ -319,6 +321,7 @@ const DefaultMaxConcurrentRepairs = 1
const DefaultRepairEvictionTimeoutSeconds = 600
const DefaultRepairHealthCheckCommandTimeoutSeconds = 30
const DefaultRepairCommandTimeoutSeconds = 30
const DefaultRepairSuccessCommandTimeoutSeconds = 30

type Retire struct {
OptionalCommand []string `json:"optional_command,omitempty"`
Expand Down
23 changes: 23 additions & 0 deletions op/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,29 @@ func GetRepairQueueStatus(ctx context.Context, inf cke.Infrastructure, n *cke.No
}
if healthy {
rqs.RepairCompleted[entry.Address] = true
//execute Success command
op, err := entry.GetMatchingRepairOperation(cluster)
if err != nil {
return cke.RepairQueueStatus{}, err
}
if op.SuccessCommand != nil {
err := func() error {
ctx := ctx
timeout := cke.DefaultRepairSuccessCommandTimeoutSeconds
if op.SuccessCommandTimeout != nil {
timeout = *op.SuccessCommandTimeout
}
if timeout != 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Second*time.Duration(timeout))
defer cancel()
}
args := append(op.SuccessCommand[1:], entry.Address)
command := well.CommandContext(ctx, op.SuccessCommand[0], args...)
return command.Run()
}()
return cke.RepairQueueStatus{}, err
}
}
}

Expand Down

0 comments on commit b6f5e1f

Please sign in to comment.