Merge pull request #15885 from rook/mergify/bp/release-1.17/pr-15884
core: improve reporting for reconcile requeue cases (backport #15884)
This commit is contained in:
4 files changed
+13
-3
No files matched your search
@@ -5306,6 +5306,9 @@ deletion.</p>
|
||||
</tr><tr><td><p>"ReconcileFailed"</p></td>
|
||||
<td><p>ReconcileFailed represents when a resource reconciliation failed.</p>
|
||||
</td>
|
||||
</tr><tr><td><p>"ReconcileRequeuing"</p></td>
|
||||
<td><p>ReconcileRequeuing represents when a resource reconciliation requeue.</p>
|
||||
</td>
|
||||
</tr><tr><td><p>"ReconcileStarted"</p></td>
|
||||
<td><p>ReconcileStarted represents when a resource reconciliation started.</p>
|
||||
</td>
|
||||
|
||||
@@ -559,7 +559,8 @@ const (
|
||||
ReconcileFailed ConditionReason = "ReconcileFailed"
|
||||
// ReconcileStarted represents when a resource reconciliation started.
|
||||
ReconcileStarted ConditionReason = "ReconcileStarted"
|
||||
|
||||
// ReconcileRequeuing represents when a resource reconciliation requeue.
|
||||
ReconcileRequeuing ConditionReason = "ReconcileRequeuing"
|
||||
// DeletingReason represents when Rook has detected a resource object should be deleted.
|
||||
DeletingReason ConditionReason = "Deleting"
|
||||
// ObjectHasDependentsReason represents when a resource object has dependents that are blocking
|
||||
|
||||
@@ -156,6 +156,10 @@ func ReportReconcileResult(
|
||||
// intent.
|
||||
return reconcileResponse, nil
|
||||
}
|
||||
} else if reconcileResponse.Requeue {
|
||||
msg := fmt.Sprintf("requeuing %s %q", kind, nsName)
|
||||
logger.Debug(msg)
|
||||
recorder.Event(objCopy, corev1.EventTypeNormal, string(cephv1.ReconcileRequeuing), msg)
|
||||
} else {
|
||||
successMsg := fmt.Sprintf("successfully configured %s %q", kind, nsName)
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ func TestReportReconcileResult(t *testing.T) {
|
||||
|
||||
successMsg := `successfully configured CephCluster "rook-ceph/my-cluster"`
|
||||
successEvent := `Normal ReconcileSucceeded ` + successMsg
|
||||
requeueMsg := `requeuing CephCluster "rook-ceph/my-cluster"`
|
||||
requeueEvent := `Normal ReconcileRequeuing ` + requeueMsg
|
||||
|
||||
fakeErr := errors.New("fake-err")
|
||||
errorMsg := `failed to reconcile CephCluster "rook-ceph/my-cluster". fake-err`
|
||||
@@ -131,9 +133,9 @@ func TestReportReconcileResult(t *testing.T) {
|
||||
cephCluster, inResult, nil)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, inResult, result)
|
||||
assert.Equal(t, successMsg, strings.TrimSpace(logBuf.String()))
|
||||
assert.Equal(t, requeueMsg, strings.TrimSpace(logBuf.String()))
|
||||
assert.Len(t, recorder.Events, 1)
|
||||
assert.Equal(t, successEvent, <-recorder.Events)
|
||||
assert.Equal(t, requeueEvent, <-recorder.Events)
|
||||
})
|
||||
|
||||
t.Run("failed reconcile with requeue", func(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user