Skip to content

Commit f034283

Browse files
committed
fix[syncer pod]: fix pod with custom PriorityClass and PreemptionPolicy is Never
1 parent a8e8b99 commit f034283

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/syncer/topdown/pod/virtual_pod_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ func (r *VirtualPodReconciler) buildPhysicalPodSpec(ctx context.Context, virtual
972972
}
973973
spec.PriorityClassName = priorityClassName
974974
spec.Priority = nil
975+
spec.PreemptionPolicy = nil
975976

976977
// cleanup service account related fields
977978
spec.ServiceAccountName = ""

test/integration/pod_sync_integration_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,7 @@ var _ = ginkgo.Describe("Virtual Pod Integration Tests", func() {
21042104
Name: customPriorityClassName,
21052105
},
21062106
Value: customPriorityValue,
2107-
PreemptionPolicy: &[]corev1.PreemptionPolicy{corev1.PreemptLowerPriority}[0],
2107+
PreemptionPolicy: &[]corev1.PreemptionPolicy{corev1.PreemptNever}[0],
21082108
Description: "Test PriorityClass for Kubeocean E2E tests",
21092109
}
21102110
gomega.Expect(k8sPhysical.Create(ctx, customPriorityClass)).To(gomega.Succeed())
@@ -2154,6 +2154,11 @@ var _ = ginkgo.Describe("Virtual Pod Integration Tests", func() {
21542154
gomega.Expect(*physicalPod.Spec.Priority).To(gomega.Equal(customPriorityValue))
21552155
ginkgo.By("Verifying physical pod has correct priority value: " + fmt.Sprintf("%v", *physicalPod.Spec.Priority))
21562156

2157+
ginkgo.By("Verifying physical pod has correct preemption policy")
2158+
gomega.Expect(physicalPod.Spec.PreemptionPolicy).NotTo(gomega.BeNil())
2159+
gomega.Expect(*physicalPod.Spec.PreemptionPolicy).To(gomega.Equal(corev1.PreemptNever))
2160+
ginkgo.By("Verifying physical pod has correct preemption policy: " + fmt.Sprintf("%v", *physicalPod.Spec.PreemptionPolicy))
2161+
21572162
// Clean up: restore ClusterBinding to default
21582163
ginkgo.By("Restoring ClusterBinding to default PriorityClass")
21592164
clusterBinding.Spec.PodPriorityClassName = ""

0 commit comments

Comments
 (0)