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

Only dynamic provisioning for an independent snapshot needs a snapshot class #1204

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

xing-yang
Copy link
Collaborator

@xing-yang xing-yang commented Nov 20, 2024

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug

/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #1203

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Only dynamic provisioning for an independent snapshot needs a snapshot class. A member snapshot in a dynamically provisioned volume group snapshot does not need a snapshot class.

@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/bug Categorizes issue or PR as related to a bug. labels Nov 20, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 20, 2024
@xing-yang
Copy link
Collaborator Author

/assign @gnufied

@leonardoce
Copy link
Contributor

I tested it, and it works fine in my environment.

@leonardoce
Copy link
Contributor

leonardoce commented Nov 21, 2024

This is the result of a static provisioning of a volume group snapshot:

apiVersion: v1
items:
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshot
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"snapshot.storage.k8s.io/v1","kind":"VolumeSnapshot","metadata":{"annotations":{},"name":"new-static-snapshot-1","namespace":"default"},"spec":{"source":{"volumeSnapshotContentName":"new-static-snapshotcontent-1"}}}
    creationTimestamp: "2024-11-19T19:56:44Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
    generation: 2
    name: new-static-snapshot-1
    namespace: default
    resourceVersion: "2530673"
    uid: 1da45b88-39de-4bc3-967c-0de10f8c6a59
  spec:
    source:
      volumeSnapshotContentName: new-static-snapshotcontent-1
  status:
    boundVolumeSnapshotContentName: new-static-snapshotcontent-1
    creationTime: "2024-11-18T10:29:35Z"
    readyToUse: true
    restoreSize: 1Gi
    volumeGroupSnapshotName: static-vg
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshot
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"snapshot.storage.k8s.io/v1","kind":"VolumeSnapshot","metadata":{"annotations":{},"name":"new-static-snapshot-2","namespace":"default"},"spec":{"source":{"volumeSnapshotContentName":"new-static-snapshotcontent-2"}}}
    creationTimestamp: "2024-11-19T19:56:44Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
    generation: 2
    name: new-static-snapshot-2
    namespace: default
    resourceVersion: "2530675"
    uid: 4fad06b0-5bf3-4fb1-9c83-fd20535f6565
  spec:
    source:
      volumeSnapshotContentName: new-static-snapshotcontent-2
  status:
    boundVolumeSnapshotContentName: new-static-snapshotcontent-2
    creationTime: "2024-11-18T10:29:35Z"
    readyToUse: true
    restoreSize: 1Gi
    volumeGroupSnapshotName: static-vg
kind: List
metadata:
  resourceVersion: ""
apiVersion: v1
items:
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshotContent
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"snapshot.storage.k8s.io/v1","kind":"VolumeSnapshotContent","metadata":{"annotations":{},"name":"new-static-snapshotcontent-1"},"spec":{"deletionPolicy":"Retain","driver":"hostpath.csi.k8s.io","source":{"snapshotHandle":"02088aff-a598-11ef-a409-4ebdfafda5f0"},"volumeSnapshotRef":{"name":"new-static-snapshot-1","namespace":"default"}}}
    creationTimestamp: "2024-11-19T19:56:44Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
    generation: 3
    name: new-static-snapshotcontent-1
    resourceVersion: "2530674"
    uid: e1e3dea4-59f4-48fc-87a2-0c47f870278e
  spec:
    deletionPolicy: Retain
    driver: hostpath.csi.k8s.io
    source:
      snapshotHandle: 02088aff-a598-11ef-a409-4ebdfafda5f0
    volumeSnapshotRef:
      name: new-static-snapshot-1
      namespace: default
      uid: 1da45b88-39de-4bc3-967c-0de10f8c6a59
  status:
    creationTime: 1731925775950103755
    readyToUse: true
    restoreSize: 1073741824
    snapshotHandle: 02088aff-a598-11ef-a409-4ebdfafda5f0
    volumeGroupSnapshotHandle: 02088ae3-a598-11ef-a409-4ebdfafda5f0
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshotContent
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"snapshot.storage.k8s.io/v1","kind":"VolumeSnapshotContent","metadata":{"annotations":{},"name":"new-static-snapshotcontent-2"},"spec":{"deletionPolicy":"Retain","driver":"hostpath.csi.k8s.io","source":{"snapshotHandle":"0208f078-a598-11ef-a409-4ebdfafda5f0"},"volumeSnapshotRef":{"name":"new-static-snapshot-2","namespace":"default"}}}
    creationTimestamp: "2024-11-19T19:56:44Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
    generation: 3
    name: new-static-snapshotcontent-2
    resourceVersion: "2530676"
    uid: 2b47fd5c-d45a-4c87-b4f0-46eb3f8ef6f8
  spec:
    deletionPolicy: Retain
    driver: hostpath.csi.k8s.io
    source:
      snapshotHandle: 0208f078-a598-11ef-a409-4ebdfafda5f0
    volumeSnapshotRef:
      name: new-static-snapshot-2
      namespace: default
      uid: 4fad06b0-5bf3-4fb1-9c83-fd20535f6565
  status:
    creationTime: 1731925775950103755
    readyToUse: true
    restoreSize: 1073741824
    snapshotHandle: 0208f078-a598-11ef-a409-4ebdfafda5f0
    volumeGroupSnapshotHandle: 02088ae3-a598-11ef-a409-4ebdfafda5f0
kind: List
metadata:
  resourceVersion: ""

cc: @xing-yang

@xing-yang
Copy link
Collaborator Author

Thanks @leonardoce! Did you test dynamically creating a VolumeGroupSnapshot without creating a VolumeSnapshotClass to start with?

@leonardoce
Copy link
Contributor

Thanks @leonardoce! Did you test dynamically creating a VolumeGroupSnapshot without creating a VolumeSnapshotClass to start with?

Yes, I did. This is a dynamically provisioned VolumeGroupSnapshot, with no reference to a VolumeSnapshotClass:

apiVersion: groupsnapshot.storage.k8s.io/v1beta1
kind: VolumeGroupSnapshot
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"groupsnapshot.storage.k8s.io/v1alpha1","kind":"VolumeGroupSnapshot","metadata":{"annotations":{},"name":"new-groupsnapshot-demo","namespace":"default"},"spec":{"source":{"selector":{"matchLabels":{"cnpg.io/instanceName":"cluster-example-1"}}},"volumeGroupSnapshotClassName":"csi-hostpath-groupsnapclass"}}
  creationTimestamp: "2024-11-21T16:03:04Z"
  finalizers:
  - groupsnapshot.storage.kubernetes.io/volumegroupsnapshot-bound-protection
  generation: 1
  name: new-groupsnapshot-demo
  namespace: default
  resourceVersion: "2532361"
  uid: 8e89727f-a1e7-4aa7-941a-50f77958192e
spec:
  source:
    selector:
      matchLabels:
        cnpg.io/instanceName: cluster-example-1
  volumeGroupSnapshotClassName: csi-hostpath-groupsnapclass
status:
  boundVolumeGroupSnapshotContentName: groupsnapcontent-8e89727f-a1e7-4aa7-941a-50f77958192e
  creationTime: "2024-11-21T16:03:05Z"
  readyToUse: true
---
apiVersion: groupsnapshot.storage.k8s.io/v1beta1
kind: VolumeGroupSnapshotContent
metadata:
  creationTimestamp: "2024-11-21T16:03:04Z"
  finalizers:
  - groupsnapshot.storage.kubernetes.io/volumegroupsnapshotcontent-bound-protection
  generation: 1
  name: groupsnapcontent-8e89727f-a1e7-4aa7-941a-50f77958192e
  resourceVersion: "2532327"
  uid: 0fb0e4a7-dc5f-4c11-a7e7-943511b42416
spec:
  deletionPolicy: Delete
  driver: hostpath.csi.k8s.io
  source:
    volumeHandles:
    - 144f5adc-a591-11ef-a409-4ebdfafda5f0
    - 145063c3-a591-11ef-a409-4ebdfafda5f0
  volumeGroupSnapshotClassName: csi-hostpath-groupsnapclass
  volumeGroupSnapshotRef:
    apiVersion: groupsnapshot.storage.k8s.io/v1alpha1
    kind: VolumeGroupSnapshot
    name: new-groupsnapshot-demo
    namespace: default
    resourceVersion: "2532313"
    uid: 8e89727f-a1e7-4aa7-941a-50f77958192e
status:
  creationTime: 1732204985006263561
  readyToUse: true
  volumeGroupSnapshotHandle: 1799732c-a822-11ef-b950-56ca10c3efa1
  volumeSnapshotHandlePairList:
  - snapshotHandle: 1799773c-a822-11ef-b950-56ca10c3efa1
    volumeHandle: 144f5adc-a591-11ef-a409-4ebdfafda5f0
  - snapshotHandle: 180f5331-a822-11ef-b950-56ca10c3efa1
    volumeHandle: 145063c3-a591-11ef-a409-4ebdfafda5f0
---
apiVersion: v1
items:
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshot
  metadata:
    creationTimestamp: "2024-11-21T16:03:07Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshot-in-group-protection
    - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
    generation: 1
    labels:
      groupsnapshot.storage.k8s.io/volumeGroupSnapshotName: new-groupsnapshot-demo
    name: snapshot-0a6aadfb3dcaf55c2faf85284d6cfc826569367276af2f635c657da09d055ac5
    namespace: default
    resourceVersion: "2532390"
    uid: 73c82d85-fa49-427e-a3c7-118502159892
  spec:
    source:
      persistentVolumeClaimName: cluster-example-1
  status:
    boundVolumeSnapshotContentName: snapcontent-0a6aadfb3dcaf55c2faf85284d6cfc826569367276af2f635c657da09d055ac5
    creationTime: "2024-11-21T16:03:05Z"
    readyToUse: true
    restoreSize: 1Gi
    volumeGroupSnapshotName: new-groupsnapshot-demo
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshot
  metadata:
    creationTimestamp: "2024-11-21T16:03:07Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshot-in-group-protection
    - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
    generation: 1
    labels:
      groupsnapshot.storage.k8s.io/volumeGroupSnapshotName: new-groupsnapshot-demo
    name: snapshot-3a90d64175aa4b02c5277e0421b1ee1df5875123174473961b7af4133d00e998
    namespace: default
    resourceVersion: "2532393"
    uid: a11e2b4c-a76b-405b-a721-e5d6da64eb0f
  spec:
    source:
      persistentVolumeClaimName: cluster-example-1-wal
  status:
    boundVolumeSnapshotContentName: snapcontent-3a90d64175aa4b02c5277e0421b1ee1df5875123174473961b7af4133d00e998
    creationTime: "2024-11-21T16:03:05Z"
    readyToUse: true
    restoreSize: 1Gi
    volumeGroupSnapshotName: new-groupsnapshot-demo
kind: List
metadata:
  resourceVersion: ""
---
apiVersion: v1
items:
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshotContent
  metadata:
    creationTimestamp: "2024-11-21T16:03:07Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
    generation: 2
    labels:
      groupsnapshot.storage.k8s.io/volumeGroupSnapshotHandle: 1799732c-a822-11ef-b950-56ca10c3efa1
    name: snapcontent-0a6aadfb3dcaf55c2faf85284d6cfc826569367276af2f635c657da09d055ac5
    resourceVersion: "2532389"
    uid: a3a111ab-7b32-402f-becc-6696af1e3aa4
  spec:
    deletionPolicy: Delete
    driver: hostpath.csi.k8s.io
    source:
      volumeHandle: 144f5adc-a591-11ef-a409-4ebdfafda5f0
    sourceVolumeMode: Filesystem
    volumeSnapshotRef:
      kind: VolumeSnapshot
      name: snapshot-0a6aadfb3dcaf55c2faf85284d6cfc826569367276af2f635c657da09d055ac5
      namespace: default
      uid: 73c82d85-fa49-427e-a3c7-118502159892
  status:
    creationTime: 1732204985006263561
    readyToUse: true
    restoreSize: 1073741824
    snapshotHandle: 1799773c-a822-11ef-b950-56ca10c3efa1
    volumeGroupSnapshotHandle: 1799732c-a822-11ef-b950-56ca10c3efa1
- apiVersion: snapshot.storage.k8s.io/v1
  kind: VolumeSnapshotContent
  metadata:
    creationTimestamp: "2024-11-21T16:03:07Z"
    finalizers:
    - snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
    generation: 2
    labels:
      groupsnapshot.storage.k8s.io/volumeGroupSnapshotHandle: 1799732c-a822-11ef-b950-56ca10c3efa1
    name: snapcontent-3a90d64175aa4b02c5277e0421b1ee1df5875123174473961b7af4133d00e998
    resourceVersion: "2532391"
    uid: d2043284-5d02-4c72-8e46-e036b649b5c2
  spec:
    deletionPolicy: Delete
    driver: hostpath.csi.k8s.io
    source:
      volumeHandle: 145063c3-a591-11ef-a409-4ebdfafda5f0
    sourceVolumeMode: Filesystem
    volumeSnapshotRef:
      kind: VolumeSnapshot
      name: snapshot-3a90d64175aa4b02c5277e0421b1ee1df5875123174473961b7af4133d00e998
      namespace: default
      uid: a11e2b4c-a76b-405b-a721-e5d6da64eb0f
  status:
    creationTime: 1732204985006263561
    readyToUse: true
    restoreSize: 1073741824
    snapshotHandle: 180f5331-a822-11ef-b950-56ca10c3efa1
    volumeGroupSnapshotHandle: 1799732c-a822-11ef-b950-56ca10c3efa1
kind: List
metadata:
  resourceVersion: ""

@leonardoce
Copy link
Contributor

And that's a dynamically provisioned independent VolumeSnapshot:

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"snapshot.storage.k8s.io/v1","kind":"VolumeSnapshot","metadata":{"annotations":{},"name":"new-snapshot-demo-v1","namespace":"default"},"spec":{"source":{"persistentVolumeClaimName":"cluster-example-1"},"volumeSnapshotClassName":"csi-hostpath-snapclass"}}
  creationTimestamp: "2024-11-21T16:10:34Z"
  finalizers:
  - snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
  - snapshot.storage.kubernetes.io/volumesnapshot-bound-protection
  generation: 1
  name: new-snapshot-demo-v1
  namespace: default
  resourceVersion: "2533390"
  uid: f1a0c5db-9fa0-4e2e-b45f-1a9f9d687047
spec:
  source:
    persistentVolumeClaimName: cluster-example-1
  volumeSnapshotClassName: csi-hostpath-snapclass
status:
  boundVolumeSnapshotContentName: snapcontent-f1a0c5db-9fa0-4e2e-b45f-1a9f9d687047
  creationTime: "2024-11-21T16:10:34Z"
  readyToUse: true
  restoreSize: 1Gi
---
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotContent
metadata:
  creationTimestamp: "2024-11-21T16:10:34Z"
  finalizers:
  - snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
  generation: 1
  name: snapcontent-f1a0c5db-9fa0-4e2e-b45f-1a9f9d687047
  resourceVersion: "2533388"
  uid: baf8d0ab-3eb3-4bcc-a90f-c9ea5f215a7e
spec:
  deletionPolicy: Delete
  driver: hostpath.csi.k8s.io
  source:
    volumeHandle: 144f5adc-a591-11ef-a409-4ebdfafda5f0
  sourceVolumeMode: Filesystem
  volumeSnapshotClassName: csi-hostpath-snapclass
  volumeSnapshotRef:
    apiVersion: snapshot.storage.k8s.io/v1
    kind: VolumeSnapshot
    name: new-snapshot-demo-v1
    namespace: default
    resourceVersion: "2533374"
    uid: f1a0c5db-9fa0-4e2e-b45f-1a9f9d687047
status:
  creationTime: 1732205434865071916
  readyToUse: true
  restoreSize: 1073741824
  snapshotHandle: 23bc78d6-a823-11ef-b950-56ca10c3efa1

@xing-yang
Copy link
Collaborator Author

Thank you for testing this, @leonardoce!

@leonardoce
Copy link
Contributor

LGTM

@gnufied
Copy link
Contributor

gnufied commented Nov 22, 2024

/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 22, 2024
@k8s-ci-robot k8s-ci-robot merged commit 9d77fea into kubernetes-csi:master Nov 22, 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/bug Categorizes issue or PR as related to a bug. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using volumegroup snapshot requires a volumesnapshotclass?
4 participants