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

Update API for pre provisioned group snapshots #971

Merged

Conversation

RaunakShah
Copy link
Contributor

@RaunakShah RaunakShah commented Dec 5, 2023

What type of PR is this?
/kind api-change

What this PR does / why we need it:

This PR updates the API of VolumeGroupSnapshotContentSource based on the discussion in https://github.com/kubernetes-csi/external-snapshotter/pull/837/files

Also fix an intermittent error seen when deleting group snapshots.

Testing:

  1. Create 2 PVCs:
% kubectl get pvc,pv 
NAME                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
persistentvolumeclaim/csi-pvc     Bound    pvc-bb3f8595-22f8-4b2a-aa2a-5e43ac13d745   1Gi        RWO            csi-hostpath-sc   113d
persistentvolumeclaim/csi-pvc-2   Bound    pvc-07ea1396-58ec-4e66-a6f0-d7c6c23870a7   1Gi        RWO            csi-hostpath-sc   113d
NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS      REASON   AGE
persistentvolume/pvc-07ea1396-58ec-4e66-a6f0-d7c6c23870a7   1Gi        RWO            Delete           Bound    default/csi-pvc-2   csi-hostpath-sc            113d
persistentvolume/pvc-bb3f8595-22f8-4b2a-aa2a-5e43ac13d745   1Gi        RWO            Delete           Bound    default/csi-pvc     csi-hostpath-sc            113d
  1. Label PVCs for group snapshotting
% kubectl describe pvc | grep group     
               group=test
               group=test
  1. Verify volume handle of PVCs
% kubectl describe pv | grep -i handle
    VolumeHandle:      ea5b1cdb-581a-11ee-90ee-4eb123ae3a5c
    VolumeHandle:      ea5a5992-581a-11ee-90ee-4eb123ae3a5c
  1. Create a Volume group snapshot for these volumes:
% cat volumegroupsnapshot-example.yaml 
apiVersion: groupsnapshot.storage.k8s.io/v1alpha1
kind: VolumeGroupSnapshot
metadata:
  name: my-group-snapshot
spec:
  source:
    selector:
      matchLabels: 
        group: test
  volumeGroupSnapshotClassName: vgs-class

% kubectl create -f volumegroupsnapshot-example.yaml 
volumegroupsnapshot.groupsnapshot.storage.k8s.io/my-group-snapshot created
  1. Verify VGS, VGSC, VS and VSC resources:
% kubectl get vgs,vgsc,vs,vsc
NAME                                                                 READYTOUSE   VOLUMEGROUPSNAPSHOTCLASS   VOLUMEGROUPSNAPSHOTCONTENT                              CREATIONTIME   AGE
volumegroupsnapshot.groupsnapshot.storage.k8s.io/my-group-snapshot   true         vgs-class                  groupsnapcontent-cc0dc294-ec3e-457a-b434-616043febb1e   5m13s          5m15s

NAME                                                                                                            READYTOUSE   DELETIONPOLICY   DRIVER                VOLUMEGROUPSNAPSHOTCLASS   VOLUMEGROUPSNAPSHOTNAMESPACE   VOLUMEGROUPSNAPSHOT   AGE
volumegroupsnapshotcontent.groupsnapshot.storage.k8s.io/groupsnapcontent-cc0dc294-ec3e-457a-b434-616043febb1e   true         Delete           hostpath.csi.k8s.io   vgs-class                  default                        my-group-snapshot     5m13s

NAME                                                                                                                                  READYTOUSE   SOURCEPVC   SOURCESNAPSHOTCONTENT                                                                             RESTORESIZE   SNAPSHOTCLASS   SNAPSHOTCONTENT                                                                                   CREATIONTIME   AGE
volumesnapshot.snapshot.storage.k8s.io/snapshot-402b62a435db391a092f0ce75987320d27b0a0fb8cc4ae7af52918ecf90988b3-2024-01-12-6.15.24   true                     snapcontent-402b62a435db391a092f0ce75987320d27b0a0fb8cc4ae7af52918ecf90988b3-2024-01-12-6.15.24   1Gi                           snapcontent-402b62a435db391a092f0ce75987320d27b0a0fb8cc4ae7af52918ecf90988b3-2024-01-12-6.15.24   5m13s          5m13s
volumesnapshot.snapshot.storage.k8s.io/snapshot-a31a29b347f23a22892e3d1d3fdd4ac62e7d55749b82e34e73767e8ff08fbe76-2024-01-12-6.15.24   true                     snapcontent-a31a29b347f23a22892e3d1d3fdd4ac62e7d55749b82e34e73767e8ff08fbe76-2024-01-12-6.15.24   1Gi                           snapcontent-a31a29b347f23a22892e3d1d3fdd4ac62e7d55749b82e34e73767e8ff08fbe76-2024-01-12-6.15.24   5m13s          5m13s

NAME                                                                                                                                            READYTOUSE   RESTORESIZE   DELETIONPOLICY   DRIVER                VOLUMESNAPSHOTCLASS   VOLUMESNAPSHOT                                                                                 VOLUMESNAPSHOTNAMESPACE   AGE
volumesnapshotcontent.snapshot.storage.k8s.io/snapcontent-402b62a435db391a092f0ce75987320d27b0a0fb8cc4ae7af52918ecf90988b3-2024-01-12-6.15.24   true         1073741824    Delete           hostpath.csi.k8s.io                         snapshot-402b62a435db391a092f0ce75987320d27b0a0fb8cc4ae7af52918ecf90988b3-2024-01-12-6.15.24   default                   5m13s
volumesnapshotcontent.snapshot.storage.k8s.io/snapcontent-a31a29b347f23a22892e3d1d3fdd4ac62e7d55749b82e34e73767e8ff08fbe76-2024-01-12-6.15.24   true         1073741824    Delete           hostpath.csi.k8s.io                         snapshot-a31a29b347f23a22892e3d1d3fdd4ac62e7d55749b82e34e73767e8ff08fbe76-2024-01-12-6.15.24   default                   5m13s

% kubectl describe vsc
Name:         snapcontent-402b62a435db391a092f0ce75987320d27b0a0fb8cc4ae7af52918ecf90988b3-2024-01-12-6.15.24
Namespace:    
Labels:       <none>
Annotations:  <none>
API Version:  snapshot.storage.k8s.io/v1
Kind:         VolumeSnapshotContent
Metadata:
  Creation Timestamp:  2024-01-12T18:15:24Z
  Finalizers:
    snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
  Generation:  2
  Managed Fields:
    API Version:  snapshot.storage.k8s.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        .:
        f:deletionPolicy:
        f:driver:
        f:source:
          .:
          f:snapshotHandle:
    Manager:      csi-snapshotter
    Operation:    Update
    Time:         2024-01-12T18:15:24Z
    API Version:  snapshot.storage.k8s.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        .:
        f:creationTime:
        f:readyToUse:
        f:restoreSize:
        f:snapshotHandle:
        f:volumeGroupSnapshotHandle:
    Manager:      csi-snapshotter
    Operation:    Update
    Subresource:  status
    Time:         2024-01-12T18:15:24Z
    API Version:  snapshot.storage.k8s.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:finalizers:
          .:
          v:"snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection":
      f:spec:
        f:volumeSnapshotRef:
    Manager:         snapshot-controller
    Operation:       Update
    Time:            2024-01-12T18:15:26Z
  Resource Version:  2527625
  UID:               c62b161b-83ef-4f0f-b6ee-7cef66ada105
Spec:
  Deletion Policy:  Delete
  Driver:           hostpath.csi.k8s.io
  Source:
    Snapshot Handle:  8e6e1bd4-b176-11ee-861b-da56dc567fbf
  Volume Snapshot Ref:
    Kind:       VolumeSnapshots
    Name:       snapshot-402b62a435db391a092f0ce75987320d27b0a0fb8cc4ae7af52918ecf90988b3-2024-01-12-6.15.24
    Namespace:  default
    UID:        1bc1c5d6-44d9-400f-b7fb-3911e9b7635f
Status:
  Creation Time:                 1705083324890079594
  Ready To Use:                  true
  Restore Size:                  1073741824
  Snapshot Handle:               8e6e1bd4-b176-11ee-861b-da56dc567fbf
  Volume Group Snapshot Handle:  8e6dd21a-b176-11ee-861b-da56dc567fbf
Events:                          <none>


Name:         snapcontent-a31a29b347f23a22892e3d1d3fdd4ac62e7d55749b82e34e73767e8ff08fbe76-2024-01-12-6.15.24
Namespace:    
Labels:       <none>
Annotations:  <none>
API Version:  snapshot.storage.k8s.io/v1
Kind:         VolumeSnapshotContent
Metadata:
  Creation Timestamp:  2024-01-12T18:15:24Z
  Finalizers:
    snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
  Generation:  2
  Managed Fields:
    API Version:  snapshot.storage.k8s.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        .:
        f:deletionPolicy:
        f:driver:
        f:source:
          .:
          f:snapshotHandle:
    Manager:      csi-snapshotter
    Operation:    Update
    Time:         2024-01-12T18:15:24Z
    API Version:  snapshot.storage.k8s.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        .:
        f:creationTime:
        f:readyToUse:
        f:restoreSize:
        f:snapshotHandle:
        f:volumeGroupSnapshotHandle:
    Manager:      csi-snapshotter
    Operation:    Update
    Subresource:  status
    Time:         2024-01-12T18:15:24Z
    API Version:  snapshot.storage.k8s.io/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:finalizers:
          .:
          v:"snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection":
      f:spec:
        f:volumeSnapshotRef:
    Manager:         snapshot-controller
    Operation:       Update
    Time:            2024-01-12T18:15:26Z
  Resource Version:  2527631
  UID:               aa027fff-8a17-44cc-aae8-401a223074af
Spec:
  Deletion Policy:  Delete
  Driver:           hostpath.csi.k8s.io
  Source:
    Snapshot Handle:  8e6ff115-b176-11ee-861b-da56dc567fbf
  Volume Snapshot Ref:
    Kind:       VolumeSnapshots
    Name:       snapshot-a31a29b347f23a22892e3d1d3fdd4ac62e7d55749b82e34e73767e8ff08fbe76-2024-01-12-6.15.24
    Namespace:  default
    UID:        2461bd99-9991-455f-b4cf-98faf9151a83
Status:
  Creation Time:                 1705083324890079594
  Ready To Use:                  true
  Restore Size:                  1073741824
  Snapshot Handle:               8e6ff115-b176-11ee-861b-da56dc567fbf
  Volume Group Snapshot Handle:  8e6dd21a-b176-11ee-861b-da56dc567fbf
Events:                          <none>

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Update API for pre provisioned group snapshots

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 5, 2023
@xing-yang
Copy link
Collaborator

/assign @msau42

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 5, 2024
@RaunakShah RaunakShah force-pushed the deletegroupsnapshot-part-3 branch from 6db9491 to 0bd355c Compare January 5, 2024 19:29
@xing-yang
Copy link
Collaborator

Can you fix the unit test?

@RaunakShah RaunakShah force-pushed the deletegroupsnapshot-part-3 branch from 57c0a97 to e6dc65f Compare January 8, 2024 18:12
@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 Jan 12, 2024
@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 Jan 12, 2024
@k8s-ci-robot k8s-ci-robot merged commit 01d5449 into kubernetes-csi:master Jan 12, 2024
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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants