From abd1f6baa2f500d83d689d9e9f4cabba03cfec27 Mon Sep 17 00:00:00 2001 From: sai chaithanya Date: Wed, 27 Mar 2019 16:44:48 +0530 Subject: [PATCH] Adds capacity field in volumesnapshotdata (#88) (#89) Signed-off-by: mittachaitu --- .../cmd/snapshot-pv-provisioner/snapshot-pv-provisioner.go | 4 ++-- snapshot/pkg/apis/crd/v1/types.go | 2 ++ snapshot/pkg/volume/openebs/processor.go | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/snapshot/cmd/snapshot-pv-provisioner/snapshot-pv-provisioner.go b/snapshot/cmd/snapshot-pv-provisioner/snapshot-pv-provisioner.go index ef2d7b4aa64..c45682b6a50 100644 --- a/snapshot/cmd/snapshot-pv-provisioner/snapshot-pv-provisioner.go +++ b/snapshot/cmd/snapshot-pv-provisioner/snapshot-pv-provisioner.go @@ -101,7 +101,7 @@ func (p *snapshotProvisioner) Provision(options controller.VolumeOptions) (*v1.P } snapshotName, ok := options.PVC.Annotations[crdclient.SnapshotPVCAnnotation] if !ok { - return nil, fmt.Errorf("snapshot annotation not found on PV") + return nil, fmt.Errorf("snapshot annotation not found on PVC") } var snapshot crdv1.VolumeSnapshot @@ -112,7 +112,7 @@ func (p *snapshotProvisioner) Provision(options controller.VolumeOptions) (*v1.P Do().Into(&snapshot) if err != nil { - return nil, fmt.Errorf("failed to retrieve VolumeSnapshot %s: %v", snapshotName, err) + return nil, fmt.Errorf("failed to retrieve VolumeSnapshot %s in namespace %s: %v", snapshotName, options.PVC.Namespace, err) } // FIXME: should also check if any VolumeSnapshotData points to this VolumeSnapshot if len(snapshot.Spec.SnapshotDataName) == 0 { diff --git a/snapshot/pkg/apis/crd/v1/types.go b/snapshot/pkg/apis/crd/v1/types.go index 3cbf03d3f92..f47419c956c 100644 --- a/snapshot/pkg/apis/crd/v1/types.go +++ b/snapshot/pkg/apis/crd/v1/types.go @@ -230,6 +230,8 @@ type CinderVolumeSnapshotSource struct { type OpenEBSVolumeSnapshotSource struct { // Unique id of the cinder volume snapshot resource. Used to identify the snapshot in OpenStack SnapshotID string `json:"snapshotId"` + // Capacity will holds the size of the snapshot + Capacity string `json:"capacity"` } // GCEPersistentDiskSnapshotSource is GCE PD volume snapshot source diff --git a/snapshot/pkg/volume/openebs/processor.go b/snapshot/pkg/volume/openebs/processor.go index 32767bf6553..7f7c9eea525 100644 --- a/snapshot/pkg/volume/openebs/processor.go +++ b/snapshot/pkg/volume/openebs/processor.go @@ -102,9 +102,11 @@ func (h *openEBSPlugin) SnapshotCreate(snapshot *crdv1.VolumeSnapshot, pv *v1.Pe } } + sizeResource := pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)] res := &crdv1.VolumeSnapshotDataSource{ OpenEBSSnapshot: &crdv1.OpenEBSVolumeSnapshotSource{ SnapshotID: snapshotName, + Capacity: sizeResource.String(), }, } return res, &cond, err