Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
feat(controller): snapshot restoration
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt committed Apr 1, 2021
1 parent be99b28 commit 5a62d21
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pkg/controller/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,23 @@ func (controller *Controller) CreateVolume(ctx context.Context, req *csi.CreateV
}

if !volumeExists {
_, _, err = controller.dothillClient.CreateVolume(volumeID, sizeStr, parameters[common.PoolConfigKey])
if err != nil {
return nil, err
var sourceID string

if volume := req.VolumeContentSource.GetVolume(); volume != nil {
sourceID = volume.VolumeId
}

if snapshot := req.VolumeContentSource.GetSnapshot(); sourceID == "" && snapshot != nil {
sourceID = snapshot.SnapshotId
}

if sourceID != "" {
controller.dothillClient.VolumeCopy(sourceID, volumeID, parameters[common.PoolConfigKey])
} else {
_, _, err = controller.dothillClient.CreateVolume(volumeID, sizeStr, parameters[common.PoolConfigKey])
if err != nil {
return nil, err
}
}
}

Expand Down

0 comments on commit 5a62d21

Please sign in to comment.