Skip to content

Commit

Permalink
Skip access-control-sys-nice-realtime-capability if there's no nodes …
Browse files Browse the repository at this point in the history
…using realtime kernel. (#2763)

* Skip access-control-sys-nice-realtime-capability if there's no nodes using realtime kernel.

There's no point in running this check if there isn't any node using
realtime kernel, so I added a custom skip function for it.

Anyway, if nodes with realtime kernel exist, it's still possible/compliant
to deploy workload pods in non-realtime kernel nodes, irrespective of
the sys_nice cap. For pods deployed in realtime kernel nodes, it's
mandatory for this cap to be set at container level.

* Add tc as skipped in expected_results.yaml
  • Loading branch information
greyerof authored Feb 5, 2025
1 parent 6592b7d commit 5b5a939
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion expected_results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ testCases:
- access-control-service-type
- access-control-ssh-daemons
- access-control-sys-admin-capability-check
- access-control-sys-nice-realtime-capability
- lifecycle-affinity-required-pods
- lifecycle-container-prestop
- lifecycle-container-poststart
Expand Down Expand Up @@ -67,6 +66,7 @@ testCases:
- affiliated-certification-container-is-certified-digest # test container image is not certified
skip:
- access-control-sys-ptrace-capability
- access-control-sys-nice-realtime-capability
- affiliated-certification-helm-version
- affiliated-certification-helmchart-is-certified
- affiliated-certification-operator-is-certified
Expand Down
15 changes: 15 additions & 0 deletions pkg/testhelper/testhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,21 @@ func GetNoOperatorCrdsSkipFn(env *provider.TestEnvironment) func() (bool, string
}
}

// The returned func returns true (skip) if there isn't any node using realtime kernel type.
func GetNoNodesWithRealtimeKernelSkipFn(env *provider.TestEnvironment) func() (bool, string) {
return func() (bool, string) {
for i := range env.Nodes {
node := env.Nodes[i]

if node.IsRTKernel() {
return false, ""
}
}

return true, "no nodes with realtime kernel type found"
}
}

func ResultObjectsToString(compliantObject, nonCompliantObject []*ReportObject) (string, error) {
reason := FailureReasonOut{
CompliantObjectsOut: compliantObject,
Expand Down
1 change: 1 addition & 0 deletions tests/accesscontrol/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func LoadChecks() {

checksGroup.Add(checksdb.NewCheck(identifiers.GetTestIDAndLabels(identifiers.TestSYSNiceRealtimeCapabilityIdentifier)).
WithSkipCheckFn(testhelper.GetNoContainersUnderTestSkipFn(&env)).
WithSkipCheckFn(testhelper.GetNoNodesWithRealtimeKernelSkipFn(&env)).
WithCheckFn(func(c *checksdb.Check) error {
testSYSNiceRealtimeCapability(c, &env)
return nil
Expand Down

0 comments on commit 5b5a939

Please sign in to comment.