Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch status in reconcile instead of update #89

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions operator/internal/controller/opsCRD.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

Expand Down Expand Up @@ -48,11 +49,14 @@ func (r *ElastiServiceReconciler) updateCRDStatus(ctx context.Context, crdNamesp
r.Logger.Error("Failed to get ElastiService for status update", zap.String("es", crdNamespacedName.String()), zap.Error(err))
return fmt.Errorf("failed to get elastiService for status update")
}
original := es.DeepCopy()

es.Status.LastReconciledTime = metav1.Now()
es.Status.Mode = mode
if err = r.Status().Update(ctx, es); err != nil {
r.Logger.Error("Failed to update status", zap.String("es", crdNamespacedName.String()), zap.Error(err))
return fmt.Errorf("failed to update CRD status")

if err = r.Status().Patch(ctx, es, client.MergeFrom(original)); err != nil {
r.Logger.Error("Failed to patch status", zap.String("es", crdNamespacedName.String()), zap.Error(err))
return fmt.Errorf("failed to patch CRD status")
}

r.Logger.Info("CRD Status updated successfully")
Expand Down
Loading