|
| 1 | +package node |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "strings" |
| 6 | + "time" |
| 7 | + |
| 8 | + o "github.com/onsi/gomega" |
| 9 | + exutil "github.com/openshift/origin/test/extended/util" |
| 10 | + compat_otp "github.com/openshift/origin/test/extended/util/compat_otp" |
| 11 | + "k8s.io/apimachinery/pkg/util/wait" |
| 12 | + e2e "k8s.io/kubernetes/test/e2e/framework" |
| 13 | +) |
| 14 | + |
| 15 | +func assertKubeletLogLevel(oc *exutil.CLI) { |
| 16 | + var kubeservice string |
| 17 | + var kublet string |
| 18 | + var err error |
| 19 | + waitErr := wait.Poll(10*time.Second, 1*time.Minute, func() (bool, error) { |
| 20 | + nodeName, nodeErr := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", "-o=jsonpath={.items[*].metadata.name}").Output() |
| 21 | + o.Expect(nodeErr).NotTo(o.HaveOccurred()) |
| 22 | + e2e.Logf("\nNode Names are %v", nodeName) |
| 23 | + nodes := strings.Fields(nodeName) |
| 24 | + |
| 25 | + for _, node := range nodes { |
| 26 | + nodeStatus, statusErr := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", node, "-o=jsonpath={.status.conditions[?(@.type=='Ready')].status}").Output() |
| 27 | + o.Expect(statusErr).NotTo(o.HaveOccurred()) |
| 28 | + e2e.Logf("\nNode %s Status is %s\n", node, nodeStatus) |
| 29 | + |
| 30 | + if nodeStatus == "True" { |
| 31 | + kubeservice, err = compat_otp.DebugNodeWithChroot(oc, node, "/bin/bash", "-c", "systemctl show kubelet.service | grep KUBELET_LOG_LEVEL") |
| 32 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 33 | + kublet, err = compat_otp.DebugNodeWithChroot(oc, node, "/bin/bash", "-c", "ps aux | grep kubelet") |
| 34 | + o.Expect(err).NotTo(o.HaveOccurred()) |
| 35 | + |
| 36 | + if strings.Contains(string(kubeservice), "KUBELET_LOG_LEVEL") && strings.Contains(string(kublet), "--v=2") { |
| 37 | + e2e.Logf(" KUBELET_LOG_LEVEL is 2. \n") |
| 38 | + return true, nil |
| 39 | + } else { |
| 40 | + e2e.Logf(" KUBELET_LOG_LEVEL is not 2. \n") |
| 41 | + return false, nil |
| 42 | + } |
| 43 | + } else { |
| 44 | + e2e.Logf("\n NODES ARE NOT READY\n ") |
| 45 | + } |
| 46 | + } |
| 47 | + return false, nil |
| 48 | + }) |
| 49 | + if waitErr != nil { |
| 50 | + e2e.Logf("Kubelet Log level is:\n %v\n", kubeservice) |
| 51 | + e2e.Logf("Running Proccess of kubelet are:\n %v\n", kublet) |
| 52 | + AssertWaitPollNoErr(waitErr, "KUBELET_LOG_LEVEL is not expected") |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +func AssertWaitPollNoErr(err error, desc string) { |
| 57 | + if err == nil { |
| 58 | + return |
| 59 | + } |
| 60 | + panic(fmt.Sprintf("Timed out waiting for %q: %v", desc, err)) |
| 61 | +} |
0 commit comments