Skip to content

Commit

Permalink
Merge branch 'main' into update-rhcos-map
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavid authored Oct 31, 2023
2 parents f6e0eee + d6177a4 commit 6b5e332
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
31 changes: 28 additions & 3 deletions cnf-certification-test/performance/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package performance
import (
"fmt"
"strconv"
"strings"

"github.com/onsi/ginkgo/v2"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -232,30 +233,54 @@ func testSchedulingPolicyInCPUPool(env *provider.TestEnvironment,
testhelper.AddTestResultReason(compliantContainersPids, nonCompliantContainersPids, tnf.ClaimFilePrintf, ginkgo.Fail)
}

const noProcessFoundErrMsg = "No such process"

func testRtAppsNoExecProbes(env *provider.TestEnvironment, cuts []*provider.Container) {
var compliantObjects []*testhelper.ReportObject
var nonCompliantObjects []*testhelper.ReportObject
for _, cut := range cuts {
if !cut.HasExecProbes() {
compliantObjects = append(compliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Container does not define exec probes", true))
continue
}

processes, err := crclient.GetContainerProcesses(cut, env)
if err != nil {
tnf.ClaimFilePrintf("Could not determine the processes pids for container %s, err: %v", cut, err)
nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Could not determine the processes pids for container", false))
break
}

allProcessesCompliant := true
for _, p := range processes {
schedPolicy, _, err := scheduling.GetProcessCPUScheduling(p.Pid, cut)
if err != nil {
// If the process does not exist anymore it means that it has finished since the time the process list
// was retrieved. In this case, just ignore the error and continue processing the rest of the processes.
if strings.Contains(err.Error(), noProcessFoundErrMsg) {
compliantObjects = append(compliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Container process disappeared", true).
AddField(testhelper.ProcessID, strconv.Itoa(p.Pid)).
AddField(testhelper.ProcessCommandLine, p.Args))
continue
}
tnf.ClaimFilePrintf("Could not determine the scheduling policy for container %s (pid=%v), err: %v", cut, p.Pid, err)
nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Could not determine the scheduling policy for container", false).
AddField(testhelper.ProcessID, strconv.Itoa(p.Pid)))
break
AddField(testhelper.ProcessID, strconv.Itoa(p.Pid)).
AddField(testhelper.ProcessCommandLine, p.Args))
allProcessesCompliant = false
continue
}
if scheduling.PolicyIsRT(schedPolicy) && cut.HasExecProbes() {
if scheduling.PolicyIsRT(schedPolicy) {
tnf.ClaimFilePrintf("Pod %s/Container %s defines exec probes while having a RT scheduling policy for pid %d", cut.Podname, cut, p.Pid)
nonCompliantObjects = append(nonCompliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Container defines exec probes while having a RT scheduling policy", false).
AddField(testhelper.ProcessID, strconv.Itoa(p.Pid)))
allProcessesCompliant = false
}
}

if allProcessesCompliant {
compliantObjects = append(compliantObjects, testhelper.NewContainerReportObject(cut.Namespace, cut.Podname, cut.Name, "Container defines exec probes but does not have a RT scheduling policy", true))
}
}
testhelper.AddTestResultReason(compliantObjects, nonCompliantObjects, tnf.ClaimFilePrintf, ginkgo.Fail)
}
3 changes: 2 additions & 1 deletion pkg/scheduling/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func GetProcessCPUScheduling(pid int, testContainer *provider.Container) (schedu

stdout, stderr, err := ch.ExecCommandContainer(ctx, command)
if err != nil || stderr != "" {
return schedulePolicy, InvalidPriority, fmt.Errorf("command %q failed to run in debug pod %s (node %s): %v", command, ctx.GetPodName(), testContainer.NodeName, err)
return schedulePolicy, InvalidPriority, fmt.Errorf("command %q failed to run in debug pod %s (node %s): %v (stderr: %v)",
command, ctx.GetPodName(), testContainer.NodeName, err, stderr)
}

schedulePolicy, schedulePriority, err = parseSchedulingPolicyAndPriority(stdout)
Expand Down

0 comments on commit 6b5e332

Please sign in to comment.