Skip to content

Commit

Permalink
Update snapshot and cloudsnap APIs from 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
disrani-px committed Dec 17, 2018
1 parent 42099f6 commit a0d3ff1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 13 additions & 11 deletions pkg/snapshot/cloudsnap.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (c *cloudSnapshotPlugin) CreateVolumeFromSnapshot(snapshotID, volumeType, v
}

if volumeName == "" {
c.log.Infof("Error finding volume name for cloudsnap %v", snapshotID)
return "", fmt.Errorf("Couldn't find volume name from cloudsnap")
}

Expand All @@ -61,18 +62,19 @@ func (c *cloudSnapshotPlugin) CreateVolumeFromSnapshot(snapshotID, volumeType, v
RestoreVolumeName: volumeName,
})
if err != nil {
c.log.Infof("Error starting cloudsnap restore for %v to %v", snapshotID, volumeName)
return "", err
}

c.log.Infof("Started cloud snapshot restore %v to volume %v", snapshotID, response.RestoreVolumeID)
err = volume.CloudBackupWaitForCompletion(volDriver, response.RestoreVolumeID,
err = volume.CloudBackupWaitForCompletion(volDriver, response.Name,
api.CloudRestoreOp)
if err != nil {
c.log.Errorf("Error restoring %v to volume %v: %v", snapshotID, response.RestoreVolumeID, err)
return "", err
}

c.log.Infof("Finished cloud snapshot restore %v to volume %v", snapshotID, response.RestoreVolumeID)
c.log.Infof("Finished cloud snapshot restore %v for %v to volume %v", response.Name, snapshotID, response.RestoreVolumeID)
return response.RestoreVolumeID, nil
}

Expand All @@ -86,7 +88,7 @@ func (c *cloudSnapshotPlugin) CreateSnapshot(volumeID, volumeAZ string, tags map
return "", err
}

err = volDriver.CloudBackupCreate(&api.CloudBackupCreateRequest{
createResp, err := volDriver.CloudBackupCreate(&api.CloudBackupCreateRequest{
VolumeID: volumeID,
Full: true,
CredentialUUID: c.credID,
Expand All @@ -95,20 +97,20 @@ func (c *cloudSnapshotPlugin) CreateSnapshot(volumeID, volumeAZ string, tags map
return "", err
}

response, err := volDriver.CloudBackupStatus(&api.CloudBackupStatusRequest{
SrcVolumeID: volumeID,
})
c.log.Infof("Started cloud snapshot backup %v for %v", createResp.Name, volumeID)
err = volume.CloudBackupWaitForCompletion(volDriver, createResp.Name, api.CloudBackupOp)
if err != nil {
c.log.Errorf("Error backing up volume %v: %v", volumeID, err)
return "", err
}
c.log.Infof("Started cloud snapshot backup %v for %v", response.Statuses[volumeID].ID, volumeID)
err = volume.CloudBackupWaitForCompletion(volDriver, volumeID, api.CloudBackupOp)
statusResponse, err := volDriver.CloudBackupStatus(&api.CloudBackupStatusRequest{
Name: createResp.Name,
})
if err != nil {
c.log.Errorf("Error backing up volume %v: %v", volumeID, err)
return "", err
}
c.log.Infof("Finished cloud snapshot backup %v for %v", response.Statuses[volumeID].ID, volumeID)
return response.Statuses[volumeID].ID, nil
c.log.Infof("Finished cloud snapshot backup %v for %v to %v", createResp.Name, volumeID, statusResponse.Statuses[createResp.Name].ID)
return statusResponse.Statuses[createResp.Name].ID, nil
}

func (c *cloudSnapshotPlugin) DeleteSnapshot(snapshotID string) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/snapshot/localsnap.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (l *localSnapshotPlugin) CreateVolumeFromSnapshot(snapshotID, volumeType, v
locator := &api.VolumeLocator{
Name: vols[0].Locator.VolumeLabels["pvName"],
}
volumeID, err := volDriver.Snapshot(snapshotID, false, locator)
volumeID, err := volDriver.Snapshot(snapshotID, false, locator, true)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -63,7 +63,7 @@ func (l *localSnapshotPlugin) CreateSnapshot(volumeID, volumeAZ string, tags map
Name: tags["ark.heptio.com/backup"] + "_" + vols[0].Locator.Name,
VolumeLabels: tags,
}
snapshotID, err := volDriver.Snapshot(volumeID, true, locator)
snapshotID, err := volDriver.Snapshot(volumeID, true, locator, true)
if err != nil {
return "", err
}
Expand Down

0 comments on commit a0d3ff1

Please sign in to comment.