Skip to content

Commit 248ee3c

Browse files
authored
fix: Rolling update pod of Redis HA Proxy are being in pending state when HA enabled cluster has Only 3 worker nodes (#1933)
* fix: redis ha proxy rolling update pod in pending state Signed-off-by: akhil nittala <[email protected]> * fix: redis ha proxy rolling update pod in pending state Signed-off-by: akhil nittala <[email protected]> * fix: redis ha proxy rolling update pod in pending state Signed-off-by: akhil nittala <[email protected]> * fix: redis ha proxy rolling update pod in pending state Signed-off-by: akhil nittala <[email protected]> --------- Signed-off-by: akhil nittala <[email protected]>
1 parent 9cbde44 commit 248ee3c

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

controllers/argocd/deployment.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,12 @@ func (r *ReconcileArgoCD) reconcileRedisDeployment(cr *argoproj.ArgoCD, useTLS b
610610
// reconcileRedisHAProxyDeployment will ensure the Deployment resource is present for the Redis HA Proxy component.
611611
func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) error {
612612
deploy := newDeploymentWithSuffix("redis-ha-haproxy", "redis", cr)
613-
613+
deploy.Spec.Strategy = appsv1.DeploymentStrategy{
614+
Type: appsv1.RollingUpdateDeploymentStrategyType,
615+
RollingUpdate: &appsv1.RollingUpdateDeployment{
616+
MaxSurge: &intstr.IntOrString{IntVal: 0},
617+
},
618+
}
614619
var redisEnv = append(proxyEnvVars(), corev1.EnvVar{
615620
Name: "AUTH",
616621
ValueFrom: &corev1.EnvVarSource{
@@ -885,6 +890,14 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
885890
explanation += "pod security context"
886891
changed = true
887892
}
893+
if !reflect.DeepEqual(deploy.Spec.Strategy, existing.Spec.Strategy) {
894+
existing.Spec.Strategy = deploy.Spec.Strategy
895+
if changed {
896+
explanation += ", "
897+
}
898+
explanation += "deployment strategy"
899+
changed = true
900+
}
888901
if changed {
889902
argoutil.LogResourceUpdate(log, existing, "updating", explanation)
890903
return r.Update(context.TODO(), existing)

controllers/argocd/deployment_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ func TestReconcileArgoCD_reconcileDeployments_HA_proxy_with_resources(t *testing
874874
}
875875
assert.Equal(t, deployment.Spec.Template.Spec.Containers[0].Resources, testResources)
876876
assert.Equal(t, deployment.Spec.Template.Spec.InitContainers[0].Resources, testResources)
877+
assert.Equal(t, deployment.Spec.Strategy.RollingUpdate.MaxSurge, &intstr.IntOrString{IntVal: 0})
877878

878879
// test resource is Updated on reconciliation
879880
newResources := corev1.ResourceRequirements{
@@ -899,6 +900,8 @@ func TestReconcileArgoCD_reconcileDeployments_HA_proxy_with_resources(t *testing
899900

900901
assert.Equal(t, deployment.Spec.Template.Spec.Containers[0].Resources, newResources)
901902
assert.Equal(t, deployment.Spec.Template.Spec.InitContainers[0].Resources, newResources)
903+
assert.Equal(t, deployment.Spec.Strategy.RollingUpdate.MaxSurge, &intstr.IntOrString{IntVal: 0})
904+
902905
}
903906
func TestReconcileArgoCD_reconcileRedisHAProxyDeployment_ModifyContainerSpec(t *testing.T) {
904907
logf.SetLogger(ZapLogger(true))

tests/ginkgo/sequential/1-020_validate_redis_ha_nonha_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
corev1 "k8s.io/api/core/v1"
3737
"k8s.io/apimachinery/pkg/api/resource"
3838
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
39+
"k8s.io/apimachinery/pkg/util/intstr"
3940
)
4041

4142
var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
@@ -158,6 +159,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
158159

159160
depl = &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: argoCDInstance.Name + "-redis-ha-haproxy", Namespace: ns.Name}}
160161
Eventually(depl, "2m", "5s").Should(deploymentFixture.HaveReadyReplicas(3))
162+
Expect(depl.Spec.Strategy.RollingUpdate.MaxSurge).To(Equal(&intstr.IntOrString{IntVal: 0}))
161163

162164
haProxyContainer := deploymentFixture.GetTemplateSpecContainerByName("haproxy", *depl)
163165

0 commit comments

Comments
 (0)