@@ -19,6 +19,7 @@ package glusterfs
19
19
import (
20
20
"fmt"
21
21
"math"
22
+ "math/rand"
22
23
"os"
23
24
"path/filepath"
24
25
"runtime"
@@ -186,13 +187,13 @@ func (plugin *glusterfsPlugin) getEndpointNameAndNamespace(spec *volume.Spec, de
186
187
}
187
188
return endpoints , endpointsNs , nil
188
189
}
189
- return "" , "" , fmt .Errorf ("Spec does not reference a GlusterFS volume type" )
190
+ return "" , "" , fmt .Errorf ("spec does not reference a GlusterFS volume type" )
190
191
191
192
}
192
193
func (plugin * glusterfsPlugin ) newMounterInternal (spec * volume.Spec , ep * v1.Endpoints , pod * v1.Pod , mounter mount.Interface ) (volume.Mounter , error ) {
193
194
volPath , readOnly , err := getVolumeInfo (spec )
194
195
if err != nil {
195
- klog .Errorf ("failed to get volumesource : %v" , err )
196
+ klog .Errorf ("failed to get volumesource: %v" , err )
196
197
return nil , err
197
198
}
198
199
return & glusterfsMounter {
@@ -267,7 +268,7 @@ func (b *glusterfsMounter) CanMount() error {
267
268
switch runtime .GOOS {
268
269
case "linux" :
269
270
if _ , err := exe .Run ("test" , "-x" , gciLinuxGlusterMountBinaryPath ); err != nil {
270
- return fmt .Errorf ("Required binary %s is missing" , gciLinuxGlusterMountBinaryPath )
271
+ return fmt .Errorf ("required binary %s is missing" , gciLinuxGlusterMountBinaryPath )
271
272
}
272
273
}
273
274
return nil
@@ -394,7 +395,7 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error {
394
395
// Refer to backup-volfile-servers @ http://docs.gluster.org/en/latest/Administrator%20Guide/Setting%20Up%20Clients/
395
396
396
397
if (len (addrlist ) > 0 ) && (addrlist [0 ] != "" ) {
397
- ip := addrlist [0 ]
398
+ ip := addrlist [rand . Intn ( len ( addrlist )) ]
398
399
errs = b .mounter .Mount (ip + ":" + b .path , dir , "glusterfs" , mountOptions )
399
400
if errs == nil {
400
401
klog .Infof ("successfully mounted directory %s" , dir )
@@ -427,7 +428,7 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error {
427
428
// it all goes in a log file, we will read the log file
428
429
logErr := readGlusterLog (log , b .pod .Name )
429
430
if logErr != nil {
430
- return fmt .Errorf ("mount failed: %v the following error information was pulled from the glusterfs log to help diagnose this issue: %v" , errs , logErr )
431
+ return fmt .Errorf ("mount failed: %v, the following error information was pulled from the glusterfs log to help diagnose this issue: %v" , errs , logErr )
431
432
}
432
433
return fmt .Errorf ("mount failed: %v" , errs )
433
434
@@ -442,7 +443,7 @@ func getVolumeInfo(spec *volume.Spec) (string, bool, error) {
442
443
spec .PersistentVolume .Spec .Glusterfs != nil {
443
444
return spec .PersistentVolume .Spec .Glusterfs .Path , spec .ReadOnly , nil
444
445
}
445
- return "" , false , fmt .Errorf ("Spec does not reference a Glusterfs volume type" )
446
+ return "" , false , fmt .Errorf ("spec does not reference a Glusterfs volume type" )
446
447
}
447
448
448
449
func (plugin * glusterfsPlugin ) NewProvisioner (options volume.VolumeOptions ) (volume.Provisioner , error ) {
@@ -743,7 +744,7 @@ func (p *glusterfsVolumeProvisioner) Provision(selectedNode *v1.Node, allowedTop
743
744
return nil , fmt .Errorf ("%s does not support block volume provisioning" , p .plugin .GetPluginName ())
744
745
}
745
746
746
- klog .V (4 ).Infof ("Provision VolumeOptions %v" , p .options )
747
+ klog .V (4 ).Infof ("provision volume with options %v" , p .options )
747
748
scName := v1helper .GetPersistentVolumeClaimClass (p .options .PVC )
748
749
cfg , err := parseClassParameters (p .options .Parameters , p .plugin .host .GetKubeClient ())
749
750
if err != nil {
@@ -762,7 +763,7 @@ func (p *glusterfsVolumeProvisioner) Provision(selectedNode *v1.Node, allowedTop
762
763
return nil , fmt .Errorf ("failed to reserve GID from table: %v" , err )
763
764
}
764
765
765
- klog .V (2 ).Infof ("Allocated GID %d for PVC %s" , gid , p .options .PVC .Name )
766
+ klog .V (2 ).Infof ("allocated GID %d for PVC %s" , gid , p .options .PVC .Name )
766
767
767
768
glusterfs , sizeGiB , volID , err := p .CreateVolume (gid )
768
769
if err != nil {
@@ -1162,21 +1163,21 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
1162
1163
}
1163
1164
1164
1165
if cfg .gidMin > cfg .gidMax {
1165
- return nil , fmt .Errorf ("StorageClass for provisioner %q must have gidMax value >= gidMin" , glusterfsPluginName )
1166
+ return nil , fmt .Errorf ("storageClass for provisioner %q must have gidMax value >= gidMin" , glusterfsPluginName )
1166
1167
}
1167
1168
1168
1169
if len (parseVolumeOptions ) != 0 {
1169
1170
volOptions := dstrings .Split (parseVolumeOptions , "," )
1170
1171
if len (volOptions ) == 0 {
1171
- return nil , fmt .Errorf ("StorageClass for provisioner %q must have valid (for e.g., 'client.ssl on') volume option" , glusterfsPluginName )
1172
+ return nil , fmt .Errorf ("storageClass for provisioner %q must have valid (for e.g., 'client.ssl on') volume option" , glusterfsPluginName )
1172
1173
}
1173
1174
cfg .volumeOptions = volOptions
1174
1175
1175
1176
}
1176
1177
1177
1178
if len (parseVolumeNamePrefix ) != 0 {
1178
1179
if dstrings .Contains (parseVolumeNamePrefix , "_" ) {
1179
- return nil , fmt .Errorf ("Storageclass parameter 'volumenameprefix' should not contain '_' in its value" )
1180
+ return nil , fmt .Errorf ("storageclass parameter 'volumenameprefix' should not contain '_' in its value" )
1180
1181
}
1181
1182
cfg .volumeNamePrefix = parseVolumeNamePrefix
1182
1183
}
@@ -1217,7 +1218,7 @@ func getVolumeID(pv *v1.PersistentVolume, volumeName string) (string, error) {
1217
1218
func (plugin * glusterfsPlugin ) ExpandVolumeDevice (spec * volume.Spec , newSize resource.Quantity , oldSize resource.Quantity ) (resource.Quantity , error ) {
1218
1219
pvSpec := spec .PersistentVolume .Spec
1219
1220
volumeName := pvSpec .Glusterfs .Path
1220
- klog .V (2 ).Infof ("Received request to expand volume %s" , volumeName )
1221
+ klog .V (2 ).Infof ("received request to expand volume %s" , volumeName )
1221
1222
volumeID , err := getVolumeID (spec .PersistentVolume , volumeName )
1222
1223
1223
1224
if err != nil {
0 commit comments