Set Tolerations for engine image daemonset
@@ -268,7 +268,16 @@ func (ic *EngineImageController) syncEngineImage(key string) (err error) {
return errors.Wrapf(err, "cannot get daemonset for engine image %v", engineImage.Name)
}
if ds == nil {
- dsSpec := ic.createEngineImageDaemonSetSpec(engineImage)
+ setting, err := ic.ds.GetSetting(types.SettingNameTaintToleration)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get taint toleration setting before creating engine image daemonset")
+ }
+ tolerations, err := types.UnmarshalTolerations(setting.Value)
+ if err != nil {
+ return errors.Wrapf(err, "failed to unmarshal taint toleration setting before creating engine image daemonset")
+ }
+
+ dsSpec := ic.createEngineImageDaemonSetSpec(engineImage, tolerations)
if err = ic.ds.CreateEngineImageDaemonSet(dsSpec); err != nil {
return errors.Wrapf(err, "fail to create daemonset for engine image %v", engineImage.Name)
}
@@ -499,7 +508,7 @@ func getEngineImageDaemonSetName(engineImageName string) string {
return "engine-image-" + engineImageName
}
-func (ic *EngineImageController) createEngineImageDaemonSetSpec(ei *longhorn.EngineImage) *appsv1beta2.DaemonSet {
+func (ic *EngineImageController) createEngineImageDaemonSetSpec(ei *longhorn.EngineImage, tolerations []v1.Toleration) *appsv1beta2.DaemonSet {
dsName := getEngineImageDaemonSetName(ei.Name)
image := ei.Spec.Image
cmd := []string{
@@ -524,6 +533,7 @@ func (ic *EngineImageController) createEngineImageDaemonSetSpec(ei *longhorn.Eng
},
Spec: v1.PodSpec{
ServiceAccountName: ic.serviceAccount,
+ Tolerations: tolerations,
Containers: []v1.Container{
{
Name: dsName,
