Skip to content

Commit

Permalink
Merge pull request rook#1746 from benceszikora/fix-udevadm
Browse files Browse the repository at this point in the history
Fix udevadm providing incomplete info by mounting /run/udev
  • Loading branch information
jbw976 authored May 26, 2018
2 parents c180c90 + 144c9ee commit b2a3579
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pkg/operator/ceph/cluster/osd/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func (c *Cluster) podTemplateSpec(devices []rookalpha.Device, selection rookalph
// create volume config for the data dir and /dev so the pod can access devices on the host
devVolume := v1.Volume{Name: "devices", VolumeSource: v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: "/dev"}}}
volumes = append(volumes, devVolume)
udevVolume := v1.Volume{Name: "udev", VolumeSource: v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: "/run/udev"}}}
volumes = append(volumes, udevVolume)
}

// add each OSD directory as another host path volume source
Expand Down Expand Up @@ -187,6 +189,8 @@ func (c *Cluster) osdContainer(devices []rookalpha.Device, selection rookalpha.S
if devMountNeeded {
devMount := v1.VolumeMount{Name: "devices", MountPath: "/dev"}
volumeMounts = append(volumeMounts, devMount)
udevMount := v1.VolumeMount{Name: "udev", MountPath: "/run/udev"}
volumeMounts = append(volumeMounts, udevMount)
}

if len(selection.Directories) > 0 {
Expand Down
14 changes: 7 additions & 7 deletions pkg/operator/ceph/cluster/osd/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func testPodDevices(t *testing.T, dataDir, deviceFilter string, allDevices bool)
assert.Equal(t, "node1", replicaSet.Spec.Template.Spec.NodeSelector[apis.LabelHostname])
assert.Equal(t, v1.RestartPolicyAlways, replicaSet.Spec.Template.Spec.RestartPolicy)
if devMountNeeded {
assert.Equal(t, 3, len(replicaSet.Spec.Template.Spec.Volumes))
assert.Equal(t, 4, len(replicaSet.Spec.Template.Spec.Volumes))
} else {
assert.Equal(t, 2, len(replicaSet.Spec.Template.Spec.Volumes))
}
Expand All @@ -95,7 +95,7 @@ func testPodDevices(t *testing.T, dataDir, deviceFilter string, allDevices bool)
cont := replicaSet.Spec.Template.Spec.Containers[0]
assert.Equal(t, "rook/rook:myversion", cont.Image)
if devMountNeeded {
assert.Equal(t, 3, len(cont.VolumeMounts))
assert.Equal(t, 4, len(cont.VolumeMounts))
} else {
assert.Equal(t, 2, len(cont.VolumeMounts))
}
Expand Down Expand Up @@ -157,14 +157,14 @@ func TestStorageSpecDevicesAndDirectories(t *testing.T) {

// pod spec should have a volume for the given dir
podSpec := replicaSet.Spec.Template.Spec
assert.Equal(t, 4, len(podSpec.Volumes))
assert.Equal(t, "rook-dir1", podSpec.Volumes[3].Name)
assert.Equal(t, "/rook/dir1", podSpec.Volumes[3].VolumeSource.HostPath.Path)
assert.Equal(t, 5, len(podSpec.Volumes))
assert.Equal(t, "rook-dir1", podSpec.Volumes[4].Name)
assert.Equal(t, "/rook/dir1", podSpec.Volumes[4].VolumeSource.HostPath.Path)

// container should have a volume mount for the given dir
container := podSpec.Containers[0]
assert.Equal(t, "rook-dir1", container.VolumeMounts[3].Name)
assert.Equal(t, "/rook/dir1", container.VolumeMounts[3].MountPath)
assert.Equal(t, "rook-dir1", container.VolumeMounts[4].Name)
assert.Equal(t, "/rook/dir1", container.VolumeMounts[4].MountPath)

// container command should have the given dir and device
verifyEnvVar(t, container.Env, "ROOK_DATA_DIRECTORIES", "/rook/dir1", true)
Expand Down

0 comments on commit b2a3579

Please sign in to comment.