Skip to content

Commit 9be1191

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#36686 from rkouj/check-gluster-fs-binaries
Automatic merge from submit-queue Implement CanMount() for gfsMounter for linux **What this PR does / why we need it**: To implement CanMount() check for glusterfs. If mount binaries are not present on the underlying node, the mount will not proceed and return an error message stating so. Related to issue : kubernetes#36098 Related to similar change for NFS : kubernetes#36280 **Release note**: `Check binaries for GlusterFS on the underlying node before doing mount` Sample output from testing in GCE/GCI: rkouj@rkouj0:~/go/src/k8s.io/kubernetes$ kubectl describe pods Name: glusterfs Namespace: default Node: e2e-test-rkouj-minion-group-kjq3/10.240.0.3 Start Time: Fri, 11 Nov 2016 17:22:04 -0800 Labels: <none> Status: Pending IP: Controllers: <none> Containers: glusterfs: Container ID: Image: gcr.io/google_containers/busybox Image ID: Port: QoS Tier: cpu: Burstable memory: BestEffort Requests: cpu: 100m State: Waiting Reason: ContainerCreating Ready: False Restart Count: 0 Environment Variables: Conditions: Type Status Initialized True Ready False PodScheduled True Volumes: glusterfs: Type: Glusterfs (a Glusterfs mount on the host that shares a pod's lifetime) EndpointsName: glusterfs-cluster Path: kube_vol ReadOnly: true default-token-2zcao: Type: Secret (a volume populated by a Secret) SecretName: default-token-2zcao Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 8s 8s 1 {default-scheduler } Normal Scheduled Successfully assigned glusterfs to e2e-test-rkouj-minion-group-kjq3 7s 4s 4 {kubelet e2e-test-rkouj-minion-group-kjq3} Warning FailedMount Unable to mount volume kubernetes.io/glusterfs/6bb04587-a876-11e6-a712-42010af00002-glusterfs (spec.Name: glusterfs) on pod glusterfs (UID: 6bb04587-a876-11e6-a712-42010af00002). Verify that your node machine has the required components before attempting to mount this volume type. Required binary /sbin/mount.glusterfs is missing
2 parents c5c461d + b85ac95 commit 9be1191

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

pkg/volume/glusterfs/glusterfs.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"k8s.io/kubernetes/pkg/util/strings"
3636
"k8s.io/kubernetes/pkg/volume"
3737
volutil "k8s.io/kubernetes/pkg/volume/util"
38+
"runtime"
3839
)
3940

4041
// This is the primary entrypoint for volume plugins.
@@ -55,17 +56,18 @@ var _ volume.Provisioner = &glusterfsVolumeProvisioner{}
5556
var _ volume.Deleter = &glusterfsVolumeDeleter{}
5657

5758
const (
58-
glusterfsPluginName = "kubernetes.io/glusterfs"
59-
volPrefix = "vol_"
60-
dynamicEpSvcPrefix = "glusterfs-dynamic-"
61-
replicaCount = 3
62-
durabilityType = "replicate"
63-
secretKeyName = "key" // key name used in secret
64-
annGlusterURL = "glusterfs.kubernetes.io/url"
65-
annGlusterSecretName = "glusterfs.kubernetes.io/secretname"
66-
annGlusterSecretNamespace = "glusterfs.kubernetes.io/secretnamespace"
67-
annGlusterUserKey = "glusterfs.kubernetes.io/userkey"
68-
annGlusterUser = "glusterfs.kubernetes.io/userid"
59+
glusterfsPluginName = "kubernetes.io/glusterfs"
60+
volPrefix = "vol_"
61+
dynamicEpSvcPrefix = "glusterfs-dynamic-"
62+
replicaCount = 3
63+
durabilityType = "replicate"
64+
secretKeyName = "key" // key name used in secret
65+
annGlusterURL = "glusterfs.kubernetes.io/url"
66+
annGlusterSecretName = "glusterfs.kubernetes.io/secretname"
67+
annGlusterSecretNamespace = "glusterfs.kubernetes.io/secretnamespace"
68+
annGlusterUserKey = "glusterfs.kubernetes.io/userkey"
69+
annGlusterUser = "glusterfs.kubernetes.io/userid"
70+
gciGlusterMountBinariesPath = "/sbin/mount.glusterfs"
6971
)
7072

7173
func (plugin *glusterfsPlugin) Init(host volume.VolumeHost) error {
@@ -211,6 +213,13 @@ func (b *glusterfsMounter) GetAttributes() volume.Attributes {
211213
// to mount the volume are available on the underlying node.
212214
// If not, it returns an error
213215
func (b *glusterfsMounter) CanMount() error {
216+
exe := exec.New()
217+
switch runtime.GOOS {
218+
case "linux":
219+
if _, err := exe.Command("/bin/ls", gciGlusterMountBinariesPath).CombinedOutput(); err != nil {
220+
return fmt.Errorf("Required binary %s is missing", gciGlusterMountBinariesPath)
221+
}
222+
}
214223
return nil
215224
}
216225

0 commit comments

Comments
 (0)