Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v1.34] Auto pick #3556: Set "system-node-critical" priority on #3559

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions pkg/render/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,15 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "NO_DEFAULT_POOLS", "true")

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

// Node image override results in correct image.
Expect(ds.Spec.Template.Spec.Containers).To(HaveLen(1))
Expect(ds.Spec.Template.Spec.Containers[0].Image).To(Equal(fmt.Sprintf("docker.io/%s:%s", components.ComponentCalicoNode.Image, components.ComponentCalicoNode.Version)))
Expand Down Expand Up @@ -519,6 +526,9 @@ var _ = Describe("Node rendering tests", func() {
// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "NO_DEFAULT_POOLS", "true")

cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
Expand Down Expand Up @@ -793,6 +803,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := rtest.GetResource(resources, "calico-node", "calico-system", "apps", "v1", "DaemonSet").(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

Expect(ds.Spec.Template.Spec.Containers[0].Image).To(Equal(components.TigeraRegistry + "tigera/cnx-node:" + components.ComponentTigeraNode.Version))
rtest.ExpectEnv(rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni").Env, "CNI_NET_DIR", "/etc/cni/net.d")

Expand Down Expand Up @@ -887,6 +901,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct security context.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

nodeContainer := rtest.GetContainer(ds.Spec.Template.Spec.Containers, "calico-node")
Expect(nodeContainer).ToNot(BeNil())
Expect(nodeContainer.SecurityContext).ToNot(BeNil())
Expand Down Expand Up @@ -1082,6 +1100,9 @@ var _ = Describe("Node rendering tests", func() {
// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "NO_DEFAULT_POOLS", "true")

cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
Expand Down Expand Up @@ -1246,6 +1267,9 @@ var _ = Describe("Node rendering tests", func() {
// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

// CNI install container should not be present.
cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
Expect(cniContainer).To(BeNil())
Expand Down Expand Up @@ -1379,6 +1403,9 @@ var _ = Describe("Node rendering tests", func() {
// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

// CNI install container should not be present.
cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
Expect(cniContainer).To(BeNil())
Expand Down Expand Up @@ -1496,6 +1523,9 @@ var _ = Describe("Node rendering tests", func() {
// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "NO_DEFAULT_POOLS", "true")

cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
Expand Down Expand Up @@ -1657,6 +1687,9 @@ var _ = Describe("Node rendering tests", func() {
// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

// CNI install container should not be present.
cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
Expect(cniContainer).To(BeNil())
Expand Down Expand Up @@ -1810,6 +1843,9 @@ var _ = Describe("Node rendering tests", func() {
ds := rtest.GetResource(resources, "calico-node", "calico-system", "apps", "v1", "DaemonSet").(*appsv1.DaemonSet)
Expect(ds.Spec.Template.Spec.Containers[0].Image).To(Equal(fmt.Sprintf("docker.io/%s:%s", components.ComponentCalicoNode.Image, components.ComponentCalicoNode.Version)))

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni").Env, "CNI_NET_DIR", "/var/run/multus/cni/net.d")

// Verify volumes. In particular, we want to make sure the flexvol-driver-host volume uses the right
Expand Down Expand Up @@ -1936,6 +1972,9 @@ var _ = Describe("Node rendering tests", func() {
ds := rtest.GetResource(resources, "calico-node", "calico-system", "apps", "v1", "DaemonSet").(*appsv1.DaemonSet)
Expect(ds.Spec.Template.Spec.Containers[0].Image).To(Equal(components.TigeraRegistry + "tigera/cnx-node:" + components.ComponentTigeraNode.Version))

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni").Env, "CNI_NET_DIR", "/var/run/multus/cni/net.d")

// Verify the Flex volume container image.
Expand Down Expand Up @@ -2032,6 +2071,9 @@ var _ = Describe("Node rendering tests", func() {
ds := rtest.GetResource(resources, "calico-node", "calico-system", "apps", "v1", "DaemonSet").(*appsv1.DaemonSet)
Expect(ds.Spec.Template.Spec.Containers[0].Image).To(Equal(components.TigeraRegistry + "tigera/cnx-node:" + components.ComponentTigeraNode.Version))

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni").Env, "CNI_NET_DIR", "/etc/cni/net.d")

expectedNodeEnv := []corev1.EnvVar{
Expand Down Expand Up @@ -2128,6 +2170,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := rtest.GetResource(resources, "calico-node", "calico-system", "apps", "v1", "DaemonSet").(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

volumes := ds.Spec.Template.Spec.Volumes
// Expect(ds.Spec.Template.Spec.Volumes).To(Equal())
Expect(volumes).To(ContainElement(
Expand Down Expand Up @@ -2162,6 +2208,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

Expect(ds.Spec.Template.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms).To(ContainElement(
corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{{
Expand All @@ -2184,6 +2234,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

Expect(ds.Spec.Template.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms).To(ContainElement(
corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{{
Expand Down Expand Up @@ -2225,6 +2279,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "IP_AUTODETECTION_METHOD", "interface=eth*")
})

Expand All @@ -2241,6 +2299,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "IP_AUTODETECTION_METHOD", "skip-interface=eth*")
})

Expand All @@ -2257,6 +2319,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "IP_AUTODETECTION_METHOD", "cidr=10.0.1.0/24,10.0.2.0/24")
})
})
Expand Down Expand Up @@ -2292,6 +2358,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

ns := ds.Spec.Template.Spec.NodeSelector
Expect(ns).To(HaveKey("projectcalico.org/operator-node-migration"))
Expect(ns["projectcalico.org/operator-node-migration"]).To(Equal("migrated"))
Expand Down Expand Up @@ -2475,6 +2545,9 @@ var _ = Describe("Node rendering tests", func() {
// The DaemonSet should have the correct configuration.
ds := rtest.GetResource(resources, "calico-node", "calico-system", "apps", "v1", "DaemonSet").(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
rtest.ExpectEnv(cniContainer.Env, "CNI_NET_DIR", "/etc/cni/net.d")

Expand Down Expand Up @@ -3067,6 +3140,10 @@ var _ = Describe("Node rendering tests", func() {

// The DaemonSet should have the correct configuration.
ds := dsResource.(*appsv1.DaemonSet)

// The pod template should have node critical priority
Expect(ds.Spec.Template.Spec.PriorityClassName).To(Equal(render.NodePriorityClassName))

rtest.ExpectEnv(ds.Spec.Template.Spec.Containers[0].Env, "NO_DEFAULT_POOLS", "true")

cniContainer := rtest.GetContainer(ds.Spec.Template.Spec.InitContainers, "install-cni")
Expand Down
3 changes: 3 additions & 0 deletions pkg/render/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,12 @@ func (c *windowsComponent) windowsDaemonset(cniCfgMap *corev1.ConfigMap) *appsv1
ds.Spec.Template.Spec.InitContainers = append(ds.Spec.Template.Spec.InitContainers, c.cniContainer())
}

setNodeCriticalPod(&(ds.Spec.Template))

if overrides := c.cfg.Installation.CalicoNodeWindowsDaemonSet; overrides != nil {
rcomp.ApplyDaemonSetOverrides(&ds, overrides)
}

return &ds
}

Expand Down
Loading