diff --git a/pkg/csi/cinder/controllerserver.go b/pkg/csi/cinder/controllerserver.go index 56aadd1276..bc76ce9353 100644 --- a/pkg/csi/cinder/controllerserver.go +++ b/pkg/csi/cinder/controllerserver.go @@ -68,6 +68,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol resID := "" resAvailability := "" + resSize := 0 if len(volumes) == 1 { resID = volumes[0].ID @@ -77,19 +78,20 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol return nil, errors.New("multiple volumes reported by Cinder with same name") } else { // Volume Create - resID, resAvailability, err = cloud.CreateVolume(volName, volSizeGB, volType, volAvailability, nil) + resID, resAvailability, resSize, err = cloud.CreateVolume(volName, volSizeGB, volType, volAvailability, nil) if err != nil { glog.V(3).Infof("Failed to CreateVolume: %v", err) return nil, err } - glog.V(4).Infof("Create volume %s in Availability Zone: %s", resID, resAvailability) + glog.V(4).Infof("Create volume %s in Availability Zone: %s of size %s GiB", resID, resAvailability, resSize) } return &csi.CreateVolumeResponse{ Volume: &csi.Volume{ - Id: resID, + Id: resID, + CapacityBytes: int64(resSize * 1024 * 1024 * 1024), Attributes: map[string]string{ "availability": resAvailability, }, diff --git a/pkg/csi/cinder/openstack/openstack.go b/pkg/csi/cinder/openstack/openstack.go index 77e69af5b6..d7e915c471 100644 --- a/pkg/csi/cinder/openstack/openstack.go +++ b/pkg/csi/cinder/openstack/openstack.go @@ -27,7 +27,7 @@ import ( ) type IOpenStack interface { - CreateVolume(name string, size int, vtype, availability string, tags *map[string]string) (string, string, error) + CreateVolume(name string, size int, vtype, availability string, tags *map[string]string) (string, string, int, error) DeleteVolume(volumeID string) error AttachVolume(instanceID, volumeID string) (string, error) WaitDiskAttached(instanceID string, volumeID string) error diff --git a/pkg/csi/cinder/openstack/openstack_volumes.go b/pkg/csi/cinder/openstack/openstack_volumes.go index 05932bc8f9..c1801d51dc 100644 --- a/pkg/csi/cinder/openstack/openstack_volumes.go +++ b/pkg/csi/cinder/openstack/openstack_volumes.go @@ -61,7 +61,7 @@ type Volume struct { } // CreateVolume creates a volume of given size -func (os *OpenStack) CreateVolume(name string, size int, vtype, availability string, tags *map[string]string) (string, string, error) { +func (os *OpenStack) CreateVolume(name string, size int, vtype, availability string, tags *map[string]string) (string, string, int, error) { opts := &volumes.CreateOpts{ Name: name, Size: size, @@ -74,10 +74,10 @@ func (os *OpenStack) CreateVolume(name string, size int, vtype, availability str vol, err := volumes.Create(os.blockstorage, opts).Extract() if err != nil { - return "", "", err + return "", "", 0, err } - return vol.ID, vol.AvailabilityZone, nil + return vol.ID, vol.AvailabilityZone, vol.Size, nil } // GetVolumesByName is a wrapper around ListVolumes that creates a Name filter to act as a GetByName