@@ -17,20 +17,21 @@ var _ = g.Describe("[sig-node] [Jira:Node/Kubelet] Kubelet, CRI-O, CPU manager",
1717 oc = exutil .NewCLIWithoutNamespace ("node" )
1818 )
1919
20+ // Skip all tests on MicroShift clusters as MachineConfig resources are not available
21+ g .BeforeEach (func () {
22+ isMicroShift , err := exutil .IsMicroShiftCluster (oc .AdminKubeClient ())
23+ o .Expect (err ).NotTo (o .HaveOccurred ())
24+ if isMicroShift {
25+ g .Skip ("Skipping test on MicroShift cluster - MachineConfig resources are not available" )
26+ }
27+ })
28+
2029 //author: asahay@redhat.com
2130 g .It ("[OTP] validate KUBELET_LOG_LEVEL" , func () {
2231 var kubeservice string
2332 var kubelet string
2433 var err error
2534
26- isMicroShift , err := exutil .IsMicroShiftCluster (oc .AdminKubeClient ())
27- if err != nil {
28- o .Expect (err ).NotTo (o .HaveOccurred (), "error determining if running on MicroShift: %v" , err )
29- }
30- if isMicroShift {
31- g .Skip ("This test case is not supported in micoshift cluster " )
32- }
33-
3435 g .By ("Polling to check kubelet log level on ready nodes" )
3536 waitErr := wait .Poll (10 * time .Second , 1 * time .Minute , func () (bool , error ) {
3637 g .By ("Getting all node names in the cluster" )
@@ -75,4 +76,31 @@ var _ = g.Describe("[sig-node] [Jira:Node/Kubelet] Kubelet, CRI-O, CPU manager",
7576 }
7677 o .Expect (waitErr ).NotTo (o .HaveOccurred (), "KUBELET_LOG_LEVEL is not expected, timed out" )
7778 })
79+
80+ //author: cmaurya@redhat.com
81+ g .It ("[OTP] validate cgroupv2 is default [OCP-80983]" , func () {
82+ g .By ("Check cgroup version on all Ready worker nodes" )
83+ nodeNames , err := oc .AsAdmin ().WithoutNamespace ().Run ("get" ).Args ("nodes" , "-l" , "node-role.kubernetes.io/worker" , "-o=jsonpath={.items[*].metadata.name}" ).Output ()
84+ o .Expect (err ).NotTo (o .HaveOccurred ())
85+ workers := strings .Fields (nodeNames )
86+ o .Expect (workers ).NotTo (o .BeEmpty (), "No worker nodes found" )
87+
88+ for _ , worker := range workers {
89+ nodeStatus , err := oc .AsAdmin ().Run ("get" ).Args ("nodes" , worker , "-o=jsonpath={.status.conditions[?(@.type=='Ready')].status}" ).Output ()
90+ o .Expect (err ).NotTo (o .HaveOccurred ())
91+ if nodeStatus != "True" {
92+ e2e .Logf ("Skipping worker node %s (not Ready)" , worker )
93+ continue
94+ }
95+ cgroupV , err := nodeutils .ExecOnNodeWithChroot (oc , worker , "/bin/bash" , "-c" , "stat -c %T -f /sys/fs/cgroup" )
96+ o .Expect (err ).NotTo (o .HaveOccurred ())
97+ e2e .Logf ("cgroup version on node %s: [%v]" , worker , cgroupV )
98+ o .Expect (cgroupV ).To (o .ContainSubstring ("cgroup2fs" ), "Node %s does not have cgroupv2" , worker )
99+ }
100+
101+ g .By ("Changing cgroup from v2 to v1 should result in error" )
102+ output , err := oc .AsAdmin ().WithoutNamespace ().Run ("patch" ).Args ("nodes.config.openshift.io" , "cluster" , "-p" , `{"spec": {"cgroupMode": "v1"}}` , "--type=merge" ).Output ()
103+ o .Expect (err ).Should (o .HaveOccurred ())
104+ o .Expect (output ).To (o .ContainSubstring ("spec.cgroupMode: Unsupported value: \" v1\" : supported values: \" v2\" , \" \" " ))
105+ })
78106})
0 commit comments