Skip to content

Commit

Permalink
Merge pull request #389 from portworx/pb-7598
Browse files Browse the repository at this point in the history
pb-7598: Removed default addition of the RunAsGroup in the securityAc…
  • Loading branch information
siva-portworx authored Jul 19, 2024
2 parents 63e0fa2 + 1e023b9 commit 1f487d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/drivers/nfsbackup/nfsbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ func jobForBackupResource(
// The Job is intended to backup resources to NFS backuplocation
// and it doesn't need a specific JOB uid/gid since it will be sqaushed at NFS server
// hence used a global hardcoded UID/GID.
job, err = utils.AddSecurityContextToJob(job, utils.KdmpJobUid, utils.KdmpJobGid)
// Not passing the groupId as we do not want to set the RunAsGroup field in the securityContext
// This helps us in setting the primaryGroup ID to root for the user ID.
job, err = utils.AddSecurityContextToJob(job, utils.KdmpJobUid, "")
if err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/drivers/nfsrestore/nfsrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ func jobForRestoreResource(
},
},
}
job, err = utils.AddSecurityContextToJob(job, utils.KdmpJobUid, utils.KdmpJobGid)
// Not passing the groupId as we do not want to set the RunAsGroup field in the securityContext
// This helps us in setting the primaryGroup ID to root for the user ID.
job, err = utils.AddSecurityContextToJob(job, utils.KdmpJobUid, "")
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/drivers/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,10 @@ func AddSecurityContextToJob(job *batchv1.Job, podUserId, podGroupId string) (*b
// if the namespace is OCP, then overwrite the UID and GID from the namespace annotation
if isOcp {
podUserId = ocpUid
podGroupId = ocpGid
// In the case of the OCP, we will not update the groupId.
if podGroupId != "" {
podGroupId = ocpGid
}
}

if podUserId != "" {
Expand Down

0 comments on commit 1f487d1

Please sign in to comment.