@@ -43,7 +43,7 @@ const (
43
43
linkedPodsKey = ".metadata.activeWorkloads"
44
44
StatusToProfLabel = "spo.x-k8s.io/profile-id"
45
45
reconcileTimeout = 1 * time .Minute
46
- pathParts = 3
46
+ pathParts = 2
47
47
)
48
48
49
49
// NewController returns a new empty controller instance.
@@ -129,8 +129,8 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req reconcile.Request) (r
129
129
continue
130
130
}
131
131
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" )
134
134
seccompProfile := & seccompprofileapi.SeccompProfile {}
135
135
136
136
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
152
152
profileName := strings .TrimSuffix (profileIndex , profileSuffix )
153
153
154
154
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 {
156
156
logger .Error (err , "could not get selinux profile for pod" )
157
157
158
158
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
317
317
// try to get profile from pod securityContext
318
318
sc := pod .Spec .SecurityContext
319
319
if sc != nil {
320
- if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , pod . GetNamespace () ) {
320
+ if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , "" ) {
321
321
profiles = append (profiles , sc .SELinuxOptions .Type )
322
322
}
323
323
}
@@ -328,7 +328,7 @@ func getSelinuxProfilesFromPod(ctx context.Context, r *PodReconciler, pod *corev
328
328
for i := range containers {
329
329
sc := containers [i ].SecurityContext
330
330
if sc != nil {
331
- if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , pod . GetNamespace () ) {
331
+ if isOperatorSelinuxType (ctx , r , sc .SELinuxOptions , "" ) {
332
332
profileString := containers [i ].SecurityContext .SELinuxOptions .Type
333
333
if ! util .Contains (profiles , profileString ) {
334
334
profiles = append (profiles , profileString )
0 commit comments