func (r *ReconcileArgoCD) reconcileServerHPA(cr *argoprojv1a1.ArgoCD) error {
	hpa := newHorizontalPodAutoscalerWithSuffix("server", cr)
	if argoutil.IsObjectFound(r.client, cr.Namespace, hpa.Name, hpa) {
		if !cr.Spec.Server.Autoscale.Enabled {
			return r.client.Delete(context.TODO(), hpa) // HorizontalPodAutoscaler found but globally disabled, delete it.
		}
		return nil // HorizontalPodAutoscaler found and configured, nothing do to, move along...
	}

	if !cr.Spec.Server.Autoscale.Enabled {
		return nil // AutoScale not enabled, move along...
	}

	if cr.Spec.Server.Autoscale.HPA != nil {
		hpa.Spec = *cr.Spec.Server.Autoscale.HPA
	} else {
		hpa.Spec.MaxReplicas = 3

		var minrReplicas int32 = 1
		hpa.Spec.MinReplicas = &minrReplicas

		var tcup int32 = 50
		hpa.Spec.TargetCPUUtilizationPercentage = &tcup

		hpa.Spec.ScaleTargetRef = autoscaling.CrossVersionObjectReference{
			APIVersion: "apps/v1",
			Kind:       "Deployment",
			Name:       nameWithSuffix("server", cr),
		}
	}

	return r.client.Create(context.TODO(), hpa)
}
// reconcileServerHPA will ensure that the HorizontalPodAutoscaler is present for the Argo CD Server component.
reconcileServerHPA will ensure that the HorizontalPodAutoscaler is present for the Argo CD Server component.
// reconcileServerHPA will ensure that the HorizontalPodAutoscaler is present for the Argo CD Server component .
func (r *ReconcileArgoCD) reconcileServerHPA(cr *argoprojv1a1.ArgoCD) error {
	hpa := newHorizontalPodAutoscalerWithSuffix("server", cr)
	if argoutil.IsObjectFound(r.client, cr.Namespace, hpa.Name, hpa) {
		if !cr.Spec.Server.Autoscale.Enabled {
			return r.client.Delete(context.TODO(), hpa) 
		}
		return nil 
	}
	if !cr.Spec.Server.Autoscale.Enabled {
		return nil 
	}
	if cr.Spec.Server.Autoscale.HPA != nil {
		hpa.Spec = *cr.Spec.Server.Autoscale.HPA
	} else {
		hpa.Spec.MaxReplicas = 3
		var minrReplicas int32 = 1
		hpa.Spec.MinReplicas = &minrReplicas
		var tcup int32 = 50
		hpa.Spec.TargetCPUUtilizationPercentage = &tcup
		hpa.Spec.ScaleTargetRef = autoscaling.CrossVersionObjectReference{
			APIVersion: "apps/v1",
			Kind:       "Deployment",
			Name:       nameWithSuffix("server", cr),
		}
	}
	return r.client.Create(context.TODO(), hpa)
}
func ( r * ReconcileArgoCD ) reconcileServerHPA ( cr * argoprojv1a1 . ArgoCD ) error { hpa := newHorizontalPodAutoscalerWithSuffix ( " " , cr ) if argoutil . IsObjectFound ( r . client , cr . Namespace , hpa . Name , hpa ) { if ! cr . Spec . Server . Autoscale . Enabled { return r . client . Delete ( context . TODO ( ) , hpa ) } return nil } if ! cr . Spec . Server . Autoscale . Enabled { return nil } if cr . Spec . Server . Autoscale . HPA != nil { hpa . Spec = * cr . Spec . Server . Autoscale . HPA } else { hpa . Spec . MaxReplicas = 3 var minrReplicas int32 = 1 hpa . Spec . MinReplicas = & minrReplicas var tcup int32 = 50 hpa . Spec . TargetCPUUtilizationPercentage = & tcup hpa . Spec . ScaleTargetRef = autoscaling . CrossVersionObjectReference { APIVersion : " " , Kind : " " , Name : nameWithSuffix ( " " , cr ) , } } return r . client . Create ( context . TODO ( ) , hpa ) }
reconcileServerHPA will ensure that the HorizontalPodAutoscaler is present for the Argo CD Server component.
reconcileServerHPA will ensure that the HorizontalPodAutoscaler is present for the Argo CD Server component .
// HorizontalPodAutoscaler found but globally disabled, delete it. // HorizontalPodAutoscaler found and configured, nothing do to, move along... // AutoScale not enabled, move along...