Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Commit

Permalink
Adds capacity field in volumesnapshotdata (#88) (#89)
Browse files Browse the repository at this point in the history
Signed-off-by: mittachaitu <[email protected]>
  • Loading branch information
sai chaithanya authored and prateekpandey14 committed Mar 27, 2019
1 parent 48180ce commit abd1f6b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions snapshot/pkg/apis/crd/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions snapshot/pkg/volume/openebs/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abd1f6b

Please sign in to comment.