Skip to content

Commit 9fe3968

Browse files
authored
fix(cleaner): add /dev mount to cleanup job (#649)
mount /dev directory from host inside the container, so that wipefs performed on the disk generates a corresponding udev change event and the change is reflected on the host also. Signed-off-by: Akhil Mohan <[email protected]>
1 parent 8472a70 commit 9fe3968

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

changelogs/unreleased/649-akhilerm

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mount /dev directory from host inside container so that wipefs gets reflected immediately on the host

pkg/cleaner/jobcontroller.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package cleaner
2323
import (
2424
"context"
2525
"fmt"
26+
2627
"github.com/openebs/node-disk-manager/api/v1alpha1"
2728
"github.com/openebs/node-disk-manager/blockdevice"
2829
"github.com/openebs/node-disk-manager/cmd/ndm_daemonset/controller"
@@ -116,14 +117,23 @@ func NewCleanupJob(bd *v1alpha1.BlockDevice, volMode VolumeMode, tolerations []v
116117

117118
jobContainer.Args = []string{args}
118119

120+
var volume v1.Volume
121+
var volumeMount v1.VolumeMount
122+
119123
// in case of sparse disk, need to mount the sparse file directory
120124
// and clear the sparse file
121125
if bd.Spec.Details.DeviceType == blockdevice.SparseBlockDeviceType {
122-
volume, volumeMount := getVolumeMounts(bd.Spec.Path, bd.Spec.Path, mountName)
123-
jobContainer.VolumeMounts = []v1.VolumeMount{volumeMount}
124-
podSpec.Volumes = []v1.Volume{volume}
126+
volume, volumeMount = getVolumeMounts(bd.Spec.Path, bd.Spec.Path, mountName)
127+
} else {
128+
// for a non sparse disk, mount the /dev directory so that wipefs inside the container
129+
// gets reflected outside the container also. When this is done a correspnding change
130+
// event is also generated from udev
131+
volume, volumeMount = getVolumeMounts("/dev", "/dev", mountName)
125132
}
126133

134+
jobContainer.VolumeMounts = []v1.VolumeMount{volumeMount}
135+
podSpec.Volumes = []v1.Volume{volume}
136+
127137
} else if volMode == VolumeModeFileSystem {
128138
jobContainer.Command = []string{"/bin/sh", "-c"}
129139
jobContainer.Args = []string{"find /tmp -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf"}

0 commit comments

Comments
 (0)