Skip to content

Commit

Permalink
feat(rwx): share manager pod respects the newly introduced storageCla…
Browse files Browse the repository at this point in the history
…ss.Parameters["shareManagerTolerations"]

Share manager pod respects the newly introduced storageClass.Parameters["shareManagerTolerations"].
The tolerations are merged with the global setting taint-toleration and are applied to share manager pod.

Longhron 7872

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit committed Apr 9, 2024
1 parent ece51b2 commit bd425d2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions controller/share_manager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,21 @@ func (c *ShareManagerController) getShareManagerNodeSelectorFromStorageClass(sc
return nodeSelector
}

func (c *ShareManagerController) getShareManagerTolerationsFromStorageClass(sc *storagev1.StorageClass) []corev1.Toleration {
value, ok := sc.Parameters["shareManagerTolerations"]
if !ok {
return []corev1.Toleration{}
}

tolerations, err := types.UnmarshalTolerations(value)
if err != nil {
c.logger.WithError(err).Warnf("Failed to unmarshal tolerations %v", value)
return []corev1.Toleration{}
}

return tolerations
}

// createShareManagerPod ensures existence of service, it's assumed that the pvc for this share manager already exists
func (c *ShareManagerController) createShareManagerPod(sm *longhorn.ShareManager) (*corev1.Pod, error) {
tolerations, err := c.ds.GetSettingTaintToleration()
Expand Down Expand Up @@ -846,6 +861,7 @@ func (c *ShareManagerController) createShareManagerPod(sm *longhorn.ShareManager
}

var affinity *corev1.Affinity

if pv.Spec.StorageClassName != "" {
sc, err := c.ds.GetStorageClass(pv.Spec.StorageClassName)
if err != nil {
Expand All @@ -861,6 +877,13 @@ func (c *ShareManagerController) createShareManagerPod(sm *longhorn.ShareManager
for k, v := range nodeSelectorFromStorageClass {
nodeSelector[k] = v
}

// Find the tolerations from the storage class and merge it with the global tolerations
if tolerations == nil {
tolerations = []corev1.Toleration{}
}
tolerationsFromStorageClass := c.getShareManagerTolerationsFromStorageClass(sc)
tolerations = append(tolerations, tolerationsFromStorageClass...)
}
}

Expand Down

0 comments on commit bd425d2

Please sign in to comment.