From 3d0fb73d766845f003e8e537a88698314242d055 Mon Sep 17 00:00:00 2001 From: Sylvain Laperche Date: Fri, 3 Jul 2020 02:17:29 +0200 Subject: [PATCH] storage-operator: do not always update LastUpdateTime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some case, this trigger an infinite reconciliation loop… Refs: #2421 Signed-off-by: Sylvain Laperche --- storage-operator/pkg/apis/storage/v1alpha1/volume_types.go | 3 ++- .../pkg/apis/storage/v1alpha1/volume_types_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/storage-operator/pkg/apis/storage/v1alpha1/volume_types.go b/storage-operator/pkg/apis/storage/v1alpha1/volume_types.go index 9766281e2a..6592b5274b 100644 --- a/storage-operator/pkg/apis/storage/v1alpha1/volume_types.go +++ b/storage-operator/pkg/apis/storage/v1alpha1/volume_types.go @@ -175,9 +175,10 @@ func (self *Volume) SetCondition( for idx, cond := range self.Status.Conditions { if cond.Type == kind { - // Don't update LastTransitionTime if status hasn't changed. + // Don't update timestamps if status hasn't changed. if cond.Status == condition.Status { condition.LastTransitionTime = cond.LastTransitionTime + condition.LastUpdateTime = cond.LastUpdateTime } self.Status.Conditions[idx] = condition return diff --git a/storage-operator/pkg/apis/storage/v1alpha1/volume_types_test.go b/storage-operator/pkg/apis/storage/v1alpha1/volume_types_test.go index c6ad76a036..4af21a0ac7 100644 --- a/storage-operator/pkg/apis/storage/v1alpha1/volume_types_test.go +++ b/storage-operator/pkg/apis/storage/v1alpha1/volume_types_test.go @@ -81,13 +81,14 @@ func TestGetCondition(t *testing.T) { if tc.transitionExpected { assert.True(t, now.Before(&condition.LastTransitionTime)) + assert.True(t, now.Before(&condition.LastUpdateTime)) } else { assert.Equal(t, now, condition.LastTransitionTime) + assert.Equal(t, now, condition.LastUpdateTime) } assert.Equal(t, tc.condType, condition.Type) assert.Equal(t, tc.condStatus, condition.Status) - assert.True(t, now.Before(&condition.LastUpdateTime)) assert.Equal(t, ConditionReason("Baz"), condition.Reason) assert.Equal(t, "Qux", condition.Message) })