Skip to content

Commit

Permalink
Add reconcile request after updating the Datacenter
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm committed Jul 23, 2024
1 parent 5e40fb1 commit 1bddd1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions controllers/k8ssandra/datacenters.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ func (r *K8ssandraClusterReconciler) reconcileDatacenters(ctx context.Context, k
dcLogger.Error(err, "Failed to update datacenter")
return result.Error(err), actualDcs
}

return result.RequeueSoon(r.DefaultDelay), actualDcs
}

if actualDc.Spec.Stopped {
Expand Down
6 changes: 4 additions & 2 deletions controllers/k8ssandra/k8ssandracluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package k8ssandra

import (
"context"
"fmt"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -156,7 +157,7 @@ func (r *K8ssandraClusterReconciler) reconcile(ctx context.Context, kc *api.K8ss
return recResult.Output()
}

if res := updateStatus(ctx, r.Client, kc); res.Completed() {
if res := updateStatus(ctx, r.Client, kc, kcLogger); res.Completed() {
return res.Output()
}

Expand Down Expand Up @@ -185,7 +186,7 @@ func (r *K8ssandraClusterReconciler) afterCassandraReconciled(ctx context.Contex
return result.Continue()
}

func updateStatus(ctx context.Context, r client.Client, kc *api.K8ssandraCluster) result.ReconcileResult {
func updateStatus(ctx context.Context, r client.Client, kc *api.K8ssandraCluster, kcLogger logr.Logger) result.ReconcileResult {
if AllowUpdate(kc) {
if metav1.HasAnnotation(kc.ObjectMeta, api.AutomatedUpdateAnnotation) {
if kc.Annotations[api.AutomatedUpdateAnnotation] == string(api.AllowUpdateOnce) {
Expand All @@ -198,6 +199,7 @@ func updateStatus(ctx context.Context, r client.Client, kc *api.K8ssandraCluster
kc.Status.SetConditionStatus(api.ClusterRequiresUpdate, corev1.ConditionFalse)
}

kcLogger.Info(fmt.Sprintf("Updating observed generation to %d", kc.Generation))
kc.Status.ObservedGeneration = kc.Generation
if err := r.Status().Update(ctx, kc); err != nil {
return result.Error(err)
Expand Down

0 comments on commit 1bddd1c

Please sign in to comment.