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

Volumes: Add remote copy support for snapshots #12045

Merged
merged 12 commits into from
Jul 24, 2023

Conversation

roosterfish
Copy link
Contributor

Adds support for copying volume snapshots to and from a remote.
Includes tests for local and remote volume snapshot copy scenarios.

Fixes #11112

@github-actions github-actions bot added the API Changes to the REST API label Jul 19, 2023
@roosterfish roosterfish force-pushed the fix_snapshot_copy branch 5 times, most recently from 81f4777 to 7c5dd7f Compare July 19, 2023 15:37
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
@tomponline
Copy link
Member

I've pinned curl in main now so you can rebase.

@monstermunchkin
Copy link
Contributor

LGTM but code tests are failing.

@roosterfish roosterfish force-pushed the fix_snapshot_copy branch 2 times, most recently from deb646b to a974583 Compare July 20, 2023 07:14
@github-actions github-actions bot added the Documentation Documentation needs updating label Jul 20, 2023
@roosterfish
Copy link
Contributor Author

LGTM but code tests are failing.

Thanks, cleared. Also the swagger doc update is now added.

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

This is looking great, I like the thorough testing added.

There's a couple of minor changes needed, as this introduces an API change so we need to make an api extension and associated commit.

Target: volume.Target,
}

path = fmt.Sprintf("/storage-pools/%s/volumes/custom/%s/snapshots/%s", url.PathEscape(pool), srcVolParentName, srcVolSnapName)
Copy link
Member

Choose a reason for hiding this comment

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

We should use url.PathEscape() on all path parameters.

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 switched to using api.NewURL().Path().String() to remove the burden of having to call url.PathEscape() countless times.

Copy link
Member

Choose a reason for hiding this comment

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

Yes that is preferred way of doing it indeed.

path = fmt.Sprintf("/storage-pools/%s/volumes/custom/%s/snapshots/%s", url.PathEscape(pool), srcVolParentName, srcVolSnapName)
} else {
req = volume
path = fmt.Sprintf("/storage-pools/%s/volumes/custom/%s", url.PathEscape(pool), volume.Name)
Copy link
Member

Choose a reason for hiding this comment

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

We should use url.PathEscape() on all path parameters.

// Initiate volume snapshot migration
// Example: false
//
// API extension: storage_api_remote_volume_handling
Copy link
Member

Choose a reason for hiding this comment

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

This isnt the API extension that added this field. Instead it should be the name of the new API extension you add in this PR.

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 was thinking a bit here but the concept of those extensions wasn't clear to me yet. Thanks. Just saw the client now also needs a check for r.HasExtension. Will add this in now.

Copy link
Member

Choose a reason for hiding this comment

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

We use r.CheckExtension. Please could you add a comment to r.HasExtension that it is considered deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done.


// Migration target (for push mode)
//
// API extension: storage_api_remote_volume_handling
Copy link
Member

Choose a reason for hiding this comment

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

Should be the new API extension name.

test/suites/storage_snapshots.sh Show resolved Hide resolved
@roosterfish roosterfish force-pushed the fix_snapshot_copy branch 5 times, most recently from 172549f to eaeca34 Compare July 21, 2023 08:05
client/lxd_server.go Outdated Show resolved Hide resolved
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
vol.Snapshots() returns an error if the volume is a snapshot.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
The extension needs to be present when trying to copy volume snapshots between remotes

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@tomponline tomponline merged commit aca9153 into canonical:main Jul 24, 2023
25 checks passed
@roosterfish roosterfish deleted the fix_snapshot_copy branch July 24, 2023 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes to the REST API Documentation Documentation needs updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy from volume snapshot to remote fails: "Error: not found"
3 participants