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

[cinder-csi-plugin] Programatically create cinder backups from Kubernetes via CSI #2473

Closed
Sebastian-RG opened this issue Nov 10, 2023 · 8 comments · Fixed by #2480
Closed
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@Sebastian-RG
Copy link
Contributor

Is this a BUG REPORT or FEATURE REQUEST?:
/kind feature

What happened:
Currently, there is no method to programmatically create volume backups from K8S.
This disallows for Kubernetes administrators to easily make sure their data is redundantly stored.

What you expected to happen:

I believe the best option would be to do something similar to what Longhorn does.
By setting the value on the volumesnapshotclass' parameters.type to snapshot or backup, you can choose between linking
the volumesnapshot object to a volume snapshot or a backup.

kind: VolumeSnapshotClass
apiVersion: snapshot.storage.k8s.io/v1
driver: driver.longhorn.io
deletionPolicy: Delete
parameters:
  type: <type>

How to reproduce it:
Not applicable

Anything else we need to know?:
I would love to contribute the necessary changes to the project

Environment:

  • openstack-cloud-controller-manager(or other related binary) version:
  • OpenStack version: openstack 6.3.0
  • Others:
@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 10, 2023
@zetaab
Copy link
Member

zetaab commented Nov 10, 2023

@zetaab
Copy link
Member

zetaab commented Nov 10, 2023

conversation in slack: currently cpo supports volume snapshots. Instead we could have also volume backups.

So the full workflows could be:

take snapshot:

  1. take volume snapshot from cinder volume
  2. make volume backup using cinder volume snapshot (done in 1.)
  3. delete volume snapshot

restore snapshot:

  1. restore volume backup

just in case: what is difference between volume backup and volume snapshot?

The difference is that volume snapshot is stored in block storage and volume backup can be stored to object storage (swift/s3 etc).

@jichenjc
Copy link
Contributor

just in case: what is difference between volume backup and volume snapshot?
The difference is that volume snapshot is stored in block storage and volume backup can be stored to object storage (swift/s3 etc).

I knew nova backup is different to nova snapshot, but not sure volume snapshot/backup
does it means we need change existing API call to cinder ? or need CSI level design (e.g backup differnet to snapshot) ?

@kayrus
Copy link
Contributor

kayrus commented Nov 14, 2023

backup has its own API: https://docs.openstack.org/api-ref/block-storage/v3/index.html#backups-backups
I recently implemented it in velero openstack plugin: Lirt/velero-plugin-for-openstack#89

@jichenjc
Copy link
Contributor

@Sebastian-RG will you submit a PR for this (with the above info we got from @zetaab and @kayrus )?

@Sebastian-RG
Copy link
Contributor Author

Hi! Yes, I will submit it tomorrow

Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 16, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 16, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 16, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 17, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 17, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 17, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 17, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 17, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 17, 2023
@Sebastian-RG
Copy link
Contributor Author

Hi. I've been having some issues with creating a volume from a backup. The flow goes like this:

  1. A PVC is created that points to a VolumeSnapshot with type backup.
  2. cinder-csi-plugin creates a volume that points to a backup with the gophercloud API.
  3. Volume creation hits this this in cinder-volume.
  4. Volume gets created, then cinder-volume tells cinder-backup to copy the data from the backup to the newly created volume
  5. The data from the backup gets copied to the new volume
  6. cinder-csi-plugin for some reason decides to delete the volume
  7. Backup tries to restore the data again to the volume, but it does not exist anymore. Backup gets stuck in state Restoring

If anyone has any idea why the last part happens I would be very grateful for the help. I've been stuck on this bit for almost a week 😓

Some things I think may cause this:

  1. GRPC repeatedly calling create volume somehow causes an issue. Probably because the backup gets set to available at the very beginning and then changes status when the backup starts restoring.
  2. Some other component (csi-provisioner or external snapshotter) deciding to delete the volume because there isn't a correponding snapshot in cinder

This is my current code master...Sebastian-RG:cloud-provider-openstack:master

Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 25, 2023
@Sebastian-RG
Copy link
Contributor Author

As it turns out, when you create a volume from a backup via Gophercloud, the returned volume object does not include the backupID. This caused the ContentSource field in CreateVolumeResponse to come back empty. This eventually caused external-snapshotter to delete the volume.

Sending the PR now :)

Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 25, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 25, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 27, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 28, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Nov 28, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Dec 1, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Dec 1, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Dec 3, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Dec 4, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Dec 5, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Dec 6, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Dec 15, 2023
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Jan 10, 2024
Signed-off-by: Sebastian-RG <fullmetalliferous@gmail.com>
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Jan 16, 2024
Signed-off-by: Sebastian-RG <fullmetalliferous@gmail.com>
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Jan 18, 2024
Signed-off-by: Sebastian-RG <fullmetalliferous@gmail.com>
Sebastian-RG added a commit to Sebastian-RG/cloud-provider-openstack that referenced this issue Feb 7, 2024
Signed-off-by: Sebastian-RG <fullmetalliferous@gmail.com>
k8s-ci-robot pushed a commit that referenced this issue Feb 8, 2024
Signed-off-by: Sebastian-RG <fullmetalliferous@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
5 participants