Skip to content

Commit 5e69487

Browse files
committed
review: address comments
address coderabbit AI comments AI-attribution: AIA PAI Ce Hin R claude-4.6-opus-1M v1.0 Signed-off-by: Francesco Romani <fromani@redhat.com>
1 parent 399f7d5 commit 5e69487

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

internal/controller/numaresourcesoperator_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,9 @@ func (r *NUMAResourcesOperatorReconciler) applyObjects(ctx context.Context, inst
820820
defer klog.V(4).InfoS("Applyied objects", "count", len(objStates))
821821
for _, objState := range objStates {
822822
if objState.Error != nil {
823-
klog.Warningf("error loading object: %v", objState.Error)
823+
if !objState.IsNotFoundError() {
824+
return fmt.Errorf("failed to load object state for %s/%s: %w", objState.Desired.GetNamespace(), objState.Desired.GetName(), objState.Error)
825+
}
824826
}
825827
if objState.UpdateError != nil {
826828
return fmt.Errorf("failed to update (%s) %s/%s: %w", objState.Desired.GetObjectKind().GroupVersionKind(), objState.Desired.GetNamespace(), objState.Desired.GetName(), objState.UpdateError)
@@ -900,7 +902,7 @@ func shouldReplaceStep(current, candidate intreconcile.Step) bool {
900902
return true
901903
}
902904
if candidate.Ongoing() && current.Ongoing() {
903-
return candidate.Result.RequeueAfter < current.Result.RequeueAfter
905+
return candidate.Result.RequeueAfter > 0 && candidate.Result.RequeueAfter < current.Result.RequeueAfter
904906
}
905907
return false
906908
}

internal/controller/numaresourcesoperator_controller_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,19 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
22962296
Expect(progressingCond).ToNot(BeNil())
22972297
Expect(progressingCond.Status).To(Equal(metav1.ConditionTrue))
22982298

2299+
By("Verify pool1 DaemonSet does not exist yet")
2300+
mcp1DSKey := client.ObjectKey{
2301+
Name: objectnames.GetComponentName(nro.Name, mcp1.Name),
2302+
Namespace: testNamespace,
2303+
}
2304+
err = reconciler.Client.Get(ctx, mcp1DSKey, ds)
2305+
Expect(apierrors.IsNotFound(err)).To(BeTrue(), "unexpected error: %v", err)
2306+
2307+
By("Verify global Available condition is false")
2308+
availableCond := getConditionByType(nro.Status.Conditions, status.ConditionAvailable)
2309+
Expect(availableCond).ToNot(BeNil())
2310+
Expect(availableCond.Status).To(Equal(metav1.ConditionFalse))
2311+
22992312
By("Make pool1 ready and reconcile again")
23002313
Expect(reconciler.Client.Get(ctx, client.ObjectKeyFromObject(mcp1), mcp1)).To(Succeed())
23012314
ensureMCPIsReady(mcp1, nro.Name)
@@ -2304,7 +2317,7 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
23042317
Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: key})).ToNot(CauseRequeue())
23052318

23062319
By("Now both DaemonSets exist and status is Available")
2307-
mcp1DSKey := client.ObjectKey{
2320+
mcp1DSKey = client.ObjectKey{
23082321
Name: objectnames.GetComponentName(nro.Name, mcp1.Name),
23092322
Namespace: testNamespace,
23102323
}

internal/reconcile/step.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (rs Step) EarlyStop() bool {
4545

4646
// Ongoing returns true if the reconciliation is still ongoing/progressing
4747
func (rs Step) Ongoing() bool {
48-
return rs.Result.RequeueAfter > 0
48+
return rs.ConditionInfo.Type == status.ConditionProgressing
4949
}
5050

5151
// Failed returns true if the reconciliation was not succesfull

internal/reconcile/step_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ func TestStepOngoingIsOngoing(t *testing.T) {
4848
assert.False(t, st.Failed())
4949
}
5050

51+
func TestStepOngoingZeroDurationIsOngoing(t *testing.T) {
52+
st := StepOngoing(0)
53+
assert.True(t, st.Ongoing())
54+
assert.False(t, st.Done())
55+
}
56+
5157
func TestStepFailedIsFailed(t *testing.T) {
5258
st := StepFailed(errors.New("fake error"))
5359
assert.True(t, st.Failed())

0 commit comments

Comments
 (0)