Skip to content

Commit

Permalink
Update Mountpoint Pod spec to tolerate all taints (#387)
Browse files Browse the repository at this point in the history
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
  • Loading branch information
unexge authored Feb 21, 2025
1 parent 262f35b commit 3ea6a5f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/podmounter/mppod/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *Creator) Create(pod *corev1.Pod, pvc *corev1.PersistentVolumeClaim) *co
}},
Affinity: &corev1.Affinity{
NodeAffinity: &corev1.NodeAffinity{
// This is to making sure Mountpoint Pod gets scheduled into same node as the Pod
// This is to making sure Mountpoint Pod gets scheduled into same node as the Workload Pod
RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{
{
Expand All @@ -100,6 +100,16 @@ func (c *Creator) Create(pod *corev1.Pod, pvc *corev1.PersistentVolumeClaim) *co
},
},
},
Tolerations: []corev1.Toleration{
// Tolerate all taints.
// - "NoScheduled" – If the Workload Pod gets scheduled to a node, Mountpoint Pod should also get
// scheduled into the same node to provide the volume.
// - "NoExecute" – If the Workload Pod tolerates a "NoExecute" taint, Mountpoint Pod should also
// tolerate it to keep running and provide volume for the Workload Pod.
// If the Workload Pod would get descheduled and then the corresponding Mountpoint Pod
// would also get descheduled naturally due to CSI volume lifecycle.
{Operator: corev1.TolerationOpExists},
},
Volumes: []corev1.Volume{
// This emptyDir volume is used for communication between Mountpoint Pod and the CSI Driver Node Pod
{
Expand Down
3 changes: 3 additions & 0 deletions pkg/podmounter/mppod/creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func TestCreatingMountpointPods(t *testing.T) {
},
},
}, mpPod.Spec.Affinity)
assert.Equals(t, []corev1.Toleration{
{Operator: corev1.TolerationOpExists},
}, mpPod.Spec.Tolerations)

assert.Equals(t, image, mpPod.Spec.Containers[0].Image)
assert.Equals(t, imagePullPolicy, mpPod.Spec.Containers[0].ImagePullPolicy)
Expand Down
5 changes: 5 additions & 0 deletions tests/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@ func verifyMountpointPodFor(pod *testPod, vol *testVolume, mountpointPod *testPo
}},
},
}))
Expect(mountpointPod.Spec.Tolerations).To(Equal([]corev1.Toleration{
{
Operator: corev1.TolerationOpExists,
},
}))

Expect(mountpointPod.Spec.Containers[0].Image).To(Equal(mountpointImage))
Expect(mountpointPod.Spec.Containers[0].ImagePullPolicy).To(Equal(mountpointImagePullPolicy))
Expand Down

0 comments on commit 3ea6a5f

Please sign in to comment.