-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
There was a problem hiding this 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.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
I'll continue to have it return an error. |
136974b
to
236d5a5
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc
pkg/plugin/block_store.go
Outdated
|
||
resp, err := c.grpcClient.GetVolumeID(context.Background(), req) | ||
if err != nil { | ||
return "", nil |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, thx
pkg/plugin/block_store.go
Outdated
|
||
resp, err := c.grpcClient.SetVolumeID(context.Background(), req) | ||
if err != nil { | ||
return nil, nil |
There was a problem hiding this comment.
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
?
pkg/restore/restorers/pv_restorer.go
Outdated
"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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops :)
pkg/restore/restorers/pv_restorer.go
Outdated
} | ||
|
||
restoreFromSnapshot = true | ||
if sr.snapshotService == nil { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
pkg/restore/restorers/pv_restorer.go
Outdated
} | ||
|
||
return obj, warning, nil | ||
return updatedObj, nil, nil |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
39ad5c2
to
a390a2b
Compare
pkg/backup/item_backupper_test.go
Outdated
@@ -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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, thanks.
Just the one unit test Q, otherwise LGTM |
Signed-off-by: Andy Goldstein <andy.goldstein@gmail.com>
f8d6afa
to
e317c94
Compare
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>
e317c94
to
c700455
Compare
LGTM |
…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>
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