Skip to content

Commit

Permalink
added maxUnhealthyCount setting to check_clients_are_healthy task
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Mar 18, 2024
1 parent cab4f93 commit eddc770
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/coordinator/tasks/check_clients_are_healthy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ The `check_clients_are_healthy` task is designed to ensure the health of specifi
- **`minClientCount`**:\
The minimum number of clients that must match the `clientNamePatterns` and pass the health checks for the task to succeed. A value of 0 indicates that all matching clients need to pass the health check. Use this to set a threshold for the number of healthy clients required by your test scenario.

- **`maxUnhealthyCount`**:\
Specifies the maximum number of unhealthy clients allowed before the task fails. A value of 0 means that any unhealthy client will cause the task to fail, enforcing strict health criteria.

### Defaults

These are the default settings for the `check_clients_are_healthy` task:
Expand All @@ -36,4 +39,5 @@ These are the default settings for the `check_clients_are_healthy` task:
skipExecutionCheck: false
expectUnhealthy: false
minClientCount: 0
maxUnhealthyCount: -1
```
4 changes: 3 additions & 1 deletion pkg/coordinator/tasks/check_clients_are_healthy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ type Config struct {
SkipExecutionCheck bool `yaml:"skipExecutionCheck" json:"skipExecutionCheck"`
ExpectUnhealthy bool `yaml:"expectUnhealthy" json:"expectUnhealthy"`
MinClientCount int `yaml:"minClientCount" json:"minClientCount"`
MaxUnhealthyCount int `yaml:"maxUnhealthyCount" json:"maxUnhealthyCount"`
}

func DefaultConfig() Config {
return Config{
PollInterval: human.Duration{Duration: 5 * time.Second},
PollInterval: human.Duration{Duration: 5 * time.Second},
MaxUnhealthyCount: -1,
}
}

Expand Down
7 changes: 5 additions & 2 deletions pkg/coordinator/tasks/check_clients_are_healthy/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ func (t *Task) processCheck() {

t.logger.Infof("Check result: %v, Failed Clients: %v", resultPass, failedClients)

if resultPass {
switch {
case t.config.MaxUnhealthyCount > -1 && len(failedClients) >= t.config.MaxUnhealthyCount:
t.ctx.SetResult(types.TaskResultFailure)
case resultPass:
t.ctx.SetResult(types.TaskResultSuccess)
} else {
default:
t.ctx.SetResult(types.TaskResultNone)
}
}
Expand Down

0 comments on commit eddc770

Please sign in to comment.