Skip to content

Commit

Permalink
NIT: VolumeController: don't overwrite err by lastErr
Browse files Browse the repository at this point in the history
When err is non-nil and lastErr is nil, if we blindly overwrite
err by lastErr, we will not requeue the volume CR. This make us
depend on the 30s resync

longhorn-6682

Signed-off-by: Phan Le <phan.le@suse.com>
(cherry picked from commit 428281c)
  • Loading branch information
PhanLe1010 authored and David Ko committed Sep 29, 2023
1 parent 4ba047e commit 540b793
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions controller/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,15 @@ func (c *VolumeController) syncVolume(key string) (err error) {
// Make sure that we don't update condition's LastTransitionTime if the condition's values hasn't changed
handleConditionLastTransitionTime(&existingVolume.Status, &volume.Status)
if !reflect.DeepEqual(existingVolume.Status, volume.Status) {
// reuse err
_, err = c.ds.UpdateVolumeStatus(volume)
_, lastErr = c.ds.UpdateVolumeStatus(volume)
}
}
if err == nil {
err = lastErr
}
// requeue if it's conflict
if apierrors.IsConflict(errors.Cause(err)) || apierrors.IsConflict(errors.Cause(lastErr)) {
log.Debugf("Requeue volume due to error %v or %v", err, lastErr)
if apierrors.IsConflict(errors.Cause(err)) {
log.Debugf("Requeue volume due to error %v", err)
c.enqueueVolume(volume)
err = nil
}
Expand Down

0 comments on commit 540b793

Please sign in to comment.