@@ -43,7 +43,7 @@ const (
4343 linkedPodsKey = ".metadata.activeWorkloads"
4444 StatusToProfLabel = "spo.x-k8s.io/profile-id"
4545 reconcileTimeout = 1 * time .Minute
46- pathParts = 3
46+ pathParts = 2
4747)
4848
4949// NewController returns a new empty controller instance.
@@ -129,8 +129,8 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req reconcile.Request) (r
129129 continue
130130 }
131131
132- profileNamespace := profileElements [ 1 ]
133- profileName := strings .TrimSuffix (profileElements [2 ], ".json" )
132+ profileNamespace := "" // It is a cluster wide profile.
133+ profileName := strings .TrimSuffix (profileElements [1 ], ".json" )
134134 seccompProfile := & seccompprofileapi.SeccompProfile {}
135135
136136 if err := r .client .Get (ctx , util .NamespacedName (profileName , profileNamespace ), seccompProfile ); err != nil {
@@ -152,7 +152,7 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req reconcile.Request) (r
152152 profileName := strings .TrimSuffix (profileIndex , profileSuffix )
153153
154154 selinuxProfile := & selinuxprofileapi.SelinuxProfile {}
155- if err := r .client .Get (ctx , util .NamespacedName (profileName , pod . GetNamespace () ), selinuxProfile ); err != nil {
155+ if err := r .client .Get (ctx , util .NamespacedName (profileName , "" ), selinuxProfile ); err != nil {
156156 logger .Error (err , "could not get selinux profile for pod" )
157157
158158 return reconcile.Result {}, fmt .Errorf ("looking up SelinuxProfile for new or updated pod: %w" , err )
@@ -317,7 +317,7 @@ func getSelinuxProfilesFromPod(ctx context.Context, r *PodReconciler, pod *corev
317317 // try to get profile from pod securityContext
318318 sc := pod .Spec .SecurityContext
319319 if sc != nil {
320- if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , pod . GetNamespace () ) {
320+ if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , "" ) {
321321 profiles = append (profiles , sc .SELinuxOptions .Type )
322322 }
323323 }
@@ -328,7 +328,7 @@ func getSelinuxProfilesFromPod(ctx context.Context, r *PodReconciler, pod *corev
328328 for i := range containers {
329329 sc := containers [i ].SecurityContext
330330 if sc != nil {
331- if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , pod . GetNamespace () ) {
331+ if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , "" ) {
332332 profileString := containers [i ].SecurityContext .SELinuxOptions .Type
333333 if ! util .Contains (profiles , profileString ) {
334334 profiles = append (profiles , profileString )
0 commit comments