Skip to content

Instantly share code, notes, and snippets.

@bodgit
Created September 16, 2015 12:44
Show Gist options
  • Save bodgit/994d791e6a058e281396 to your computer and use it in GitHub Desktop.
Save bodgit/994d791e6a058e281396 to your computer and use it in GitHub Desktop.
Kubernetes 1.0.6 on Mesos and GlusterFS
diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go
index b3d5c4b..3ee9f38 100644
--- a/pkg/volume/glusterfs/glusterfs.go
+++ b/pkg/volume/glusterfs/glusterfs.go
@@ -17,8 +17,8 @@ limitations under the License.
package glusterfs
import (
- "math/rand"
"os"
+ "path"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
@@ -199,12 +199,23 @@ func (glusterfsVolume *glusterfs) setUpAtInternal(dir string) error {
options = append(options, "ro")
}
- l := len(glusterfsVolume.hosts.Subsets)
+ p := path.Join(glusterfsVolume.plugin.host.GetPluginDir(glusterfsPluginName), glusterfsVolume.volName)
+ if err := os.MkdirAll(p, 0750); err != nil {
+ return err
+ }
+ log := path.Join(p, "glusterfs.log")
+ options = append(options, "log-file="+log)
+
+ addr := make(map[string]struct{})
+ for _, s := range glusterfsVolume.hosts.Subsets {
+ for _, a := range s.Addresses {
+ addr[a.IP] = struct{}{}
+ }
+ }
+
// Avoid mount storm, pick a host randomly.
- start := rand.Int() % l
// Iterate all hosts until mount succeeds.
- for i := start; i < start+l; i++ {
- hostIP := glusterfsVolume.hosts.Subsets[i%l].Addresses[0].IP
+ for hostIP := range addr {
errs = glusterfsVolume.mounter.Mount(hostIP+":"+glusterfsVolume.path, dir, "glusterfs", options)
if errs == nil {
return nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment