Merge pull request #8237 from travisn/retry-after-cancel

ceph: Retry reconcile immediately after cancellation
This commit is contained in:
Travis Nielsen
2021-07-02 10:11:24 -06:00
committed by GitHub
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -21,6 +21,7 @@ import (
"context"
"fmt"
"os"
"strings"
"sync"
"time"
@@ -224,6 +225,10 @@ func add(mgr manager.Manager, r reconcile.Reconciler, context *clusterd.Context)
func (r *ReconcileCephCluster) Reconcile(context context.Context, request reconcile.Request) (reconcile.Result, error) {
// workaround because the rook logging mechanism is not compatible with the controller-runtime logging interface
reconcileResponse, cephCluster, err := r.reconcile(request)
if err != nil && strings.Contains(err.Error(), opcontroller.CancellingOrchestrationMessage) {
logger.Infof("Cluster update requested. %s", opcontroller.CancellingOrchestrationMessage)
return opcontroller.ImmediateRetryResultNoBackoff, nil
}
return reporting.ReportReconcileResult(logger, r.clusterController.recorder,
cephCluster, reconcileResponse, err)
@@ -43,12 +43,19 @@ const (
// OperatorNotInitializedMessage is the message we print when the Operator is not ready to reconcile, typically the ceph.conf has not been generated yet
OperatorNotInitializedMessage = "skipping reconcile since operator is still initializing"
// CancellingOrchestrationMessage is the message to indicate a reconcile was cancelled
CancellingOrchestrationMessage = "CANCELLING CURRENT ORCHESTRATION"
)
var (
// ImmediateRetryResult Return this for a immediate retry of the reconciliation loop with the same request object.
ImmediateRetryResult = reconcile.Result{Requeue: true}
// ImmediateRetryResultNoBackoff Return this for a immediate retry of the reconciliation loop with the same request object.
// Override the exponential backoff behavior by setting the RequeueAfter time explicitly.
ImmediateRetryResultNoBackoff = reconcile.Result{Requeue: true, RequeueAfter: time.Second}
// WaitForRequeueIfCephClusterNotReady waits for the CephCluster to be ready
WaitForRequeueIfCephClusterNotReady = reconcile.Result{Requeue: true, RequeueAfter: 10 * time.Second}
@@ -80,7 +87,7 @@ func CheckForCancelledOrchestration(context *clusterd.Context) error {
// Check whether we need to cancel the orchestration
if context.RequestCancelOrchestration.IsSet() {
return errors.New("CANCELLING CURRENT ORCHESTRATION")
return errors.New(CancellingOrchestrationMessage)
}
return nil