Skip to content

Commit

Permalink
core: run discover daemonset as root uid
Browse files Browse the repository at this point in the history
So that the tool inside the container has the permission to run
correctly, e.g: sgdisk.

Clsoes: #9493
Signed-off-by: Sébastien Han <seb@redhat.com>
(cherry picked from commit dd67b86)
  • Loading branch information
leseb authored and mergify-bot committed Jan 4, 2022
1 parent ca89626 commit 78c2965
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/operator/discover/discover.go
Expand Up @@ -30,6 +30,7 @@ import (
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/clusterd"
discoverDaemon "github.com/rook/rook/pkg/daemon/discover"
"github.com/rook/rook/pkg/operator/ceph/controller"
k8sutil "github.com/rook/rook/pkg/operator/k8sutil"
"github.com/rook/rook/pkg/util/sys"

Expand Down Expand Up @@ -79,7 +80,6 @@ func (d *Discover) Start(ctx context.Context, namespace, discoverImage, security
}

func (d *Discover) createDiscoverDaemonSet(ctx context.Context, namespace, discoverImage, securityAccount string, useCephVolume bool) error {
privileged := true
discovery_parameters := []string{"discover",
"--discover-interval", getEnvVar(discoverIntervalEnv, defaultDiscoverInterval)}
if useCephVolume {
Expand Down Expand Up @@ -108,12 +108,10 @@ func (d *Discover) createDiscoverDaemonSet(ctx context.Context, namespace, disco
ServiceAccountName: securityAccount,
Containers: []v1.Container{
{
Name: discoverDaemonsetName,
Image: discoverImage,
Args: discovery_parameters,
SecurityContext: &v1.SecurityContext{
Privileged: &privileged,
},
Name: discoverDaemonsetName,
Image: discoverImage,
Args: discovery_parameters,
SecurityContext: controller.PrivilegedContext(true),
VolumeMounts: []v1.VolumeMount{
{
Name: "dev",
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/discover/discover_test.go
Expand Up @@ -79,6 +79,7 @@ func TestStartDiscoveryDaemonset(t *testing.T) {
assert.Equal(t, "mysa", agentDS.Spec.Template.Spec.ServiceAccountName)
assert.Equal(t, "my-priority-class", agentDS.Spec.Template.Spec.PriorityClassName)
assert.True(t, *agentDS.Spec.Template.Spec.Containers[0].SecurityContext.Privileged)
assert.Equal(t, int64(0), *agentDS.Spec.Template.Spec.Containers[0].SecurityContext.RunAsUser)
volumes := agentDS.Spec.Template.Spec.Volumes
assert.Equal(t, 3, len(volumes))
volumeMounts := agentDS.Spec.Template.Spec.Containers[0].VolumeMounts
Expand Down

0 comments on commit 78c2965

Please sign in to comment.