Skip to content

Commit

Permalink
[Development][Change] Change ctrl time for errors (#369)
Browse files Browse the repository at this point in the history
* Added logic for updating followers replicas

Signed-off-by: iamabhishek-dubey <[email protected]>

* Fixed ctrl time for errors
  • Loading branch information
iamabhishek-dubey authored Oct 30, 2022
1 parent 3a8cbfd commit 16a02c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
20 changes: 10 additions & 10 deletions controllers/rediscluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,54 +63,54 @@ func (r *RedisClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request
totalReplicas := leaderReplicas + followerReplicas

if err := k8sutils.HandleRedisClusterFinalizer(instance, r.Client); err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}

if err := k8sutils.AddRedisClusterFinalizer(instance, r.Client); err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}

err = k8sutils.CreateRedisLeader(instance)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}
if leaderReplicas != 0 {
err = k8sutils.CreateRedisLeaderService(instance)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}
}

err = k8sutils.ReconcileRedisPodDisruptionBudget(instance, "leader", instance.Spec.RedisLeader.PodDisruptionBudget)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}

redisLeaderInfo, err := k8sutils.GetStatefulSet(instance.Namespace, instance.ObjectMeta.Name+"-leader")
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}

if int32(redisLeaderInfo.Status.ReadyReplicas) == leaderReplicas {
err = k8sutils.CreateRedisFollower(instance)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}
// if we have followers create their service.
if followerReplicas != 0 {
err = k8sutils.CreateRedisFollowerService(instance)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}
}
err = k8sutils.ReconcileRedisPodDisruptionBudget(instance, "follower", instance.Spec.RedisFollower.PodDisruptionBudget)
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}
}
redisFollowerInfo, err := k8sutils.GetStatefulSet(instance.Namespace, instance.ObjectMeta.Name+"-follower")
if err != nil {
return ctrl.Result{}, err
return ctrl.Result{RequeueAfter: time.Second * 60}, err
}

if leaderReplicas == 0 {
Expand Down
11 changes: 10 additions & 1 deletion example/eks-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ metadata:
name: operator-testing
region: us-west-2
version: "1.22"
nodeGroups:
managedNodeGroups:
- name: ng-1
instanceType: t3a.medium
desiredCapacity: 3
volumeSize: 30
ssh:
allow: true
volumeType: gp3
kubernetesNetworkConfig:
ipFamily: IPv4
# ipFamily: IPv6
addons:
- name: vpc-cni
- name: coredns
- name: kube-proxy
iam:
withOIDC: true

0 comments on commit 16a02c3

Please sign in to comment.