Skip to content

Commit e1eb210

Browse files
authored
fsdiff: add panic prevention (#2859)
1 parent 00e83a6 commit e1eb210

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/platform/suite.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,20 @@ func testContainersFsDiff(check *checksdb.Check, env *provider.TestEnvironment)
231231
check.LogInfo("Testing Container %q", cut)
232232
probePod := env.ProbePods[cut.NodeName]
233233

234+
// If the probe pod is not found, we cannot run the test.
235+
if probePod == nil {
236+
check.LogError("Probe Pod not found for node %q", cut.NodeName)
237+
nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "certsuite probe pod not found", false))
238+
continue
239+
}
240+
241+
// Check whether or not a container is available to prevent a panic.
242+
if len(probePod.Spec.Containers) == 0 {
243+
check.LogError("Probe Pod %q has no containers", probePod)
244+
nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "certsuite probe pod has no containers", false))
245+
continue
246+
}
247+
234248
ctxt := clientsholder.NewContext(probePod.Namespace, probePod.Name, probePod.Spec.Containers[0].Name)
235249
fsDiffTester := cnffsdiff.NewFsDiffTester(check, clientsholder.GetClientsHolder(), ctxt, env.OpenshiftVersion)
236250
fsDiffTester.RunTest(cut.UID)

0 commit comments

Comments
 (0)