Skip to content

Commit

Permalink
Fix so that udevadm can be run from inside kubernetes container on th…
Browse files Browse the repository at this point in the history
…e host
  • Loading branch information
davidz627 committed Oct 3, 2018
1 parent b85c3a2 commit ab9b4b9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ FROM gcr.io/google-containers/debian-base-amd64:0.3
COPY --from=builder /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver /gce-pd-csi-driver

# Install necessary dependencies
RUN clean-install util-linux e2fsprogs mount ca-certificates
RUN clean-install util-linux e2fsprogs mount ca-certificates udev

ENTRYPOINT ["/gce-pd-csi-driver"]
28 changes: 27 additions & 1 deletion deploy/kubernetes/dev/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ spec:
- name: plugin-dir
mountPath: /csi
- name: device-dir
mountPath: /host/dev
mountPath: /dev
# The following mounts are required to trigger host udevadm from container
- name: udev-rules-etc
mountPath: /etc/udev
- name: udev-rules-lib
mountPath: /lib/udev
- name: udev-socket
mountPath: /run/udev
- name: sys
mountPath: /sys
volumes:
- name: registration-dir
hostPath:
Expand All @@ -68,4 +77,21 @@ spec:
- name: device-dir
hostPath:
path: /dev
type: Directory
# The following mounts are required to trigger host udevadm from container
- name: udev-rules-etc
hostPath:
path: /etc/udev
type: Directory
- name: udev-rules-lib
hostPath:
path: /lib/udev
type: Directory
- name: udev-socket
hostPath:
path: /run/udev
type: Directory
- name: sys
hostPath:
path: /sys
type: Directory
7 changes: 2 additions & 5 deletions pkg/mount-manager/device-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ import (
)

const (
diskByHostIdPath = "/host/dev/disk/by-id/"
diskByIdPath = "/dev/disk/by-id/"
diskGooglePrefix = "google-"
diskScsiGooglePrefix = "scsi-0Google_PersistentDisk_"
diskPartitionSuffix = "-part"
diskSDPath = "/host/dev/sd"
diskSDPattern = "/host/dev/sd*"
diskSDPath = "/dev/sd"
diskSDPattern = "/dev/sd*"
// How many times to retry for a consistent read of /proc/mounts.
maxListTries = 3
// Number of fields per line in /proc/mounts as per the fstab man page.
Expand Down Expand Up @@ -75,8 +74,6 @@ func (m *deviceUtils) GetDiskByIdPaths(deviceName string, partition string) []st
devicePaths := []string{
path.Join(diskByIdPath, diskGooglePrefix+deviceName),
path.Join(diskByIdPath, diskScsiGooglePrefix+deviceName),
path.Join(diskByHostIdPath, diskScsiGooglePrefix+deviceName),
path.Join(diskByHostIdPath, diskScsiGooglePrefix+deviceName),
}

if partition != "" {
Expand Down

0 comments on commit ab9b4b9

Please sign in to comment.