ScaleCondition is a closure around Scale that facilitates retries via util.wait
(r Scaler, precondition *ScalePrecondition, namespace, name string, count uint, updatedResourceVersion *string, actualSize *int32, gvr schema.GroupVersionResource, dryRun bool)
| 82 | |
| 83 | // ScaleCondition is a closure around Scale that facilitates retries via util.wait |
| 84 | func ScaleCondition(r Scaler, precondition *ScalePrecondition, namespace, name string, count uint, updatedResourceVersion *string, actualSize *int32, gvr schema.GroupVersionResource, dryRun bool) wait.ConditionWithContextFunc { |
| 85 | return func(context.Context) (bool, error) { |
| 86 | rv, size, err := r.ScaleSimple(namespace, name, precondition, count, gvr, dryRun) |
| 87 | if updatedResourceVersion != nil { |
| 88 | *updatedResourceVersion = rv |
| 89 | } |
| 90 | if actualSize != nil { |
| 91 | *actualSize = size |
| 92 | } |
| 93 | // Retry only on update conflicts. |
| 94 | if apierrors.IsConflict(err) { |
| 95 | return false, nil |
| 96 | } |
| 97 | if err != nil { |
| 98 | return false, err |
| 99 | } |
| 100 | return true, nil |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // validateGeneric ensures that the preconditions match. Returns nil if they are valid, otherwise an error |
| 105 | func (precondition *ScalePrecondition) validate(scale *autoscalingv1.Scale) error { |
searching dependent graphs…