UPSTREAM: 37986: Add `clusterid`, an optional parameter to storageclass.
@@ -663,6 +663,7 @@ func (r *glusterfsVolumeProvisioner) Provision() (*api.PersistentVolume, error)
}
func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *api.GlusterfsVolumeSource, size int, err error) {
+ var clusterIds []string
capacity := p.options.PVC.Spec.Resources.Requests[api.ResourceName(api.ResourceStorage)]
volSizeBytes := capacity.Value()
sz := int(volume.RoundUpSize(volSizeBytes, 1024*1024*1024))
@@ -676,7 +677,10 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *api.GlusterfsVolu
glog.Errorf("glusterfs: failed to create glusterfs rest client")
return nil, 0, fmt.Errorf("failed to create glusterfs REST client, REST server authentication failed")
}
- clusterIds := dstrings.Split(p.clusterId, ",")
+ if p.provisioningConfig.clusterId != "" {
+ clusterIds = dstrings.Split(p.clusterId, ",")
+ glog.V(4).Infof("glusterfs: provided clusterids: %v", clusterIds)
+ }
gid64 := int64(gid)
volumeReq := &gapi.VolumeCreateRequest{Size: sz, Clusters: clusterIds, Gid: gid64, Durability: gapi.VolumeDurabilityInfo{Type: durabilityType, Replicate: gapi.ReplicaDurability{Replica: replicaCount}}}
volume, err := cli.VolumeCreate(volumeReq)
@@ -833,7 +837,9 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
case "secretnamespace":
cfg.secretNamespace = v
case "clusterid":
+ if len(v) != 0 {
cfg.clusterId = v
+ }
case "restauthenabled":
authEnabled = dstrings.ToLower(v) == "true"
case "gidmin":
