Skip to content

Commit 4c3dc65

Browse files
gaohowardhowardgao
andauthored
Remove CriticalAddonsOnly toleration from the CDI pods (#3909) (#3910)
The CriticalAddonsOnly toleration is added to the CDI pods which affects pod scheduling and is against k8s best practices Signed-off-by: Howard Gao <[email protected]> Co-authored-by: Howard Gao <[email protected]>
1 parent d71a929 commit 4c3dc65

File tree

4 files changed

+0
-95
lines changed

4 files changed

+0
-95
lines changed

doc/quota.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ spec:
4848
infra:
4949
nodeSelector:
5050
kubernetes.io/os: linux
51-
tolerations:
52-
- key: CriticalAddonsOnly
53-
operator: Exists
5451
workload:
5552
nodeSelector:
5653
kubernetes.io/os: linux

manifests/templates/release/cdi-cr.yaml.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ spec:
1111
infra:
1212
nodeSelector:
1313
kubernetes.io/os: linux
14-
tolerations:
15-
- key: CriticalAddonsOnly
16-
operator: Exists
1714
workload:
1815
nodeSelector:
1916
kubernetes.io/os: linux

pkg/operator/resources/utils/common.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ func CreateOperatorDeployment(name, namespace, matchKey, matchValue, serviceAcco
117117
},
118118
ImagePullSecrets: imagePullSecrets,
119119
NodeSelector: map[string]string{"kubernetes.io/os": "linux"},
120-
Tolerations: []corev1.Toleration{
121-
{
122-
Key: "CriticalAddonsOnly",
123-
Operator: corev1.TolerationOpExists,
124-
},
125-
},
126120
Affinity: &corev1.Affinity{
127121
PodAffinity: &corev1.PodAffinity{
128122
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{

tests/operator_test.go

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -317,71 +317,6 @@ var _ = Describe("ALL Operator tests", func() {
317317
return true
318318
}, 5*time.Minute, 2*time.Second).Should(BeTrue())
319319
})
320-
321-
It("should deploy components that tolerate CriticalAddonsOnly taint", func() {
322-
cr := getCDI(f)
323-
criticalAddonsToleration := corev1.Toleration{
324-
Key: "CriticalAddonsOnly",
325-
Operator: corev1.TolerationOpExists,
326-
}
327-
328-
if !tolerationExists(cr.Spec.Infra.NodePlacement.Tolerations, criticalAddonsToleration) {
329-
Skip("Unexpected CDI CR (not from cdi-cr.yaml), doesn't tolerate CriticalAddonsOnly")
330-
}
331-
332-
labelSelector := metav1.LabelSelector{MatchLabels: map[string]string{"cdi.kubevirt.io/testing": ""}}
333-
cdiTestPods, err := f.K8sClient.CoreV1().Pods(f.CdiInstallNs).List(context.TODO(), metav1.ListOptions{
334-
LabelSelector: labels.Set(labelSelector.MatchLabels).String(),
335-
})
336-
Expect(err).ToNot(HaveOccurred(), "failed listing cdi testing pods")
337-
Expect(cdiTestPods.Items).ToNot(BeEmpty(), "no cdi testing pods found")
338-
339-
By("adding taints to all nodes")
340-
criticalPodTaint := corev1.Taint{
341-
Key: "CriticalAddonsOnly",
342-
Value: "",
343-
Effect: corev1.TaintEffectNoExecute,
344-
}
345-
346-
for _, node := range nodes.Items {
347-
Eventually(func() bool {
348-
nodeCopy, err := f.K8sClient.CoreV1().Nodes().Get(context.TODO(), node.Name, metav1.GetOptions{})
349-
Expect(err).ToNot(HaveOccurred())
350-
351-
if nodeHasTaint(*nodeCopy, criticalPodTaint) {
352-
return true
353-
}
354-
355-
nodeCopy.Spec.Taints = append(nodeCopy.Spec.Taints, criticalPodTaint)
356-
_, _ = f.K8sClient.CoreV1().Nodes().Update(context.TODO(), nodeCopy, metav1.UpdateOptions{})
357-
return false
358-
}, 5*time.Minute, 2*time.Second).Should(BeTrue())
359-
}
360-
361-
By("Waiting for all CDI testing pods to terminate")
362-
Eventually(func() bool {
363-
for _, cdiTestPod := range cdiTestPods.Items {
364-
By(fmt.Sprintf("CDI test pod: %s", cdiTestPod.Name))
365-
_, err := f.K8sClient.CoreV1().Pods(cdiTestPod.Namespace).Get(context.TODO(), cdiTestPod.Name, metav1.GetOptions{})
366-
if !errors.IsNotFound(err) {
367-
return false
368-
}
369-
}
370-
return true
371-
}, 5*time.Minute, 2*time.Second).Should(BeTrue())
372-
373-
By("Checking that all the non-testing pods are running")
374-
for _, cdiPod := range cdiPods.Items {
375-
if _, isTestingComponent := cdiPod.Labels["cdi.kubevirt.io/testing"]; isTestingComponent {
376-
continue
377-
}
378-
By(fmt.Sprintf("Non-test CDI pod: %s", cdiPod.Name))
379-
podUpdated, err := f.K8sClient.CoreV1().Pods(cdiPod.Namespace).Get(context.TODO(), cdiPod.Name, metav1.GetOptions{})
380-
Expect(err).ToNot(HaveOccurred(), "failed setting taint on node")
381-
Expect(podUpdated.Status.Phase).To(Equal(corev1.PodRunning))
382-
}
383-
})
384-
385320
})
386321

387322
var _ = Describe("Operator delete CDI CR tests", func() {
@@ -1356,24 +1291,6 @@ func waitCDI(f *framework.Framework, cr *cdiv1.CDI, cdiPods *corev1.PodList) {
13561291
}
13571292
}
13581293

1359-
func tolerationExists(tolerations []corev1.Toleration, testValue corev1.Toleration) bool {
1360-
for _, toleration := range tolerations {
1361-
if reflect.DeepEqual(toleration, testValue) {
1362-
return true
1363-
}
1364-
}
1365-
return false
1366-
}
1367-
1368-
func nodeHasTaint(node corev1.Node, testedTaint corev1.Taint) bool {
1369-
for _, taint := range node.Spec.Taints {
1370-
if reflect.DeepEqual(taint, testedTaint) {
1371-
return true
1372-
}
1373-
}
1374-
return false
1375-
}
1376-
13771294
func infraDeploymentAvailable(f *framework.Framework, cr *cdiv1.CDI) bool {
13781295
cdi, _ := f.CdiClient.CdiV1beta1().CDIs().Get(context.TODO(), cr.Name, metav1.GetOptions{})
13791296
if !conditions.IsStatusConditionTrue(cdi.Status.Conditions, conditions.ConditionAvailable) {

0 commit comments

Comments
 (0)