diff --git a/pkg/glusterfs/controllerserver.go b/pkg/glusterfs/controllerserver.go index fa885c6a8..78b4a3e34 100644 --- a/pkg/glusterfs/controllerserver.go +++ b/pkg/glusterfs/controllerserver.go @@ -180,7 +180,7 @@ func (cs *ControllerServer) doVolumeCreate(volumeName string, volSizeMB int) err } func (cs *ControllerServer) checkExistingVolume(volumeName string, volSizeMB int) error { - vol, err := cs.client.VolumeStatus(volumeName) + vol, err := cs.client.Volumes(volumeName) if err != nil { glog.Errorf("failed to fetch volume : %v", err) errResp := cs.client.LastErrorResponse() @@ -191,21 +191,22 @@ func (cs *ControllerServer) checkExistingVolume(volumeName string, volSizeMB int return status.Errorf(codes.Internal, "error in fetching volume details %v", err) } + volInfo := vol[0] // Do the owner validation - if glusterAnnVal, found := vol.Info.Metadata[volumeOwnerAnn]; !found || (found && glusterAnnVal != glusterfsCSIDriverName) { + if glusterAnnVal, found := volInfo.Metadata[volumeOwnerAnn]; !found || (found && glusterAnnVal != glusterfsCSIDriverName) { return status.Errorf(codes.Internal, "volume %s (%s) is not owned by GlusterFS CSI driver", - vol.Info.Name, vol.Info.Metadata) + volInfo.Name, volInfo.Metadata) } - if int(vol.Size.Capacity) != volSizeMB { - return status.Errorf(codes.AlreadyExists, "volume %s already exits with different size: %d", vol.Info.Name, vol.Size.Capacity) + if int(volInfo.Capacity) != volSizeMB { + return status.Errorf(codes.AlreadyExists, "volume %s already exits with different size: %d", volInfo.Name, volInfo.Capacity) } //volume has not started, start the volume - if !vol.Online { - err = cs.client.VolumeStart(vol.Info.Name, true) + if volInfo.State != api.VolStarted { + err = cs.client.VolumeStart(volInfo.Name, true) if err != nil { - return status.Errorf(codes.Internal, "failed to start volume %s: %v", vol.Info.Name, err) + return status.Errorf(codes.Internal, "failed to start volume %s: %v", volInfo.Name, err) } } @@ -310,7 +311,7 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req return nil, status.Error(codes.InvalidArgument, "ValidateVolumeCapabilities() - VolumeCapabilities is nil") } - _, err := cs.client.VolumeStatus(req.VolumeId) + _, err := cs.client.Volumes(volumeID) if err != nil { return nil, status.Errorf(codes.NotFound, "ValidateVolumeCapabilities() - %v", err) } diff --git a/pkg/glusterfs/driver_test.go b/pkg/glusterfs/driver_test.go index bcfd4f69b..9c8b93c5d 100644 --- a/pkg/glusterfs/driver_test.go +++ b/pkg/glusterfs/driver_test.go @@ -117,12 +117,13 @@ func handleGETRequest(w http.ResponseWriter, r *http.Request, t *testing.T) { return } - if strings.HasSuffix(r.URL.String(), "/v1/volumes") { + if r.URL.String() == "/v1/volumes" { resp := make(api.VolumeListResp, 1) resp[0] = api.VolumeGetResp{ ID: id, Name: "test1", Metadata: map[string]string{volumeOwnerAnn: glusterfsCSIDriverName}, + State: api.VolStarted, Capacity: 1000, } writeResp(w, http.StatusOK, resp, t) @@ -132,16 +133,12 @@ func handleGETRequest(w http.ResponseWriter, r *http.Request, t *testing.T) { vol := strings.Split(strings.Trim(r.URL.String(), "/"), "/") if checkVolume(vol[2]) { - resp := api.VolumeStatusResp{ - Info: api.VolumeInfo{ - ID: id, - Name: vol[2], - Metadata: map[string]string{volumeOwnerAnn: glusterfsCSIDriverName}, - }, - Online: true, - Size: api.SizeInfo{ - Capacity: volumeCache[vol[2]], - }, + resp := api.VolumeGetResp{ + ID: id, + Name: vol[2], + Metadata: map[string]string{volumeOwnerAnn: glusterfsCSIDriverName}, + State: api.VolStarted, + Capacity: volumeCache[vol[2]], } writeResp(w, http.StatusOK, resp, t) return