Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom volume snapshots & restores #215

Merged
merged 2 commits into from
Nov 29, 2017

Conversation

ncdc
Copy link
Contributor

@ncdc ncdc commented Nov 27, 2017

The main Ark code was hard-coding specific support for AWS, GCE, and Azure volume snapshots and restores, and anything else was considered unsupported. This PR adds GetVolumeID and SetVolumeID to the BlockStore interface, to allow block store plugins to handle volume snapshots and restores.

Fixes #214

Signed-off-by: Andy Goldstein andy.goldstein@gmail.com

cc @stevesloka

@ncdc ncdc added this to the v0.6.0 milestone Nov 27, 2017
@ncdc ncdc assigned nrb and skriss Nov 27, 2017
Copy link
Contributor

@nrb nrb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Get/SetVolumeID functions make sense to include to me. I also agree with the more lenient approach to PV restoration, but there may be edge cases that I'm not aware of.

@skriss
Copy link
Contributor

skriss commented Nov 28, 2017

The plugin change definitely makes sense - thanks for catching that.

I think the PV restorer change is OK, although maybe we still want to return a warning if there is a VolumeBackups map but the current PV isn't in it? It's certainly not an expected case -- likely either the snapshot failed during backup, or someone manually deleted it - so probably worth explicitly recording in the log.


aws["volumeID"] = volumeID

return pv, nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pv was never changed here and aws is not returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to return the full object. aws comes from pv (collections.GetMap(pv.UnstructuredContent(), "spec.awsElasticBlockStore")). When we mutate aws, it's mutating pv.

@ncdc
Copy link
Contributor Author

ncdc commented Nov 28, 2017

@skriss

I think the PV restorer change is OK, although maybe we still want to return a warning if there is a VolumeBackups map but the current PV isn't in it? It's certainly not an expected case -- likely either the snapshot failed during backup, or someone manually deleted it - so probably worth explicitly recording in the log.

I'll continue to have it return an error.

@ncdc ncdc force-pushed the support-custom-snapshots branch from 136974b to 236d5a5 Compare November 28, 2017 18:51
@@ -46,6 +47,9 @@ type SnapshotService interface {

// GetVolumeInfo gets the type and IOPS (if applicable) from the cloud API.
GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)

GetVolumeID(pv runtime.Unstructured) (string, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

godoc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, opting to do it last

// GetVolumeID returns the cloud provider specific identifier for the PersistentVolume.
GetVolumeID(pv runtime.Unstructured) (string, error)

SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

godoc


resp, err := c.grpcClient.GetVolumeID(context.Background(), req)
if err != nil {
return "", nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be returning "", err?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thx


resp, err := c.grpcClient.SetVolumeID(context.Background(), req)
if err != nil {
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be returning nil, err?

"k8s.io/apimachinery/pkg/runtime"

api "github.com/heptio/ark/pkg/apis/ark/v1"
"github.com/heptio/ark/pkg/cloudprovider"
"github.com/heptio/ark/pkg/util/boolptr"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pkg is missing from the commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops :)

}

restoreFromSnapshot = true
if sr.snapshotService == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is going to return an error if SnapshotVolumes is auto for both the backup and the restore, and there was no snapshotService for the backup (so no backups). I think this is definitely not desired behavior. I think we want to exit prior to this (without error) if backup.status.VolumeBackups is nil/empty, right? (we may have discussed this already this AM).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blech. That wasn't a case I was thinking about. I'll add that check.

}

return obj, warning, nil
return updatedObj, nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can get rid of the warning return arg since it's always nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that when I rebase

@ncdc ncdc force-pushed the support-custom-snapshots branch 2 times, most recently from 39ad5c2 to a390a2b Compare November 28, 2017 21:09
@@ -455,7 +458,7 @@ func TestTakePVSnapshot(t *testing.T) {
name: "unsupported PV source type",
snapshotEnabled: true,
pv: `{"apiVersion": "v1", "kind": "PersistentVolume", "metadata": {"name": "mypv"}, "spec": {"unsupportedPVSource": {}}}`,
expectError: false,
expectError: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change from false to true? Shouldn't it still not return an error since it doesn't contain a supported PV source?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks.

@skriss
Copy link
Contributor

skriss commented Nov 29, 2017

Just the one unit test Q, otherwise LGTM

Signed-off-by: Andy Goldstein <andy.goldstein@gmail.com>
@ncdc ncdc force-pushed the support-custom-snapshots branch from f8d6afa to e317c94 Compare November 29, 2017 17:25
@ncdc ncdc changed the title WIP Support custom volume snapshots & restores Support custom volume snapshots & restores Nov 29, 2017
The main Ark code was hard-coding specific support for AWS, GCE, and
Azure volume snapshots and restores, and anything else was considered
unsupported.

Add GetVolumeID and SetVolumeID to the BlockStore interface, to allow
block store plugins to handle volume snapshots and restores.

Signed-off-by: Andy Goldstein <andy.goldstein@gmail.com>
@ncdc ncdc force-pushed the support-custom-snapshots branch from e317c94 to c700455 Compare November 29, 2017 18:19
@skriss
Copy link
Contributor

skriss commented Nov 29, 2017

LGTM

@skriss skriss merged commit c129d1c into vmware-tanzu:master Nov 29, 2017
@ncdc ncdc deleted the support-custom-snapshots branch December 1, 2017 16:41
github-actions bot pushed a commit to kaovilai/velero that referenced this pull request Oct 28, 2022
kaovilai pushed a commit to kaovilai/velero that referenced this pull request Feb 6, 2023
kaovilai pushed a commit to kaovilai/velero that referenced this pull request Mar 16, 2023
alromeros pushed a commit to alromeros/velero that referenced this pull request Oct 25, 2024
…anzu#215)

Bumps [kubevirt.io/api](https://github.com/kubevirt/api) from 1.0.0 to 1.1.1.

Signed-off-by: Shelly Kagan <skagan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants