Skip to content

Commit

Permalink
fix for review
Browse files Browse the repository at this point in the history
  • Loading branch information
YZ775 committed Dec 9, 2024
1 parent ab06270 commit c7b8888
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The repair configurations control the [repair functionality](repair.md).
| `repair_steps` | true | `[]RepairStep` | Sequences of [repair steps](#repairstep). |
| `health_check_command` | true | array | A command to check repaired machine's health. List of strings. |
| `command_timeout_seconds` | false | \*int | Deadline for health retrieval. Zero means infinity. Default: 30 |
| `success_command` | false | array | A command executed when repair is succeeded. List of strings. |
| `success_command` | false | array | A command executed when repair succeeded. List of strings. |
| `success_command_timeout` | false | \*int | Deadline for execution of succcess_command. Zero means infinity. Default: 30 |

##### RepairStep
Expand Down
6 changes: 3 additions & 3 deletions docs/repair.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ CKE decides to execute a repair operations if its `operation` matches `OPERATION
When CKE executes the check command, it appends the IP address of the target machine to the command.
The command should return a string `true` if it evaluates the machine as healthy.

`success_command` and its timeout are used when all of the repair steps are successfully finished.
`success_command` and its timeout are used when the machine is evaluated as healthy and the repair operation finishes successfully.
When CKE executes the success command, it appends the IP address of the target machine to the command.
If the repair is failed, the command is not executed.
If the repair operation has failed, the command is not executed.
If the `success_command` fails, CKE changes the status of the queue entry to `failed`.
Users can use this command if they want to execute a command after the repair steps.
Users can use this command if they want to execute a command as a post-processing of repair operation.

### Repair steps

Expand Down
4 changes: 2 additions & 2 deletions mtest/repair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func testRepairOperations() {
waitRepairEmpty(cluster)

By("setting erroneous success command")
originalSuceessCommand := cluster.Repair.RepairProcedures[0].RepairOperations[0].SuccessCommand
originalSuccessCommand := cluster.Repair.RepairProcedures[0].RepairOperations[0].SuccessCommand
cluster.Repair.RepairProcedures[0].RepairOperations[0].SuccessCommand = []string{"false"}
_, err := ckecliClusterSet(cluster)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -140,7 +140,7 @@ func testRepairOperations() {
waitRepairEmpty(cluster)

By("restoring success command")
cluster.Repair.RepairProcedures[0].RepairOperations[0].SuccessCommand = originalSuceessCommand
cluster.Repair.RepairProcedures[0].RepairOperations[0].SuccessCommand = originalSuccessCommand
_, err = ckecliClusterSet(cluster)
Expect(err).NotTo(HaveOccurred())
time.Sleep(time.Second * 3)
Expand Down
30 changes: 15 additions & 15 deletions op/repair_finish.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ func repairFinish(ctx context.Context, inf cke.Infrastructure, entry *cke.Repair
if err != nil {
return err
}
if op.SuccessCommand != nil {
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()
if op.SuccessCommand == nil {
return nil
}
return nil
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()
}()
if err != nil {
entry.Status = cke.RepairStatusFailed
Expand Down

0 comments on commit c7b8888

Please sign in to comment.