object: all CephBucketTopic reconcile errors set .status.phase

topic.reconcile() had a number of error triggered return statements
which did not update the CR's status to reflect a reconcile failure.

Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
This commit is contained in:
Joshua Hoblitt committed 2025-03-25 09:52:37 -07:00
1 parent 0cf7f40e70
commit dcf0a57d11
1 file changed
+2 -7
+2 -7
View File
@@ -89,6 +89,7 @@ func (r *ReconcileBucketTopic) Reconcile(context context.Context, request reconc
// workaround because the rook logging mechanism is not compatible with the controller-runtime logging interface
reconcileResponse, err := r.reconcile(request)
if err != nil {
r.updateStatus(k8sutil.ObservedGenerationNotAvailable, request.NamespacedName, k8sutil.ReconcileFailedStatus, nil)
logger.Errorf("failed to reconcile %v", err)
}
@@ -172,7 +173,6 @@ func (r *ReconcileBucketTopic) reconcile(request reconcile.Request) (reconcile.R
// validate the topic settings
err = cephBucketTopic.ValidateTopicSpec()
if err != nil {
r.updateStatus(k8sutil.ObservedGenerationNotAvailable, request.NamespacedName, k8sutil.ReconcileFailedStatus, nil)
return reconcile.Result{}, errors.Wrapf(err, "invalid CephBucketTopic %q", request.NamespacedName)
}
@@ -182,7 +182,7 @@ func (r *ReconcileBucketTopic) reconcile(request reconcile.Request) (reconcile.R
// create topic
topicARN, err := r.createCephBucketTopic(cephBucketTopic)
if err != nil {
return r.setFailedStatus(k8sutil.ObservedGenerationNotAvailable, request.NamespacedName, "failed to create topic for bucket notifications", err)
return reconcile.Result{}, errors.Wrapf(err, "topic creation failed for CephBucketTopic %q", request.NamespacedName)
}
// update ObservedGeneration in status a the end of reconcile
@@ -220,11 +220,6 @@ func (r *ReconcileBucketTopic) deleteCephBucketTopic(topic *cephv1.CephBucketTop
)
}
func (r *ReconcileBucketTopic) setFailedStatus(observedGeneration int64, name types.NamespacedName, errMessage string, err error) (reconcile.Result, error) {
r.updateStatus(observedGeneration, name, k8sutil.ReconcileFailedStatus, nil)
return reconcile.Result{}, errors.Wrapf(err, "%s", errMessage)
}
// updateStatus updates the topic with a given status
func (r *ReconcileBucketTopic) updateStatus(observedGeneration int64, nsName types.NamespacedName, status string, topicARN *string) {
topic := &cephv1.CephBucketTopic{}