Implement CanMount() for gfsMounter for linux

This commit is contained in:
rkouj 2016-11-11 17:30:20 -08:00
parent f228edbf8e
commit b85ac95143

View File

@ -35,6 +35,7 @@ import (
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
volutil "k8s.io/kubernetes/pkg/volume/util"
"runtime"
)
// This is the primary entrypoint for volume plugins.
@ -66,6 +67,7 @@ const (
annGlusterSecretNamespace = "glusterfs.kubernetes.io/secretnamespace"
annGlusterUserKey = "glusterfs.kubernetes.io/userkey"
annGlusterUser = "glusterfs.kubernetes.io/userid"
gciGlusterMountBinariesPath = "/sbin/mount.glusterfs"
)
func (plugin *glusterfsPlugin) Init(host volume.VolumeHost) error {
@ -211,6 +213,13 @@ func (b *glusterfsMounter) GetAttributes() volume.Attributes {
// to mount the volume are available on the underlying node.
// If not, it returns an error
func (b *glusterfsMounter) CanMount() error {
exe := exec.New()
switch runtime.GOOS {
case "linux":
if _, err := exe.Command("/bin/ls", gciGlusterMountBinariesPath).CombinedOutput(); err != nil {
return fmt.Errorf("Required binary %s is missing", gciGlusterMountBinariesPath)
}
}
return nil
}