Operator SDK controller failed to update Custom Resource status
You need get the object before update, that happens because you have old version of the object when you try to update.
EDIT:
podSet := &appv1alpha1.PodSet{}err := r.Get(context.Background(), req.NamespacedName, podSet)if err != nil { return reconcile.Result{}, err}// Update the status if necessarystatus := appv1alpha1.PodSetStatus{ PodNames: availableNames, AvailableReplicas: numAvailable,}if !reflect.DeepEqual(podSet.Status, status) { podSet.Status = status err = r.Status().Update(context.Background(), podSet) if err != nil { r.Log.Error(err, "Failed to update PodSet status") return reconcile.Result{}, err }}
you have to bring the latest version of the object from kubernetes to make sure you have the latest version of it