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

DeleteVolumeGroupSnapshot API - part 1 #882

Merged

Conversation

RaunakShah
Copy link
Contributor

@RaunakShah RaunakShah commented Aug 15, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:

This PR adds logic to delete volume group snapshots.

Currently, Only the volume group snapshots and corresponding volume group snapshot contents are deleted. The logic to delete individual snapshots will be added in a separate PR.

Testing

  1. Dynamically volume group snapshot:
  • Create a volume group snapshot
% kubectl create -f volumegroupsnapshot-example.yaml 
volumegroupsnapshot.groupsnapshot.storage.k8s.io/my-group-snapshot created
% kubectl get vgsc
NAME                                                    READYTOUSE   DELETIONPOLICY   DRIVER                VOLUMEGROUPSNAPSHOTCLASS   VOLUMEGROUPSNAPSHOTNAMESPACE   VOLUMEGROUPSNAPSHOT   AGE
groupsnapcontent-29f97dbc-d2a7-4204-b356-98a8c29870fb   true         Delete           hostpath.csi.k8s.io   vgs-class                  default                        my-group-snapshot     10s
% kubectl get vgs 
NAME                READYTOUSE   VOLUMEGROUPSNAPSHOTCLASS   VOLUMEGROUPSNAPSHOTCONTENT                              CREATIONTIME   AGE
my-group-snapshot   true         vgs-class                  groupsnapcontent-29f97dbc-d2a7-4204-b356-98a8c29870fb   11s            11s
% kubectl get vs  
NAME                                                                                           READYTOUSE   SOURCEPVC   SOURCESNAPSHOTCONTENT                                                                             RESTORESIZE   SNAPSHOTCLASS   SNAPSHOTCONTENT                                                                                   CREATIONTIME   AGE
snapshot-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   true                     snapcontent-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   1Gi                           snapcontent-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   19s            19s
snapshot-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   true                     snapcontent-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   1Gi                           snapcontent-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   19s            19s
% kubectl get vsc
NAME                                                                                              READYTOUSE   RESTORESIZE   DELETIONPOLICY   DRIVER                VOLUMESNAPSHOTCLASS   VOLUMESNAPSHOT                                                                                 VOLUMESNAPSHOTNAMESPACE   AGE
snapcontent-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   true         1073741824    Delete           hostpath.csi.k8s.io                         snapshot-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   default                   20s
snapcontent-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   true         1073741824    Delete           hostpath.csi.k8s.io                         snapshot-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   default                   20s
  • Delete the volume group snapshot and verify that objects are deleted from API server:
% kubectl delete -f volumegroupsnapshot-example.yaml 
volumegroupsnapshot.groupsnapshot.storage.k8s.io "my-group-snapshot" deleted
% kubectl get vgs
No resources found in default namespace.
% kubectl get vgsc
No resources found
  • Verify that VS and VSC still exist:
% kubectl get vs  
NAME                                                                                           READYTOUSE   SOURCEPVC   SOURCESNAPSHOTCONTENT                                                                             RESTORESIZE   SNAPSHOTCLASS   SNAPSHOTCONTENT                                                                                   CREATIONTIME   AGE
snapshot-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   true                     snapcontent-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   1Gi                           snapcontent-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   19s            19s
snapshot-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   true                     snapcontent-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   1Gi                           snapcontent-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   19s            19s
% kubectl get vsc
NAME                                                                                              READYTOUSE   RESTORESIZE   DELETIONPOLICY   DRIVER                VOLUMESNAPSHOTCLASS   VOLUMESNAPSHOT                                                                                 VOLUMESNAPSHOTNAMESPACE   AGE
snapcontent-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   true         1073741824    Delete           hostpath.csi.k8s.io                         snapshot-0a89a20f6f519bbb505bd29e6e8651e50319d3e527705239f9687d1fbce1a8a6-2023-10-13-8.50.54   default                   20s
snapcontent-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   true         1073741824    Delete           hostpath.csi.k8s.io                         snapshot-4c6d03c90c122b50363288a808f0e784469b9730117fa028df007967a6b19359-2023-10-13-8.50.54   default                   20s

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Introduce logic to delete volume group snapshots

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Aug 15, 2023
@k8s-ci-robot k8s-ci-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Aug 15, 2023
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 15, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: RaunakShah / name: Raunak Pradip Shah (facefba)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 15, 2023
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 22, 2023
@RaunakShah RaunakShah changed the title [WIP][Do not review] DeleteVolumeGroupSnapshot API DeleteVolumeGroupSnapshot API - part 1 Oct 13, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 13, 2023
@RaunakShah
Copy link
Contributor Author

/assign @xing-yang

pkg/sidecar-controller/csi_handler.go Outdated Show resolved Hide resolved
pkg/sidecar-controller/csi_handler.go Outdated Show resolved Hide resolved
pkg/sidecar-controller/csi_handler.go Outdated Show resolved Hide resolved
pkg/utils/util.go Outdated Show resolved Hide resolved
pkg/sidecar-controller/groupsnapshot_helper.go Outdated Show resolved Hide resolved

/*
TODO: Add finalizer to group snapshot
TODO: Add PVC finalizer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need PVC finalizer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an open question I had - do we add any finalisers to PVCs, similar to the case for individual VolumeSnapshots?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, we do need to add PVC finalizers when creating a snapshot from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So will the individual snapshot creation handle that, or does the group snapshot also need to add a finaliser?

Copy link
Collaborator

@xing-yang xing-yang Nov 2, 2023

Choose a reason for hiding this comment

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

Since the creation of the individual VolumeSnapshot API objects (that are part of a group snapshot) are handled by the group snapshot controller, the PVC finalizer should also be added by the group snapshot controller. Let me know if you see any problems.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the first revision, let's try to separate the logic as much as possible to avoid introducing regression to the existing volume snapshot feature.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm going to merge this PR. Please address this comment in a followup PR.

pkg/common-controller/groupsnapshot_controller_helper.go Outdated Show resolved Hide resolved
pkg/common-controller/groupsnapshot_controller_helper.go Outdated Show resolved Hide resolved
pkg/common-controller/groupsnapshot_controller_helper.go Outdated Show resolved Hide resolved
pkg/common-controller/groupsnapshot_controller_helper.go Outdated Show resolved Hide resolved
@xing-yang
Copy link
Collaborator

Can you add a release note?

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 1, 2023
@xing-yang
Copy link
Collaborator

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 3, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RaunakShah, xing-yang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2023
@xing-yang
Copy link
Collaborator

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 3, 2023
@xing-yang
Copy link
Collaborator

Actually can you please squash the commits? After that we can cancel the hold.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 3, 2023
@RaunakShah
Copy link
Contributor Author

Actually can you please squash the commits? After that we can cancel the hold.

Done

@xing-yang
Copy link
Collaborator

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 3, 2023
@xing-yang
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 3, 2023
@k8s-ci-robot k8s-ci-robot merged commit dad8b28 into kubernetes-csi:master Nov 3, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants