Skip to content
Closed
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
11 changes: 7 additions & 4 deletions pkg/controllers/clusterresourceplacement/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/prometheus/client_golang/prometheus"
corev1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -198,11 +199,13 @@ func (r *Reconciler) handleUpdate(ctx context.Context, crp *fleetv1beta1.Cluster
return ctrl.Result{}, err
}

if err := r.Client.Status().Update(ctx, crp); err != nil {
klog.ErrorS(err, "Failed to update the status", "clusterResourcePlacement", crpKObj)
return ctrl.Result{}, err
if !apiequality.Semantic.DeepEqual(oldCRP.Status, crp.Status) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortuantely, this is not safe as we don't reconcile on status change

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't quite understand:

  • who else do you expect will update the status of this resource and make it out of sync?
  • why can't a periodic resync that you already have course-correct drifts eventually?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Only the CRP controller changes its status but the reconcile is triggered by many other objects's status change.
  • if we rely on periodic resync to course-correct then it means the resync period needs to be reasonably short (say a min) which is something we agreed not a good practice.

We should still try to optimize the startup sequence though

if err := r.Client.Status().Update(ctx, crp); err != nil {
klog.ErrorS(err, "Failed to update the status", "clusterResourcePlacement", crpKObj)
return ctrl.Result{}, err
}
klog.V(2).InfoS("Updated the clusterResourcePlacement status", "clusterResourcePlacement", crpKObj)
}
klog.V(2).InfoS("Updated the clusterResourcePlacement status", "clusterResourcePlacement", crpKObj)

// We skip checking the last resource condition (available) because it will be covered by checking isRolloutCompleted func.
for i := condition.RolloutStartedCondition; i < condition.TotalCondition-1; i++ {
Expand Down
Loading