Skip to content

Commit

Permalink
check replicas before use it
Browse files Browse the repository at this point in the history
Signed-off-by: Gang Liu <gang.liu@daocloud.io>
  • Loading branch information
izturn committed Nov 20, 2022
1 parent edf13ba commit e0b0c12
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/provisioner/controller/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
}

if gatewayClassParams.Spec.Contour != nil {
contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas // nolint:staticcheck
if gatewayClassParams.Spec.Contour.Replicas > 0 { // nolint:staticcheck
contourModel.Spec.ContourReplicas = gatewayClassParams.Spec.Contour.Replicas // nolint:staticcheck
}

// Deployment replicas
if gatewayClassParams.Spec.Contour.Deployment != nil && gatewayClassParams.Spec.Contour.Deployment.Replicas > 0 {
Expand Down Expand Up @@ -280,7 +282,9 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

// Deployment replicas
if gatewayClassParams.Spec.Envoy.WorkloadType == contour_api_v1alpha1.WorkloadTypeDeployment {
contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas // nolint:staticcheck
if gatewayClassParams.Spec.Envoy.Replicas > 0 { // nolint:staticcheck
contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Replicas // nolint:staticcheck
}

if gatewayClassParams.Spec.Envoy.Deployment != nil && gatewayClassParams.Spec.Envoy.Deployment.Replicas > 0 {
contourModel.Spec.EnvoyReplicas = gatewayClassParams.Spec.Envoy.Deployment.Replicas
Expand Down

0 comments on commit e0b0c12

Please sign in to comment.