-
Notifications
You must be signed in to change notification settings - Fork 618
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
cinder-csi: Adds support for managing backups (kubernetes#2473) #2480
Conversation
|
Welcome @Sebastian-RG! |
Hi @Sebastian-RG. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
a typo here ? should be backup?? |
It seems the E2E test failed, but I can't tell how it's related to the changes I made 🤔
|
I think I found the error
looks like a flake. This then causes
Rerun the test? |
/retest |
de0bd43
to
7d90197
Compare
@Sebastian-RG can you fill in the release notes in the initial PR message? |
ef01bb9
to
b0ea276
Compare
/retest |
if err != nil { | ||
//If there is an error getting the backup as well, fail. | ||
return nil, status.Errorf(codes.NotFound, "VolumeContentSource Snapshot or Backup with ID %s not found", snapshotID) | ||
} |
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 don't think API will behave differently if cinder-backup
is not deployed. In such case API will still get us a 404, as GET
call doesn't RPC down to cinder-backup
and just looks the items up in the DB: https://opendev.org/openstack/cinder/src/branch/master/cinder/backup/api.py#L71-L76.
If backups are optional, wouldn't it be better to put all the backup operations behind an if
based on existence of the backup API extension: https://docs.openstack.org/api-ref/block-storage/v3/#list-known-api-extensions ?
@@ -413,8 +594,18 @@ func (cs *controllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS | |||
return nil, status.Error(codes.InvalidArgument, "Snapshot ID must be provided in DeleteSnapshot request") | |||
} | |||
|
|||
// If volumeSnapshot object was linked to a cinder backup, delete the backup. | |||
back, err := cs.Cloud.GetBackupByID(id) |
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.
As I explained above, GET call on backups will not tell us anything about cinder-backup
being present in the deployment, but now I think it does make some sense to probe for backup existence, because on DELETE call we'll crash here: https://opendev.org/openstack/cinder/src/branch/master/cinder/backup/api.py#L120. Thanks, please mark this one as resolved.
|
||
func (os *OpenStack) BackupsAreEnabled() (bool, error) { | ||
// Check if the backup service is enabled | ||
allPages, err := services.List(os.blockstorage, services.ListOpts{Binary: backupBinary}).AllPages() |
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 is an admin-only API, this will not work when user is a regular tenant of the cloud, so it's not acceptable for CSI. I rather proposed checking if backups API extension is enabled, but I see gophercloud currently doesn't have such an API. Let's make this method return true, nil
for now, I'll take a look on how to add the new gophercloud API and we'll be able to fix this in a follow up patch.
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.
There is no way of checking if it's enabled or not by getting the extensions. I've tested cases environments where backups are not enabled and openstack still lists the Backups
and CreateBackup
extensions :(
Listing services was the only reliable way i found to tell if backups are enabled.
I also thought about just listing all backups and seeing if it returns an error but it just returns an empty list. I'll set it to return true, nil
as you say
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 know, admins tend to forget about configuring the extensions correctly. Well, we can't do much about environments that return incorrect data, but it's probably the thing to look at. Anyway it's not a big deal at this state.
var sourceVolID string | ||
var sourceBackupID string | ||
var backupsAreEnabled bool | ||
backupsAreEnabled, err = cloud.BackupsAreEnabled() |
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.
Could we cache this as a part of controllerServer struct so that it's only calling API once, on service startup? At a glance I'm not sure it's possible…?
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 think the added delay for a createVolume or createSnapshot action should not be noticeable. Also if we do this at controller startup it might be hard to debug when adding backups capability to an existing cluster.
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 can be done as a second step, I think.
/lgtm |
Signed-off-by: Sebastian-RG <[email protected]>
/retest |
/retest It should be good now. |
/lgtm |
@Sebastian-RG thanks for driving this through! /hold cancel |
What this PR does / why we need it:
This allows for creating and deleting cinder backups from K8S via VolumeSnapshot objects that have a VolumeSnapshotClass with
parameters.type = "backup"
.Backups are different from snapshots in that they are usually stored off-site, for example via S3 or NFS.
Which issue this PR fixes(if applicable):
fixes #2473
Special notes for reviewers:
Create a VolumeSnapshotClass that has parameters.type equal to "backup"
Create a volumeSnapshot that has a Cinder PVC as the Source. This creates a Backup. Deleting this also deletes the backup.
Create a PVC that has the previouse VolumeSnapshot as the source.
The requested size must be greater than the backup size.
This creates a volume populated with the backup data.
Release note: