diff --git a/cnf-certification-test/platform/suite.go b/cnf-certification-test/platform/suite.go index fde9432ec..81e71bcae 100644 --- a/cnf-certification-test/platform/suite.go +++ b/cnf-certification-test/platform/suite.go @@ -44,7 +44,6 @@ var ( env provider.TestEnvironment beforeEachFn = func(check *checksdb.Check) error { - check.LogInfo("Check %s: getting test environment.", check.ID) env = provider.GetTestEnvironment() return nil } @@ -52,7 +51,7 @@ var ( //nolint:funlen func LoadChecks() { - log.Debug("Entering %s suite", common.PlatformAlterationTestKey) + log.Debug("Loading %s suite checks", common.PlatformAlterationTestKey) checksGroup := checksdb.NewChecksGroup(common.PlatformAlterationTestKey). WithBeforeEachFn(beforeEachFn) @@ -172,13 +171,17 @@ func testHyperThreadingEnabled(check *checksdb.Check, env *provider.TestEnvironm baremetalNodes := env.GetBaremetalNodes() for _, node := range baremetalNodes { nodeName := node.Data.Name + check.LogInfo("Testing node %q", nodeName) enable, err := node.IsHyperThreadNode(env) //nolint:gocritic if enable { + check.LogInfo("Node %q has hyperthreading enabled", nodeName) compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(nodeName, "Node has hyperthreading enabled", true)) } else if err != nil { - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Error with executing the checke for hyperthreading: "+err.Error(), false)) + check.LogError("Hyperthreading check fail for node %q, err: %v", nodeName, err) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Error with executing the check for hyperthreading: "+err.Error(), false)) } else { + check.LogError("Node %q has hyperthreading disabled", nodeName) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Node has hyperthreading disabled ", false)) } } @@ -189,18 +192,20 @@ func testServiceMesh(check *checksdb.Check, env *provider.TestEnvironment) { var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject for _, put := range env.Pods { + check.LogInfo("Testing Pod %q", put) istioProxyFound := false for _, cut := range put.Containers { if cut.IsIstioProxy() { - check.LogDebug("Istio proxy container found on %s", put) + check.LogInfo("Istio proxy container found on Pod %q (Container %q)", put, cut) istioProxyFound = true break } } if !istioProxyFound { - check.LogDebug("Pod found without service mesh: %s", put.String()) + check.LogError("Pod %q found without service mesh", put) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewPodReportObject(put.Namespace, put.Name, "Pod found without service mesh container", false)) } else { + check.LogInfo("Pod %q found with service mesh", put) compliantObjects = append(compliantObjects, testhelper.NewPodReportObject(put.Namespace, put.Name, "Pod found with service mesh container", true)) } } @@ -213,7 +218,7 @@ func testContainersFsDiff(check *checksdb.Check, env *provider.TestEnvironment) var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject for _, cut := range env.Containers { - check.LogDebug(fmt.Sprintf("%s should not install new packages after starting", cut.String())) + check.LogInfo("Testing Container %q", cut) debugPod := env.DebugPods[cut.NodeName] ctxt := clientsholder.NewContext(debugPod.Namespace, debugPod.Name, debugPod.Spec.Containers[0].Name) @@ -221,16 +226,17 @@ func testContainersFsDiff(check *checksdb.Check, env *provider.TestEnvironment) fsDiffTester.RunTest(cut.UID) switch fsDiffTester.GetResults() { case testhelper.SUCCESS: + check.LogInfo("Container %q is not modified", cut) compliantObjects = append(compliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Container is not modified", true)) continue case testhelper.FAILURE: - check.LogDebug("%s - changed folders: %v, deleted folders: %v", cut, fsDiffTester.ChangedFolders, fsDiffTester.DeletedFolders) + check.LogError("Container %q modified (changed folders: %v, deleted folders: %v", cut, fsDiffTester.ChangedFolders, fsDiffTester.DeletedFolders) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Container is modified", false). AddField("ChangedFolders", strings.Join(fsDiffTester.ChangedFolders, ",")). AddField("DeletedFolders", strings.Join(fsDiffTester.DeletedFolders, ","))) case testhelper.ERROR: - check.LogDebug("%s - error while running fs-diff: %v", cut, fsDiffTester.Error) + check.LogError("Could not run fs-diff in Container %q, err: %v", cut, fsDiffTester.Error) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Error while running fs-diff", false).AddField(testhelper.Error, fsDiffTester.Error.Error())) } } @@ -267,7 +273,7 @@ func testTainted(check *checksdb.Check, env *provider.TestEnvironment) { for _, dp := range env.DebugPods { nodeName := dp.Spec.NodeName - check.LogInfo("Checking kernel taints of node %s", nodeName) + check.LogInfo("Testing node %q", nodeName) ocpContext := clientsholder.NewContext(dp.Namespace, dp.Name, dp.Spec.Containers[0].Name) tf := nodetainted.NewNodeTaintedTester(&ocpContext, nodeName) @@ -275,27 +281,29 @@ func testTainted(check *checksdb.Check, env *provider.TestEnvironment) { // Get the taints mask from the node kernel taintsMask, err := tf.GetKernelTaintsMask() if err != nil { - check.LogDebug("Failed to retrieve kernel taint information from node %s: %v", nodeName, err) + check.LogError("Failed to retrieve kernel taint information from node %q, err: %v", nodeName, err) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Failed to retrieve kernel taint information from node", false). AddField(testhelper.Error, err.Error())) continue } if taintsMask == 0 { - check.LogDebug("Node %s has no non-approved kernel taints.", nodeName) + check.LogInfo("Node %q has no non-approved kernel taints.", nodeName) compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(nodeName, "Node has no non-approved kernel taints", true)) continue } - check.LogDebug("Node %s kernel is tainted. Taints mask=%d - Decoded taints: %v", + check.LogInfo("Node %q kernel is tainted. Taints mask=%d - Decoded taints: %v", nodeName, taintsMask, nodetainted.DecodeKernelTaintsFromBitMask(taintsMask)) // Check the allow list. If empty, mark this node as failed. if len(allowListedModules) == 0 { taintsMaskStr := strconv.FormatUint(taintsMask, 10) + taintsStr := strings.Join(nodetainted.DecodeKernelTaintsFromBitMask(taintsMask), ",") + check.LogError("Node %q contains taints not covered by module allowlist. Taints: %q (mask=%q)", nodeName, taintsStr, taintsMaskStr) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Node contains taints not covered by module allowlist", false). AddField(testhelper.TaintMask, taintsMaskStr). - AddField(testhelper.Taints, strings.Join(nodetainted.DecodeKernelTaintsFromBitMask(taintsMask), ","))) + AddField(testhelper.Taints, taintsStr)) continue } @@ -306,7 +314,7 @@ func testTainted(check *checksdb.Check, env *provider.TestEnvironment) { // one tainter module. tainters, taintBitsByAllModules, err := tf.GetTainterModules(allowListedModules) if err != nil { - check.LogDebug("failed to get tainter modules from node %s: %v", nodeName, err) + check.LogError("Could not get tainter modules from node %q, err: %v", nodeName, err) errNodes = append(errNodes, nodeName) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Failed to get tainter modules", false). AddField(testhelper.Error, err.Error())) @@ -323,7 +331,7 @@ func testTainted(check *checksdb.Check, env *provider.TestEnvironment) { // Create non-compliant taint objects for each of the taints for _, taint := range moduleTaints { - check.LogDebug("Node %s - module %s taints kernel: %s", nodeName, moduleName, taint) + check.LogError("Node %q - module %q taints kernel: %q", nodeName, moduleName, taint) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewTaintReportObject(nodetainted.RemoveAllExceptNumbers(taint), nodeName, taint, false).AddField(testhelper.ModuleName, moduleName)) // Set the node as non-compliant for future reporting @@ -334,7 +342,7 @@ func testTainted(check *checksdb.Check, env *provider.TestEnvironment) { // Lastly, check that all kernel taint bits come from modules. otherKernelTaints := nodetainted.GetOtherTaintedBits(taintsMask, taintBitsByAllModules) for _, taintedBit := range otherKernelTaints { - check.LogDebug("Node %s - taint bit %d is set but it is not caused by any module.", nodeName, taintedBit) + check.LogError("Node %q - taint bit %d is set but it is not caused by any module.", nodeName, taintedBit) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewTaintReportObject(strconv.Itoa(taintedBit), nodeName, nodetainted.GetTaintMsg(taintedBit), false). AddField(testhelper.ModuleName, "N/A")) otherTaints[nodeName] = append(otherTaints[nodeName], taintedBit) @@ -344,41 +352,42 @@ func testTainted(check *checksdb.Check, env *provider.TestEnvironment) { } if compliantNode { + check.LogInfo("Node %q passed the tainted kernel check", nodeName) compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(nodeName, "Passed the tainted kernel check", true)) } } - check.LogInfo("Nodes with errors: %+v", errNodes) - check.LogInfo("Bad Modules: %+v", badModules) - check.LogInfo("Taints not related to any module: %+v", otherTaints) - if len(errNodes) > 0 { - check.LogInfo("Failed to get kernel taints from some nodes: %+v", errNodes) + check.LogError("Failed to get kernel taints from some nodes: %+v", errNodes) } if len(badModules) > 0 || len(otherTaints) > 0 { - check.LogInfo("Nodes have been found to be tainted. Check claim log for more details.") + check.LogError("Nodes have been found to be tainted. Tainted modules: %+v", badModules) + } + + if len(otherTaints) > 0 { + check.LogError("Taints not related to any module: %+v", otherTaints) } check.SetResult(compliantObjects, nonCompliantObjects) } func testIsRedHatRelease(check *checksdb.Check, env *provider.TestEnvironment) { - check.LogInfo("should report a proper Red Hat version") var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject for _, cut := range env.Containers { - check.LogInfo("%s is checked for Red Hat version", cut) + check.LogInfo("Testing Container %q", cut) baseImageTester := isredhat.NewBaseImageTester(clientsholder.GetClientsHolder(), clientsholder.NewContext(cut.Namespace, cut.Podname, cut.Name)) result, err := baseImageTester.TestContainerIsRedHatRelease() if err != nil { - check.LogError("failed to collect release information from container, err=%v", err) + check.LogError("Could not collect release information from Container %q, err=%v", cut, err) } if !result { - check.LogDebug("%s has failed the RHEL release check", cut) + check.LogError("Container %q has failed the RHEL release check", cut) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Failed the RHEL release check", false)) } else { + check.LogInfo("Container %q has passed the RHEL release check", cut) compliantObjects = append(compliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Passed the RHEL release check", true)) } } @@ -400,25 +409,20 @@ func testIsSELinuxEnforcing(check *checksdb.Check, env *provider.TestEnvironment ctx := clientsholder.NewContext(debugPod.Namespace, debugPod.Name, debugPod.Spec.Containers[0].Name) outStr, errStr, err := o.ExecCommandContainer(ctx, getenforceCommand) if err != nil || errStr != "" { - check.LogError("Failed to execute command %s in debug %s, errStr: %s, err: %v", getenforceCommand, debugPod.String(), errStr, err) + check.LogError("Could not execute command %q in Debug Pod %q, errStr: %q, err: %v", getenforceCommand, debugPod, errStr, err) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewPodReportObject(debugPod.Namespace, debugPod.Name, "Failed to execute command", false)) nodesError++ continue } if outStr != enforcingString { - check.LogDebug(fmt.Sprintf("Node %s is not running selinux, %s command returned: %s", debugPod.Spec.NodeName, getenforceCommand, outStr)) + check.LogError("Node %q is not running SELinux, %s command returned: %s", debugPod.Spec.NodeName, getenforceCommand, outStr) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(debugPod.Spec.NodeName, "SELinux is not enforced", false)) nodesFailed++ } else { + check.LogInfo("Node %q is running SELinux", debugPod.Spec.NodeName) compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(debugPod.Spec.NodeName, "SELinux is enforced", true)) } } - if nodesError > 0 { - check.LogInfo("Failed because could not run %s command on %d nodes", getenforceCommand, nodesError) - } - if nodesFailed > 0 { - check.LogInfo(fmt.Sprintf("Failed because %d nodes are not running selinux", nodesFailed)) - } check.SetResult(compliantObjects, nonCompliantObjects) } @@ -428,29 +432,33 @@ func testHugepages(check *checksdb.Check, env *provider.TestEnvironment) { var nonCompliantObjects []*testhelper.ReportObject for i := range env.Nodes { node := env.Nodes[i] + nodeName := node.Data.Name + check.LogInfo("Testing node %q", nodeName) if !node.IsWorkerNode() { - compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Not a worker node", true)) + check.LogInfo("Node %q is not a worker node", nodeName) + compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(nodeName, "Not a worker node", true)) continue } - debugPod, exist := env.DebugPods[node.Data.Name] + debugPod, exist := env.DebugPods[nodeName] if !exist { - check.LogDebug("Node %s: tnf debug pod not found.", node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "tnf debug pod not found", false)) + check.LogError("Could not find a Debug Pod in node %q.", nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "tnf debug pod not found", false)) continue } hpTester, err := hugepages.NewTester(&node, debugPod, clientsholder.GetClientsHolder()) if err != nil { - check.LogDebug("Unable to get node hugepages tester for node %s, err: %v", node.Data.Name, err) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Unable to get node hugepages tester", false)) + check.LogError("Unable to get node hugepages tester for node %q, err: %v", nodeName, err) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Unable to get node hugepages tester", false)) } if err := hpTester.Run(); err != nil { - check.LogDebug("Node %s: %v", node.Data.Name, err) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, err.Error(), false)) + check.LogError("Hugepages check failed for node %q, err: %v", nodeName, err) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, err.Error(), false)) } else { - compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Passed the hugepages check", true)) + check.LogInfo("Node %q passed the hugepages check", nodeName) + compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(nodeName, "Passed the hugepages check", true)) } } @@ -462,17 +470,20 @@ func testUnalteredBootParams(check *checksdb.Check, env *provider.TestEnvironmen var nonCompliantObjects []*testhelper.ReportObject alreadyCheckedNodes := map[string]bool{} for _, cut := range env.Containers { + check.LogInfo("Testing Container %q", cut) if alreadyCheckedNodes[cut.NodeName] { - check.LogDebug("Skipping node %s: already checked.", cut.NodeName) + check.LogInfo("Skipping node %q: already checked.", cut.NodeName) continue } alreadyCheckedNodes[cut.NodeName] = true err := bootparams.TestBootParamsHelper(env, cut, check.GetLoggger()) if err != nil { + check.LogError("Node %q failed the boot params check", cut.NodeName) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(cut.NodeName, "Failed the boot params check", false). AddField(testhelper.DebugPodName, env.DebugPods[cut.NodeName].Name)) } else { + check.LogInfo("Node %q passed the boot params check", cut.NodeName) compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(cut.NodeName, "Passed the boot params check", true). AddField(testhelper.DebugPodName, env.DebugPods[cut.NodeName].Name)) } @@ -487,19 +498,21 @@ func testSysctlConfigs(check *checksdb.Check, env *provider.TestEnvironment) { alreadyCheckedNodes := map[string]bool{} for _, cut := range env.Containers { + check.LogInfo("Testing Container %q", cut) if alreadyCheckedNodes[cut.NodeName] { continue } alreadyCheckedNodes[cut.NodeName] = true debugPod := env.DebugPods[cut.NodeName] if debugPod == nil { + check.LogError("Debug Pod not found for node %q", cut.NodeName) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(cut.NodeName, "tnf debug pod not found", false)) continue } sysctlSettings, err := sysctlconfig.GetSysctlSettings(env, cut.NodeName) if err != nil { - check.LogDebug("Could not get sysctl settings for node %s, error: %v", cut.NodeName, err) + check.LogError("Could not get sysctl settings for node %q, error: %v", cut.NodeName, err) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(cut.NodeName, "Could not get sysctl settings", false)) continue } @@ -509,14 +522,15 @@ func testSysctlConfigs(check *checksdb.Check, env *provider.TestEnvironment) { for key, sysctlConfigVal := range sysctlSettings { if mcVal, ok := mcKernelArgumentsMap[key]; ok { if mcVal != sysctlConfigVal { - check.LogDebug(fmt.Sprintf("Kernel config mismatch in node %s for %s (sysctl value: %s, machine config value: %s)", - cut.NodeName, key, sysctlConfigVal, mcVal)) + check.LogError("Kernel config mismatch in node %q for %q (sysctl value: %q, machine config value: %q)", + cut.NodeName, key, sysctlConfigVal, mcVal) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(cut.NodeName, fmt.Sprintf("Kernel config mismatch for %s", key), false)) validSettings = false } } } if validSettings { + check.LogInfo("Node %q passed the sysctl config check", cut.NodeName) compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(cut.NodeName, "Passed the sysctl config check", true)) } } @@ -525,26 +539,19 @@ func testSysctlConfigs(check *checksdb.Check, env *provider.TestEnvironment) { } func testOCPStatus(check *checksdb.Check, env *provider.TestEnvironment) { - check.LogInfo("Testing the OCP Version for lifecycle status") - clusterIsInEOL := false switch env.OCPStatus { case compatibility.OCPStatusEOL: - msg := fmt.Sprintf("OCP Version %s has been found to be in end of life", env.OpenshiftVersion) - check.LogDebug(msg) + check.LogError("OCP Version %q has been found to be in end of life", env.OpenshiftVersion) clusterIsInEOL = true case compatibility.OCPStatusMS: - msg := fmt.Sprintf("OCP Version %s has been found to be in maintenance support", env.OpenshiftVersion) - check.LogDebug(msg) + check.LogInfo("OCP Version %q has been found to be in maintenance support", env.OpenshiftVersion) case compatibility.OCPStatusGA: - msg := fmt.Sprintf("OCP Version %s has been found to be in general availability", env.OpenshiftVersion) - check.LogDebug(msg) + check.LogInfo("OCP Version %q has been found to be in general availability", env.OpenshiftVersion) case compatibility.OCPStatusPreGA: - msg := fmt.Sprintf("OCP Version %s has been found to be in pre-general availability", env.OpenshiftVersion) - check.LogDebug(msg) + check.LogInfo("OCP Version %q has been found to be in pre-general availability", env.OpenshiftVersion) default: - msg := fmt.Sprintf("OCP Version %s was unable to be found in the lifecycle compatibility matrix", env.OpenshiftVersion) - check.LogDebug(msg) + check.LogInfo("OCP Version %q was unable to be found in the lifecycle compatibility matrix", env.OpenshiftVersion) } var compliantObjects []*testhelper.ReportObject @@ -561,25 +568,23 @@ func testOCPStatus(check *checksdb.Check, env *provider.TestEnvironment) { //nolint:funlen func testNodeOperatingSystemStatus(check *checksdb.Check, env *provider.TestEnvironment) { - check.LogInfo("Testing the control-plane and workers in the cluster for Operating System compatibility") - - check.LogDebug(fmt.Sprintf("There are %d nodes to process for Operating System compatibility.", len(env.Nodes))) - failedControlPlaneNodes := []string{} failedWorkerNodes := []string{} var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject for _, node := range env.Nodes { + nodeName := node.Data.Name + check.LogInfo("Testing node %q", nodeName) // Get the OSImage which should tell us what version of operating system the node is running. - check.LogDebug(fmt.Sprintf("Node %s is running operating system: %s", node.Data.Name, node.Data.Status.NodeInfo.OSImage)) + check.LogInfo("Node %q is running operating system %q", nodeName, node.Data.Status.NodeInfo.OSImage) // Control plane nodes must be RHCOS (also CentOS Stream starting in OCP 4.13) // Per the release notes from OCP documentation: // "You must use RHCOS machines for the control plane, and you can use either RHCOS or RHEL for compute machines." if node.IsMasterNode() && !node.IsRHCOS() && !node.IsCSCOS() { - check.LogDebug("Master node %s has been found to be running an incompatible operating system: %s", node.Data.Name, node.Data.Status.NodeInfo.OSImage) - failedControlPlaneNodes = append(failedControlPlaneNodes, node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Master node has been found to be running an incompatible OS", false).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) + check.LogError("Master node %q has been found to be running an incompatible operating system %q", nodeName, node.Data.Status.NodeInfo.OSImage) + failedControlPlaneNodes = append(failedControlPlaneNodes, nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Master node has been found to be running an incompatible OS", false).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) continue } @@ -590,35 +595,36 @@ func testNodeOperatingSystemStatus(check *checksdb.Check, env *provider.TestEnvi // Get the short version from the node shortVersion, err := node.GetRHCOSVersion() if err != nil { - check.LogDebug("Node %s failed to gather RHCOS version. Error: %v", node.Data.Name, err) - failedWorkerNodes = append(failedWorkerNodes, node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Failed to gather RHCOS version", false)) + check.LogError("Node %q failed to gather RHCOS version, err: %v", nodeName, err) + failedWorkerNodes = append(failedWorkerNodes, nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Failed to gather RHCOS version", false)) continue } if shortVersion == operatingsystem.NotFoundStr { - check.LogDebug("Node %s has an RHCOS operating system that is not found in our internal database. Skipping as to not cause failures due to database mismatch.", node.Data.Name) + check.LogInfo("Node %q has an RHCOS operating system that is not found in our internal database. Skipping as to not cause failures due to database mismatch.", nodeName) continue } // If the node's RHCOS version and the OpenShift version are not compatible, the node fails. - check.LogDebug("Comparing RHCOS shortVersion: %s to openshiftVersion: %s", shortVersion, env.OpenshiftVersion) + check.LogDebug("Comparing RHCOS shortVersion %q to openshiftVersion %q", shortVersion, env.OpenshiftVersion) if !compatibility.IsRHCOSCompatible(shortVersion, env.OpenshiftVersion) { - check.LogDebug("Node %s has been found to be running an incompatible version of RHCOS: %s", node.Data.Name, shortVersion) - failedWorkerNodes = append(failedWorkerNodes, node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Worker node has been found to be running an incompatible OS", false). + check.LogError("Worker node %q has been found to be running an incompatible version of RHCOS %q", nodeName, shortVersion) + failedWorkerNodes = append(failedWorkerNodes, nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Worker node has been found to be running an incompatible OS", false). AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) continue } - compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Worker node has been found to be running a compatible OS", true). + check.LogInfo("Worker node %q has been found to be running a compatible version of RHCOS %q", nodeName, shortVersion) + compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(nodeName, "Worker node has been found to be running a compatible OS", true). AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) } else if node.IsCSCOS() { // Get the short version from the node shortVersion, err := node.GetCSCOSVersion() if err != nil { - check.LogDebug("Node %s failed to gather CentOS Stream CoreOS version. Error: %v", node.Data.Name, err) - failedWorkerNodes = append(failedWorkerNodes, node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Failed to gather CentOS Stream CoreOS version", false)) + check.LogError("Node %q failed to gather CentOS Stream CoreOS version, err: %v", nodeName, err) + failedWorkerNodes = append(failedWorkerNodes, nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Failed to gather CentOS Stream CoreOS version", false)) continue } @@ -629,45 +635,41 @@ func testNodeOperatingSystemStatus(check *checksdb.Check, env *provider.TestEnvi Node %s is using CentOS Stream CoreOS %s, which is not being used yet in any OCP RC/GA version. Relaxing the conditions to check the OS as a result. ` - check.LogDebug(msg, node.Data.Name, shortVersion) + check.LogDebug(msg, nodeName, shortVersion) } else if node.IsRHEL() { // Get the short version from the node shortVersion, err := node.GetRHELVersion() if err != nil { - check.LogDebug("Node %s failed to gather RHEL version. Error: %v", node.Data.Name, err) - failedWorkerNodes = append(failedWorkerNodes, node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Failed to gather RHEL version", false)) + check.LogError("Node %q failed to gather RHEL version, err: %v", nodeName, err) + failedWorkerNodes = append(failedWorkerNodes, nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Failed to gather RHEL version", false)) continue } // If the node's RHEL version and the OpenShift version are not compatible, the node fails. - check.LogDebug("Comparing RHEL shortVersion: %s to openshiftVersion: %s", shortVersion, env.OpenshiftVersion) + check.LogDebug("Comparing RHEL shortVersion %q to openshiftVersion %q", shortVersion, env.OpenshiftVersion) if !compatibility.IsRHELCompatible(shortVersion, env.OpenshiftVersion) { - check.LogDebug("Node %s has been found to be running an incompatible version of RHEL: %s", node.Data.Name, shortVersion) - failedWorkerNodes = append(failedWorkerNodes, node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Worker node has been found to be running an incompatible OS", false).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) + check.LogError("Worker node %q has been found to be running an incompatible version of RHEL %q", nodeName, shortVersion) + failedWorkerNodes = append(failedWorkerNodes, nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Worker node has been found to be running an incompatible OS", false).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) } else { - compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Worker node has been found to be running a compatible OS", true).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) + check.LogInfo("Worker node %q has been found to be running a compatible version of RHEL %q", nodeName, shortVersion) + compliantObjects = append(compliantObjects, testhelper.NewNodeReportObject(nodeName, "Worker node has been found to be running a compatible OS", true).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) } } else { - check.LogDebug("Node %s has been found to be running an incompatible operating system", node.Data.Name) - failedWorkerNodes = append(failedWorkerNodes, node.Data.Name) - nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(node.Data.Name, "Worker node has been found to be running an incompatible OS", false).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) + check.LogError("Worker node %q has been found to be running an incompatible operating system %q", nodeName, node.Data.Status.NodeInfo.OSImage) + failedWorkerNodes = append(failedWorkerNodes, nodeName) + nonCompliantObjects = append(nonCompliantObjects, testhelper.NewNodeReportObject(nodeName, "Worker node has been found to be running an incompatible OS", false).AddField(testhelper.OSImage, node.Data.Status.NodeInfo.OSImage)) } } } - var b strings.Builder if n := len(failedControlPlaneNodes); n > 0 { - errMsg := fmt.Sprintf("Number of control plane nodes running non-RHCOS based operating systems: %d", n) - b.WriteString(errMsg) - check.LogDebug(errMsg) + check.LogError("Number of control plane nodes running non-RHCOS based operating systems: %d", n) } if n := len(failedWorkerNodes); n > 0 { - errMsg := fmt.Sprintf("Number of worker nodes running non-RHCOS or non-RHEL based operating systems: %d", n) - b.WriteString(errMsg) - check.LogDebug(errMsg) + check.LogError("Number of worker nodes running non-RHCOS or non-RHEL based operating systems: %d", n) } check.SetResult(compliantObjects, nonCompliantObjects) @@ -677,10 +679,13 @@ func testPodHugePagesSize(check *checksdb.Check, env *provider.TestEnvironment, var compliantObjects []*testhelper.ReportObject var nonCompliantObjects []*testhelper.ReportObject for _, put := range env.GetHugepagesPods() { + check.LogInfo("Testing Pod %q", put) result := put.CheckResourceHugePagesSize(size) if !result { + check.LogError("Pod %q has been found to be running with an incorrect hugepages size (expected size %q)", put, size) nonCompliantObjects = append(nonCompliantObjects, testhelper.NewPodReportObject(put.Namespace, put.Name, "Pod has been found to be running with an incorrect hugepages size", false)) } else { + check.LogInfo("Pod %q has been found to be running with a correct hugepages size %q", put, size) compliantObjects = append(compliantObjects, testhelper.NewPodReportObject(put.Namespace, put.Name, "Pod has been found to be running with a correct hugepages size", true)) } } diff --git a/pkg/provider/pods.go b/pkg/provider/pods.go index ce841caf5..4e01b498e 100644 --- a/pkg/provider/pods.go +++ b/pkg/provider/pods.go @@ -142,7 +142,6 @@ func (p *Pod) HasHugepages() bool { } func (p *Pod) CheckResourceHugePagesSize(size string) bool { - // check if hugepages configuration other than 2Mi is present for _, cut := range p.Containers { // Resources must be specified if len(cut.Resources.Requests) == 0 || len(cut.Resources.Limits) == 0 {