Skip to content

Commit 92c3024

Browse files
committed
add validation for autoscale
Signed-off-by: Sergei Semenchuk <pdp.eleven11@gmail.com>
1 parent 5600157 commit 92c3024

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

apis/v1alpha1/opentelemetrycollector_webhook.go

+15
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,20 @@ func (r *OpenTelemetryCollector) validateCRDSpec() error {
109109
}
110110
}
111111

112+
// validate autoscale with horizontal pod autoscaler
113+
if r.Spec.Autoscale != nil && *r.Spec.Autoscale {
114+
if r.Spec.Replicas != nil {
115+
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, replicas should be nil")
116+
}
117+
118+
if r.Spec.MaxReplicas == nil || *r.Spec.MaxReplicas < int32(1) {
119+
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, maaxReplicas should be defined and more than one")
120+
}
121+
122+
if r.Spec.MinReplicas != nil && *r.Spec.MinReplicas > *r.Spec.MaxReplicas {
123+
return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, minReplicas could be more than maxReplicas")
124+
}
125+
}
126+
112127
return nil
113128
}

0 commit comments

Comments
 (0)