diff --git a/protokube/pkg/protokube/kube_boot.go b/protokube/pkg/protokube/kube_boot.go index e723a2b267..6e06e298c2 100644 --- a/protokube/pkg/protokube/kube_boot.go +++ b/protokube/pkg/protokube/kube_boot.go @@ -19,6 +19,7 @@ package protokube import ( "fmt" "net" + "path/filepath" "time" "github.com/golang/glog" @@ -195,6 +196,17 @@ func pathFor(hostPath string) string { return RootFS + hostPath[1:] } +func pathForSymlinks(hostPath string) string { + path := pathFor(hostPath) + + symlink, err := filepath.EvalSymlinks(path) + if err != nil { + return path + } + + return symlink +} + func (k *KubeBoot) String() string { return DebugString(k) } diff --git a/protokube/pkg/protokube/volume_mounter.go b/protokube/pkg/protokube/volume_mounter.go index 64d510afa1..22edf6c112 100644 --- a/protokube/pkg/protokube/volume_mounter.go +++ b/protokube/pkg/protokube/volume_mounter.go @@ -187,8 +187,8 @@ func (k *VolumeMountController) safeFormatAndMount(volume *Volume, mountpoint st } if mountedDevice != "" { - // We check that it is the correct device. We also tolerate /dev/X as well as /root/dev/X - if mountedDevice != source && mountedDevice != device { + // We check that it is the correct device. We also tolerate /dev/X as well as /root/dev/X and any of symlinks to them + if mountedDevice != source && mountedDevice != device && pathFor(mountedDevice) != pathForSymlinks(device) { return fmt.Errorf("device already mounted at %s, but is %s and we want %s or %s", target, mountedDevice, source, device) } } else {