Skip to content

Commit

Permalink
Maintain the previous state machine of share manager CR
Browse files Browse the repository at this point in the history
1. Switch the share manager controller sync loop to sync volume first
   then sync share manager pod after
2. Skip calling gprc to mount the share manager volume if the share
   manager is currently delinquent. This helps to avoid the 20s delay when
   attemping to make the grpc call to dead share-manager pod

longhorn-6205

Signed-off-by: Phan Le <phan.le@suse.com>
  • Loading branch information
PhanLe1010 authored and mergify[bot] committed Jul 25, 2024
1 parent 8529b65 commit a999bb9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions controller/share_manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,11 @@ func (c *ShareManagerController) syncShareManager(key string) (err error) {
}
}()

if err = c.syncShareManagerPod(sm); err != nil {
if err = c.syncShareManagerVolume(sm); err != nil {
return err
}

if err = c.syncShareManagerVolume(sm); err != nil {
if err = c.syncShareManagerPod(sm); err != nil {
return err
}

Expand Down Expand Up @@ -638,6 +638,11 @@ func (c *ShareManagerController) syncShareManagerVolume(sm *longhorn.ShareManage
}
}()

isDelinquent, _, err := c.ds.IsRWXVolumeDelinquent(sm.Name)
if err != nil {
return err
}

if !c.isShareManagerRequiredForVolume(sm, volume, va) {
c.unmountShareManagerVolume(sm)

Expand All @@ -647,7 +652,7 @@ func (c *ShareManagerController) syncShareManagerVolume(sm *longhorn.ShareManage
sm.Status.State = longhorn.ShareManagerStateStopping
}
return nil
} else if sm.Status.State == longhorn.ShareManagerStateRunning {
} else if sm.Status.State == longhorn.ShareManagerStateRunning && !isDelinquent {
err := c.mountShareManagerVolume(sm)
if err != nil {
log.WithError(err).Error("Failed to mount share manager volume")
Expand Down

0 comments on commit a999bb9

Please sign in to comment.