Skip to content

Commit ab9b4b9

Browse files
committed
Fix so that udevadm can be run from inside kubernetes container on the host
1 parent b85c3a2 commit ab9b4b9

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ FROM gcr.io/google-containers/debian-base-amd64:0.3
2525
COPY --from=builder /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver /gce-pd-csi-driver
2626

2727
# Install necessary dependencies
28-
RUN clean-install util-linux e2fsprogs mount ca-certificates
28+
RUN clean-install util-linux e2fsprogs mount ca-certificates udev
2929

3030
ENTRYPOINT ["/gce-pd-csi-driver"]

deploy/kubernetes/dev/node.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ spec:
5151
- name: plugin-dir
5252
mountPath: /csi
5353
- name: device-dir
54-
mountPath: /host/dev
54+
mountPath: /dev
55+
# The following mounts are required to trigger host udevadm from container
56+
- name: udev-rules-etc
57+
mountPath: /etc/udev
58+
- name: udev-rules-lib
59+
mountPath: /lib/udev
60+
- name: udev-socket
61+
mountPath: /run/udev
62+
- name: sys
63+
mountPath: /sys
5564
volumes:
5665
- name: registration-dir
5766
hostPath:
@@ -68,4 +77,21 @@ spec:
6877
- name: device-dir
6978
hostPath:
7079
path: /dev
80+
type: Directory
81+
# The following mounts are required to trigger host udevadm from container
82+
- name: udev-rules-etc
83+
hostPath:
84+
path: /etc/udev
85+
type: Directory
86+
- name: udev-rules-lib
87+
hostPath:
88+
path: /lib/udev
89+
type: Directory
90+
- name: udev-socket
91+
hostPath:
92+
path: /run/udev
93+
type: Directory
94+
- name: sys
95+
hostPath:
96+
path: /sys
7197
type: Directory

pkg/mount-manager/device-utils.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ import (
2727
)
2828

2929
const (
30-
diskByHostIdPath = "/host/dev/disk/by-id/"
3130
diskByIdPath = "/dev/disk/by-id/"
3231
diskGooglePrefix = "google-"
3332
diskScsiGooglePrefix = "scsi-0Google_PersistentDisk_"
3433
diskPartitionSuffix = "-part"
35-
diskSDPath = "/host/dev/sd"
36-
diskSDPattern = "/host/dev/sd*"
34+
diskSDPath = "/dev/sd"
35+
diskSDPattern = "/dev/sd*"
3736
// How many times to retry for a consistent read of /proc/mounts.
3837
maxListTries = 3
3938
// Number of fields per line in /proc/mounts as per the fstab man page.
@@ -75,8 +74,6 @@ func (m *deviceUtils) GetDiskByIdPaths(deviceName string, partition string) []st
7574
devicePaths := []string{
7675
path.Join(diskByIdPath, diskGooglePrefix+deviceName),
7776
path.Join(diskByIdPath, diskScsiGooglePrefix+deviceName),
78-
path.Join(diskByHostIdPath, diskScsiGooglePrefix+deviceName),
79-
path.Join(diskByHostIdPath, diskScsiGooglePrefix+deviceName),
8077
}
8178

8279
if partition != "" {

0 commit comments

Comments
 (0)