Skip to content

Commit

Permalink
storage-operator: do not always update LastUpdateTime
Browse files Browse the repository at this point in the history
In some case, this trigger an infinite reconciliation loop…

Refs: #2421
Signed-off-by: Sylvain Laperche <[email protected]>
  • Loading branch information
slaperche-scality committed Jul 6, 2020
1 parent f0afb57 commit b0eca3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion storage-operator/pkg/apis/storage/v1alpha1/volume_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit b0eca3d

Please sign in to comment.