Skip to content

Commit 5b6e4cc

Browse files
Merge pull request #29785 from isabella-janssen/ocpbugs-55968
OCPBUGS-55384: OCPBUGS-55968: Fix PIS tests on SNO & Enable applicable MCN & PIS tests on SNO
2 parents 8fad4d6 + 226a55a commit 5b6e4cc

File tree

6 files changed

+110
-22
lines changed

6 files changed

+110
-22
lines changed

test/extended/machine_config/helpers.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,19 +430,19 @@ func ValidateMCNForNodeInPool(oc *exutil.CLI, clientSet *machineconfigclient.Cli
430430
return nil
431431
}
432432

433-
// `GetRandomNode` gets a random node from a given MCP and checks whether the node is ready. If no
433+
// `GetRandomNode` gets a random node from with a given role and checks whether the node is ready. If no
434434
// nodes are ready, it will wait for up to 5 minutes for a node to become available.
435-
func GetRandomNode(oc *exutil.CLI, pool string) corev1.Node {
436-
if node := getRandomNode(oc, pool); isNodeReady(node) {
435+
func GetRandomNode(oc *exutil.CLI, role string) corev1.Node {
436+
if node := getRandomNode(oc, role); isNodeReady(node) {
437437
return node
438438
}
439439

440440
// If no nodes are ready, wait for up to 5 minutes for one to be ready
441441
waitPeriod := time.Minute * 5
442-
framework.Logf("No ready nodes found for pool '%s', waiting up to %s for a ready node to become available", pool, waitPeriod)
442+
framework.Logf("No ready nodes found with role '%s', waiting up to %s for a ready node to become available", role, waitPeriod)
443443
var targetNode corev1.Node
444444
o.Eventually(func() bool {
445-
if node := getRandomNode(oc, pool); isNodeReady(node) {
445+
if node := getRandomNode(oc, role); isNodeReady(node) {
446446
targetNode = node
447447
return true
448448
}
@@ -453,9 +453,9 @@ func GetRandomNode(oc *exutil.CLI, pool string) corev1.Node {
453453
return targetNode
454454
}
455455

456-
// `getRandomNode` gets a random node from a given pool
457-
func getRandomNode(oc *exutil.CLI, pool string) corev1.Node {
458-
nodes, err := GetNodesByRole(oc, pool)
456+
// `getRandomNode` gets a random node with a given role
457+
func getRandomNode(oc *exutil.CLI, role string) corev1.Node {
458+
nodes, err := GetNodesByRole(oc, role)
459459
o.Expect(err).NotTo(o.HaveOccurred())
460460
o.Expect(nodes).ShouldNot(o.BeEmpty())
461461

test/extended/machine_config/machine_config_node.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:MachineConfigNodes]", func() {
9999
})
100100

101101
g.It("Should properly block MCN updates by impersonation of the MCD SA [apigroup:machineconfiguration.openshift.io]", func() {
102-
skipOnSingleNodeTopology(oc) //skip this test for SNO
103102
ValidateMCNScopeImpersonationPathTest(oc)
104103
})
105104

106105
g.It("Should properly update the MCN from the associated MCD [apigroup:machineconfiguration.openshift.io]", func() {
107-
skipOnSingleNodeTopology(oc) //skip this test for SNO
108106
ValidateMCNScopeHappyPathTest(oc)
109107
})
110108
})
@@ -571,7 +569,7 @@ func ValidateMCNScopeSadPathTest(oc *exutil.CLI) {
571569
// Grab two different nodes, so we don't end up testing and targeting the same node.
572570
nodeUnderTest := nodes[0]
573571
targetNode := nodes[1]
574-
framework.Logf("Testing with nodes '%v' and '%v'.", nodeUnderTest, targetNode)
572+
framework.Logf("Testing with nodes '%v' and '%v'.", nodeUnderTest.Name, targetNode.Name)
575573

576574
// Attempt to patch the MCN owned by targetNode from nodeUnderTest's MCD. This should fail.
577575
// This oc command effectively use the service account of the nodeUnderTest's MCD pod, which should only be able to edit nodeUnderTest's MCN.
@@ -584,9 +582,10 @@ func ValidateMCNScopeSadPathTest(oc *exutil.CLI) {
584582

585583
// `ValidateMCNScopeImpersonationPathTest` checks that MCN updates by impersonation of the MCD SA are blocked
586584
func ValidateMCNScopeImpersonationPathTest(oc *exutil.CLI) {
587-
// Grab a random node from the worker pool
585+
// Grab a random node with a worker role
588586
nodeUnderTest := GetRandomNode(oc, "worker")
589-
framework.Logf("Testing with node '%v'.", nodeUnderTest)
587+
o.Expect(nodeUnderTest.Name).NotTo(o.Equal(""), "Could not get a `worker` node.")
588+
framework.Logf("Testing with node '%v'.", nodeUnderTest.Name)
590589

591590
var errb bytes.Buffer
592591
// Attempt to patch the MCN owned by nodeUnderTest by impersonating the MCD SA. This should fail.
@@ -602,17 +601,18 @@ func ValidateMCNScopeImpersonationPathTest(oc *exutil.CLI) {
602601

603602
// `ValidateMCNScopeHappyPathTest` checks that MCN updates from the associated MCD are allowed
604603
func ValidateMCNScopeHappyPathTest(oc *exutil.CLI) {
605-
// Grab a random node from the worker pool
604+
// Grab a random node with a worker role
606605
nodeUnderTest := GetRandomNode(oc, "worker")
607-
framework.Logf("Testing with node '%v'.", nodeUnderTest)
606+
o.Expect(nodeUnderTest.Name).NotTo(o.Equal(""), "Could not get a `worker` node.")
607+
framework.Logf("Testing with node '%v'.", nodeUnderTest.Name)
608608

609609
// Get node's starting desired version
610610
nodeDesiredConfig := nodeUnderTest.Annotations[desiredConfigAnnotationKey]
611611

612612
// Attempt to patch the MCN owned by nodeUnderTest from nodeUnderTest's MCD. This should succeed.
613613
// This oc command effectively use the service account of the nodeUnderTest's MCD pod, which should only be able to edit nodeUnderTest's MCN.
614614
ExecCmdOnNode(oc, nodeUnderTest, "chroot", "/rootfs", "oc", "patch", "machineconfignodes", nodeUnderTest.Name, "--type=merge", "-p", "{\"spec\":{\"configVersion\":{\"desired\":\"rendered-worker-test\"}}}")
615-
framework.Logf("MCN '%v' patched successfully.", nodeUnderTest)
615+
framework.Logf("MCN '%v' patched successfully.", nodeUnderTest.Name)
616616

617617
// Cleanup by updating the MCN desired config back to the original value.
618618
framework.Logf("Cleaning up patched MCN's desired config value.")

test/extended/machine_config/pinnedimages.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:PinnedImages][OCPFeatureGate:Machin
3333
MCOKubeletConfigBaseDir = exutil.FixturePath("testdata", "machine_config", "kubeletconfig")
3434

3535
pinnedImageSetFixture = filepath.Join(MCOPinnedImageBaseDir, "pis.yaml")
36+
masterPinnedImageSetFixture = filepath.Join(MCOPinnedImageBaseDir, "masterPis.yaml")
3637
customMCPFixture = filepath.Join(MCOMachineConfigPoolBaseDir, "customMCP.yaml")
3738
customMCPpinnedImageSetFixture = filepath.Join(MCOPinnedImageBaseDir, "customMCPpis.yaml")
3839
customGCMCPpinnedImageSetFixture = filepath.Join(MCOPinnedImageBaseDir, "customGCMCPpis.yaml")
3940
customGcKCFixture = filepath.Join(MCOKubeletConfigBaseDir, "gcKC.yaml")
4041
invalidPinnedImageSetFixture = filepath.Join(MCOPinnedImageBaseDir, "invalidPis.yaml")
42+
masterInvalidPinnedImageSetFixture = filepath.Join(MCOPinnedImageBaseDir, "masterInvalidPis.yaml")
4143
customInvalidPinnedImageSetFixture = filepath.Join(MCOPinnedImageBaseDir, "customInvalidPis.yaml")
4244

4345
oc = exutil.NewCLIWithoutNamespace("machine-config")
@@ -109,21 +111,31 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:PinnedImages][OCPFeatureGate:Machin
109111
})
110112

111113
g.It("All Nodes in a standard Pool should have the PinnedImages PIS [apigroup:machineconfiguration.openshift.io]", func() {
112-
// TODO (ijanssen/rsaini): re-enable this test on SNO after fixing OCPBUGS-55384
113-
// (temporarily) skip these tests on SNO
114-
skipOnSingleNodeTopology(oc)
115-
116114
kubeClient, err := kubernetes.NewForConfig(oc.KubeFramework().ClientConfig())
117115
o.Expect(err).NotTo(o.HaveOccurred(), "Get KubeClient")
118116

119-
SimplePISTest(oc, kubeClient, pinnedImageSetFixture, true)
117+
// Since the node in a SNO cluster is a part of the master MCP, the PIS for this test on a
118+
// single node topology should target `master`.
119+
pisFixture := pinnedImageSetFixture
120+
if IsSingleNode(oc) {
121+
pisFixture = masterPinnedImageSetFixture
122+
}
123+
124+
SimplePISTest(oc, kubeClient, pisFixture, true)
120125
})
121126

122127
g.It("Invalid PIS leads to degraded MCN in a standard Pool [apigroup:machineconfiguration.openshift.io]", func() {
123128
kubeClient, err := kubernetes.NewForConfig(oc.KubeFramework().ClientConfig())
124129
o.Expect(err).NotTo(o.HaveOccurred(), "Get KubeClient")
125130

126-
SimplePISTest(oc, kubeClient, invalidPinnedImageSetFixture, false)
131+
// Since the node in a SNO cluster is a part of the master MCP, the PIS for this test on a
132+
// single node topology should target `master`.
133+
pisFixture := invalidPinnedImageSetFixture
134+
if IsSingleNode(oc) {
135+
pisFixture = masterInvalidPinnedImageSetFixture
136+
}
137+
138+
SimplePISTest(oc, kubeClient, pisFixture, false)
127139
})
128140

129141
g.It("Invalid PIS leads to degraded MCN in a custom Pool [apigroup:machineconfiguration.openshift.io]", func() {

test/extended/testdata/bindata.go

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: machineconfiguration.openshift.io/v1
2+
kind: PinnedImageSet
3+
metadata:
4+
name: test-pinned
5+
labels:
6+
machineconfiguration.openshift.io/role: "master"
7+
spec:
8+
pinnedImages:
9+
- name: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:86d26e7ebcccd6f07a75db5b1e56283b25c2ee1c6a755d6ffc5a4d59beb9cdef
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: machineconfiguration.openshift.io/v1
2+
kind: PinnedImageSet
3+
metadata:
4+
name: test-pinned
5+
labels:
6+
machineconfiguration.openshift.io/role: "master"
7+
spec:
8+
pinnedImages:
9+
- name: quay.io/openshifttest/busybox@sha256:c5439d7db88ab5423999530349d327b04279ad3161d7596d2126dfb5b02bfd1f

0 commit comments

Comments
 (0)