Skip to content

Commit

Permalink
Move datacenterCondition reset for ResizingVolumes
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm committed Jun 28, 2024
1 parent be423ad commit 19a5a80
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
16 changes: 8 additions & 8 deletions pkg/reconciliation/reconcile_racks.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ func (rc *ReconciliationContext) CheckPVCResizing() result.ReconcileResult {
}
}

dcPatch := client.MergeFrom(rc.Datacenter.DeepCopy())
if updated := rc.setCondition(api.NewDatacenterCondition(api.DatacenterResizingVolumes, corev1.ConditionFalse)); updated {
if err := rc.Client.Status().Patch(rc.Ctx, rc.Datacenter, dcPatch); err != nil {
rc.ReqLogger.Error(err, "error patching datacenter status for updating")
return result.Error(err)
}
}

return result.Continue()
}

Expand Down Expand Up @@ -292,14 +300,6 @@ func (rc *ReconciliationContext) CheckVolumeClaimSizes(statefulSet, desiredSts *
}
}

dcPatch := client.MergeFrom(rc.Datacenter.DeepCopy())
if updated := rc.setCondition(api.NewDatacenterCondition(api.DatacenterResizingVolumes, corev1.ConditionFalse)); updated {
if err := rc.Client.Status().Patch(rc.Ctx, rc.Datacenter, dcPatch); err != nil {
rc.ReqLogger.Error(err, "error patching datacenter status for updating")
return result.Error(err)
}
}

return result.Continue()
}

Expand Down
16 changes: 15 additions & 1 deletion pkg/reconciliation/reconcile_racks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ func TestVolumeClaimSizesExpansion(t *testing.T) {
require.Equal(corev1.ConditionFalse, cond.Status)
}

func TestPVCResizingCheck(t *testing.T) {
func TestCheckPVCResizing(t *testing.T) {
rc, _, cleanupMockScr := setupTest()
defer cleanupMockScr()
require := require.New(t)
Expand Down Expand Up @@ -2288,6 +2288,20 @@ func TestPVCResizingCheck(t *testing.T) {
}}
require.NoError(rc.Client.Status().Update(rc.Ctx, pvc))

// Verify datacenter status resizing is removed if nothing is being resized anymore
rc.Datacenter.SetCondition(api.DatacenterCondition{
Status: corev1.ConditionTrue,
Type: api.DatacenterResizingVolumes,
})
require.NoError(rc.Client.Status().Update(rc.Ctx, rc.Datacenter))

res = rc.CheckPVCResizing()
require.Equal(result.Continue(), res, "No resizing in progress, we should simply continue")

cond, found := rc.Datacenter.GetCondition(api.DatacenterResizingVolumes)
require.True(found)
require.Equal(corev1.ConditionFalse, cond.Status)

// Create another PVC, not related to our Datacenter and check it is ignored
pvc2 := &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 19a5a80

Please sign in to comment.