Commit fdfe315b authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #37986 from humblec/glusterfs-clusterid-nil-allow

Automatic merge from submit-queue (batch tested with PRs 37307, 29606, 37986) Allow glusterfs dp volume creation for empty clusterid parameter in sc. Why this patch is needed? The `strings.split()` (https://github.com/kubernetes/kubernetes/pull/37986/files#diff-e97253dd603331ffca81131a4b67264fR700) returns a slice of `single element("empty") ` when the split is attempted on a string. This is expected according to `https://golang.org/pkg/strings/#Split` and `https://github.com/golang/go/issues/13075`. This make the provisioner to fail, if `clusterid` is not defined in the SCs. This patch make sure the split is attempted only when clusterid is mentioned in the sc parameter. Signed-off-by: 's avatarHumble Chirammal <hchiramm@redhat.com>
parents 2613e81a e6a300d7
...@@ -682,6 +682,7 @@ func (r *glusterfsVolumeProvisioner) Provision() (*v1.PersistentVolume, error) { ...@@ -682,6 +682,7 @@ func (r *glusterfsVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
} }
func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsVolumeSource, size int, err error) { func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsVolumeSource, size int, err error) {
var clusterIds []string
capacity := p.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)] capacity := p.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
volSizeBytes := capacity.Value() volSizeBytes := capacity.Value()
sz := int(volume.RoundUpSize(volSizeBytes, 1024*1024*1024)) sz := int(volume.RoundUpSize(volSizeBytes, 1024*1024*1024))
...@@ -695,7 +696,10 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsVolum ...@@ -695,7 +696,10 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsVolum
glog.Errorf("glusterfs: failed to create glusterfs rest client") glog.Errorf("glusterfs: failed to create glusterfs rest client")
return nil, 0, fmt.Errorf("failed to create glusterfs REST client, REST server authentication failed") 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) gid64 := int64(gid)
volumeReq := &gapi.VolumeCreateRequest{Size: sz, Clusters: clusterIds, Gid: gid64, Durability: gapi.VolumeDurabilityInfo{Type: durabilityType, Replicate: gapi.ReplicaDurability{Replica: replicaCount}}} volumeReq := &gapi.VolumeCreateRequest{Size: sz, Clusters: clusterIds, Gid: gid64, Durability: gapi.VolumeDurabilityInfo{Type: durabilityType, Replicate: gapi.ReplicaDurability{Replica: replicaCount}}}
volume, err := cli.VolumeCreate(volumeReq) volume, err := cli.VolumeCreate(volumeReq)
...@@ -852,7 +856,9 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa ...@@ -852,7 +856,9 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
case "secretnamespace": case "secretnamespace":
cfg.secretNamespace = v cfg.secretNamespace = v
case "clusterid": case "clusterid":
cfg.clusterId = v if len(v) != 0 {
cfg.clusterId = v
}
case "restauthenabled": case "restauthenabled":
authEnabled = dstrings.ToLower(v) == "true" authEnabled = dstrings.ToLower(v) == "true"
case "gidmin": case "gidmin":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment