mirror of https://github.com/kubernetes/kops.git
protokube: check for device symlinks
This commit is contained in:
parent
1eee3c35a1
commit
b0ef6a2f99
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue