Skip to content

Commit a5224bd

Browse files
committed
fix: set the ResourceIsPod of DefaultPodValidationOptions to false (#1986)
Signed-off-by: Yesphet <[email protected]>
1 parent 483dc2f commit a5224bd

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pkg/webhook/util/pod_validation.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ var (
2626
AllowInvalidLabelValueInSelector: true,
2727
AllowHostIPsField: true,
2828
AllowInvalidTopologySpreadConstraintLabelSelector: true,
29-
ResourceIsPod: true,
29+
ResourceIsPod: false,
3030
}
3131
)

test/e2e/apps/cloneset.go

+25
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,31 @@ var _ = SIGDescribe("CloneSet", func() {
6363
randStr = rand.String(10)
6464
})
6565

66+
framework.KruiseDescribe("CloneSet Creating", func() {
67+
68+
framework.ConformanceIt("creates with hostNetwork pod, specified containerPort without specifying hostPort", func() {
69+
cs := tester.NewCloneSet("hostnetwork-port-"+randStr, 1, appsv1alpha1.CloneSetUpdateStrategy{})
70+
cs.Spec.Template.Spec.HostNetwork = true
71+
cs.Spec.Template.Spec.Containers[0].Ports = []v1.ContainerPort{{ContainerPort: 80}}
72+
cs, err := tester.CreateCloneSet(cs)
73+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "creation should be success")
74+
75+
gomega.Eventually(func() int32 {
76+
cs, err = tester.GetCloneSet(cs.Name)
77+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
78+
return cs.Status.ReadyReplicas
79+
}, 120*time.Second, 3*time.Second).Should(gomega.Equal(int32(1)))
80+
81+
pods, err := tester.ListPodsForCloneSet(cs.Name)
82+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
83+
for _, pod := range pods {
84+
ginkgo.By("hostPort should defaults to containerPort")
85+
gomega.Expect(pod.Spec.Containers[0].Ports[0].HostPort).To(gomega.Equal(pod.Spec.Containers[0].Ports[0].ContainerPort))
86+
}
87+
})
88+
89+
})
90+
6691
framework.KruiseDescribe("CloneSet Scaling", func() {
6792
var err error
6893

0 commit comments

Comments
 (0)