From a999bb9fe4f648084031e390753ec7e5dd602fab Mon Sep 17 00:00:00 2001 From: Phan Le Date: Thu, 25 Jul 2024 14:52:39 -0700 Subject: [PATCH] Maintain the previous state machine of share manager CR 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 --- controller/share_manager_controller.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/controller/share_manager_controller.go b/controller/share_manager_controller.go index b1dda8df34..2fd2cc34b1 100644 --- a/controller/share_manager_controller.go +++ b/controller/share_manager_controller.go @@ -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 } @@ -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) @@ -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")