Skip to content

Commit 8daa115

Browse files
author
jmccormick2001
committed
add check to make sure replica-count is greater than 0 if autofail is specified
1 parent a5a3abe commit 8daa115

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,6 @@ func CreateCluster(request *msgs.CreateClusterRequest, ns string) msgs.CreateClu
554554
if request.BadgerFlag {
555555
userLabelsMap[util.LABEL_BADGER] = "true"
556556
}
557-
//if request.AutofailFlag || apiserver.Pgo.Cluster.Autofail {
558-
//userLabelsMap[util.LABEL_AUTOFAIL] = "true"
559-
//}
560557
if request.ServiceType != "" {
561558
if request.ServiceType != config.DEFAULT_SERVICE_TYPE && request.ServiceType != config.LOAD_BALANCER_SERVICE_TYPE && request.ServiceType != config.NODEPORT_SERVICE_TYPE {
562559
resp.Status.Code = msgs.Error
@@ -694,6 +691,16 @@ func CreateCluster(request *msgs.CreateClusterRequest, ns string) msgs.CreateClu
694691

695692
// Create an instance of our CRD
696693
newInstance := getClusterParams(request, clusterName, userLabelsMap, ns)
694+
695+
//verify that for autofail clusters we have a replica requested
696+
if newInstance.Spec.Replicas == "0" {
697+
if request.AutofailFlag || apiserver.Pgo.Cluster.Autofail {
698+
resp.Status.Code = msgs.Error
699+
resp.Status.Msg = "replica-count of 1 or more is required when autofail is specified"
700+
return resp
701+
}
702+
}
703+
697704
validateConfigPolicies(clusterName, request.Policies, ns)
698705

699706
t := time.Now()

0 commit comments

Comments
 (0)