Skip to content

Commit

Permalink
Substract ignored targets from targets count (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
Devatoria authored Mar 4, 2021
1 parent ba1e4e5 commit 2421f02
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/disruption_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,12 @@ func (r *DisruptionReconciler) selectTargets(instance *chaosv1beta1.Disruption)
targetsCount = instance.Spec.Count.IntValue()
}

// subtract already ignored targets from the targets count to avoid going through all the
// eligible targets with a disruption having a chaos pod failing everytime
// so a disruption having a count of 1 with an already ignored target (because the chaos pod has been removed)
// won't pick up another one
targetsCount -= len(instance.Status.IgnoredTargets)

// computed count should not be 0 unless the given count was not expected
if targetsCount == 0 {
return fmt.Errorf("parsing error, either incorrectly formatted percentage or incorrectly formatted integer: %s\n%w", instance.Spec.Count.String(), err)
Expand Down

0 comments on commit 2421f02

Please sign in to comment.