Skip to content

Commit

Permalink
Remove pod infomer in engine controller and fix some NIT for Eric's
Browse files Browse the repository at this point in the history
comments

longhorn-6205

Signed-off-by: Phan Le <phan.le@suse.com>
  • Loading branch information
PhanLe1010 committed Jul 22, 2024
1 parent 6229d4d commit a8e56ab
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
12 changes: 0 additions & 12 deletions controller/engine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,6 @@ func NewEngineController(
}
ec.cacheSyncs = append(ec.cacheSyncs, ds.InstanceManagerInformer.HasSynced)

if _, err = ds.PodInformer.AddEventHandlerWithResyncPeriod(cache.FilteringResourceEventHandler{
FilterFunc: isShareManagerPod,
Handler: cache.ResourceEventHandlerFuncs{
AddFunc: ec.enqueueShareManagerPodChange,
UpdateFunc: func(old, cur interface{}) { ec.enqueueShareManagerPodChange(cur) },
DeleteFunc: ec.enqueueShareManagerPodChange,
},
}, 0); err != nil {
return nil, err
}
ec.cacheSyncs = append(ec.cacheSyncs, ds.PodInformer.HasSynced)

return ec, nil
}

Expand Down
4 changes: 2 additions & 2 deletions controller/share_manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (c *ShareManagerController) syncShareManager(key string) (err error) {
return err
}
if isStale {
isDelinquent, _, err := c.ds.IsRWXVolumeInDelinquent(sm.Name)
isDelinquent, _, err := c.ds.IsRWXVolumeDelinquent(sm.Name)
if err != nil {
return err
}
Expand Down Expand Up @@ -1160,7 +1160,7 @@ func (c *ShareManagerController) createShareManagerPod(sm *longhorn.ShareManager
}
}

isDelinquent, delinquentNode, err := c.ds.IsRWXVolumeInDelinquent(sm.Name)
isDelinquent, delinquentNode, err := c.ds.IsRWXVolumeDelinquent(sm.Name)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions datastore/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,13 @@ func (s *DataStore) UpdateLease(lease *coordinationv1.Lease) (*coordinationv1.Le
return s.kubeClient.CoordinationV1().Leases(s.namespace).Update(context.TODO(), lease, metav1.UpdateOptions{})
}

// IsRWXVolumeInDelinquent checks whether the volume has a lease by the same name, which an RWX volume should,
// IsRWXVolumeDelinquent checks whether the volume has a lease by the same name, which an RWX volume should,
// and whether that lease's spec shows that its holder is delinquent (its acquire time has been zeroed.)
// If so, return the delinquent holder.
// Any hiccup yields a return of "false".
func (s *DataStore) IsRWXVolumeInDelinquent(name string) (isDelinquent bool, holder string, err error) {
func (s *DataStore) IsRWXVolumeDelinquent(name string) (isDelinquent bool, holder string, err error) {
defer func() {
err = errors.Wrapf(err, "failed to check IsRWXVolumeInDelinquent")
err = errors.Wrapf(err, "failed to check IsRWXVolumeDelinquent")
}()

enabled, err := s.GetSettingAsBool(types.SettingNameEnableShareManagerFastFailover)
Expand Down
2 changes: 1 addition & 1 deletion datastore/longhorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2956,7 +2956,7 @@ func (s *DataStore) IsNodeDelinquent(nodeName string, volumeName string) (bool,
return false, nil
}

isDelinquent, delinquentNode, err := s.IsRWXVolumeInDelinquent(volumeName)
isDelinquent, delinquentNode, err := s.IsRWXVolumeDelinquent(volumeName)
if err != nil {
return false, err
}
Expand Down

0 comments on commit a8e56ab

Please sign in to comment.