Skip to content

Commit

Permalink
ssc: update correct SELinux option
Browse files Browse the repository at this point in the history
set the SSC with the correct SELinux option,
given we use custom policy or not.

Signed-off-by: Talor Itzhak <[email protected]>
  • Loading branch information
Tal-or committed Sep 30, 2024
1 parent 5631c40 commit 0d6dc0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions controllers/numaresourcesoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ func (r *NUMAResourcesOperatorReconciler) syncNUMAResourcesOperatorResources(ctx
}
rteupdate.DaemonSetHashAnnotation(r.RTEManifests.DaemonSet, cmHash)
}
rteupdate.SecurityContextConstraintSetSELinuxOption(r.RTEManifests.SecurityContextConstraint, instance.IsCustomPolicyEnabled())

existing := rtestate.FromClient(ctx, r.Client, r.Platform, r.RTEManifests, instance, trees, r.Namespace)
for _, objState := range existing.State(r.RTEManifests, instance, daemonsetUpdater) {
Expand Down
12 changes: 12 additions & 0 deletions pkg/objectupdate/rte/rte.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/klog/v2"

securityv1 "github.com/openshift/api/security/v1"

"github.com/k8stopologyawareschedwg/deployer/pkg/assets/selinux"
"github.com/k8stopologyawareschedwg/deployer/pkg/flagcodec"
k8swgobjupdate "github.com/k8stopologyawareschedwg/deployer/pkg/objectupdate"
k8swgrteupdate "github.com/k8stopologyawareschedwg/deployer/pkg/objectupdate/rte"
Expand Down Expand Up @@ -219,6 +222,15 @@ func AddVolumeMountMemory(podSpec *corev1.PodSpec, cnt *corev1.Container, mountN
)
}

func SecurityContextConstraintSetSELinuxOption(scc *securityv1.SecurityContextConstraints, legacyRTEContext bool) {
if legacyRTEContext {
scc.SELinuxContext.SELinuxOptions.Type = selinux.RTEContextTypeLegacy
return
}
scc.SELinuxContext.SELinuxOptions.Type = selinux.RTEContextType

}

Check failure on line 232 in pkg/objectupdate/rte/rte.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unnecessary trailing newline (whitespace)

Check failure on line 232 in pkg/objectupdate/rte/rte.go

View workflow job for this annotation

GitHub Actions / build

unnecessary trailing newline (whitespace)

func isPodFingerprintEnabled(conf *nropv1.NodeGroupConfig) (bool, string) {
cfg := nropv1.DefaultNodeGroupConfig()
if conf == nil || conf.PodsFingerprinting == nil {
Expand Down

0 comments on commit 0d6dc0e

Please sign in to comment.