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

Fail the Restore if the StorageClass is associated with WaitForFirstConsumer volumeBindingMode #568

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

deepakkinni
Copy link
Collaborator

What this PR does / why we need it:
Fail the Restore if the StorageClass is associated with WaitForFirstConsumer volumeBindingMode

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

** Testing Done **

  1. Basic Regression: Backup and Restore with no VolumeBindingMode specified in the StorageClass(implying Immediate)
❯ velero backup create rest-warn-test-1 --include-namespaces=test-ns --snapshot-volumes
❯ velero backup describe rest-warn-test-1
Name:         rest-warn-test-1
Namespace:    velero
Labels:       velero.io/storage-location=default
Annotations:  velero.io/source-cluster-k8s-gitversion=v1.29.1
              velero.io/source-cluster-k8s-major-version=1
              velero.io/source-cluster-k8s-minor-version=29

Phase:  Completed

Errors:    0
Warnings:  0

Namespaces:
  Included:  test-ns
  Excluded:  <none>

Resources:
  Included:        *
  Excluded:        <none>
  Cluster-scoped:  auto

Label selector:  <none>

Storage Location:  default

Velero-Native Snapshot PVs:  true

TTL:  720h0m0s

CSISnapshotTimeout:  10m0s

Hooks:  <none>

Backup Format Version:  1.1.0

Started:    2024-02-29 11:08:03 -0800 PST
Completed:  2024-02-29 11:08:11 -0800 PST

Expiration:  2024-03-30 12:08:03 -0700 PDT

Total items to be backed up:  8
Items backed up:              8

Velero-Native Snapshots: <none included>

❯ velero restore create --from-backup rest-warn-test-1
❯ velero restore describe rest-warn-test-1-20240229111117
Name:         rest-warn-test-1-20240229111117
Namespace:    velero
Labels:       <none>
Annotations:  <none>

Phase:                       Completed
Total items to be restored:  5
Items restored:              5

Started:    2024-02-29 11:11:17 -0800 PST
Completed:  2024-02-29 11:12:21 -0800 PST

Backup:  rest-warn-test-1

Namespaces:
  Included:  all namespaces found in the backup
  Excluded:  <none>

Resources:
  Included:        *
  Excluded:        nodes, events, events.events.k8s.io, backups.velero.io, restores.velero.io, resticrepositories.velero.io, csinodes.storage.k8s.io, volumeattachments.storage.k8s.io, backuprepositories.velero.io
  Cluster-scoped:  auto

Namespace mappings:  <none>

Label selector:  <none>

Restore PVs:  auto

Existing Resource Policy:   <none>

Preserve Service NodePorts:  auto

❯ kubectl get pv,pvc -A
NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                               STORAGECLASS               VOLUMEATTRIBUTESCLASS   REASON   AGE
persistentvolume/pvc-7350c4ea-02a5-4806-ac11-76d992cb0eb3   1Gi        RWO            Delete           Bound    test-ns/example-vanilla-block-pvc   example-vanilla-block-sc   <unset>                          93s

NAMESPACE   NAME                                              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS               VOLUMEATTRIBUTESCLASS   AGE
test-ns     persistentvolumeclaim/example-vanilla-block-pvc   Bound    pvc-7350c4ea-02a5-4806-ac11-76d992cb0eb3   1Gi        RWO            example-vanilla-block-sc   <unset>                 96s

  1. Restore into a setup with a StorageClass with volumeBindingMode as WaitForFirstConsumer marked as default
    Expectation: Restore should fail
❯ kubectl get sc
NAME                                 PROVISIONER              RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
example-vanilla-block-sc (default)   csi.vsphere.vmware.com   Delete          WaitForFirstConsumer   false                  6s

❯ velero restore create --from-backup rest-warn-test-1
Restore request "rest-warn-test-1-20240229112130" submitted successfully.
Run `velero restore describe rest-warn-test-1-20240229112130` or `velero restore logs rest-warn-test-1-20240229112130` for more details.
❯ velero restore describe rest-warn-test-1-20240229112130
Name:         rest-warn-test-1-20240229112130
Namespace:    velero
Labels:       <none>
Annotations:  <none>

Phase:                       PartiallyFailed (run 'velero restore logs rest-warn-test-1-20240229112130' for more information)
Total items to be restored:  5
Items restored:              5

Started:    2024-02-29 11:21:30 -0800 PST
Completed:  2024-02-29 11:21:32 -0800 PST

Errors:
  Velero:     <none>
  Cluster:    <none>
  Namespaces:
    test-ns:  error preparing persistentvolumeclaims/test-ns/example-vanilla-block-pvc: rpc error: code = Unknown desc = The PVC to be restored is a associated with StorageClass with WaitForFirstConsumer VolumeBindingMode, this is currently not supported

Backup:  rest-warn-test-1

Namespaces:
  Included:  all namespaces found in the backup
  Excluded:  <none>

Resources:
  Included:        *
  Excluded:        nodes, events, events.events.k8s.io, backups.velero.io, restores.velero.io, resticrepositories.velero.io, csinodes.storage.k8s.io, volumeattachments.storage.k8s.io, backuprepositories.velero.io
  Cluster-scoped:  auto

Namespace mappings:  <none>

Label selector:  <none>

Restore PVs:  auto

Existing Resource Policy:   <none>

Preserve Service NodePorts:  auto

time="2024-02-29T19:21:32Z" level=error msg="Namespace test-ns, resource restore error: error preparing persistentvolumeclaims/test-ns/example-vanilla-block-pvc: rpc error: code = Unknown desc = The PVC to be restored is a associated with StorageClass with WaitForFirstConsumer VolumeBindingMode, this is currently not supported" logSource="pkg/controller/restore_controller.go:531" restore=velero/rest-warn-test-1-20240229112130
  1. Restore with StorageClass mapping, mapping from a StorageClass with Immediate VolumeBindingMode to a StorageClass with WaitForFirstConsumer VolumeBindingMode
    Expectation: Restore should fail
❯ kubectl get sc
NAME                         PROVISIONER              RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
example-vanilla-block-sc     csi.vsphere.vmware.com   Delete          Immediate              false                  43s
example-vanilla-block-sc-2   csi.vsphere.vmware.com   Delete          WaitForFirstConsumer   false                  7s

❯ velero restore create --from-backup rest-warn-test-1
Restore request "rest-warn-test-1-20240229113221" submitted successfully.
Run `velero restore describe rest-warn-test-1-20240229113221` or `velero restore logs rest-warn-test-1-20240229113221` for more details.
❯ velero restore describe rest-warn-test-1-20240229113221
Name:         rest-warn-test-1-20240229113221
Namespace:    velero
Labels:       <none>
Annotations:  <none>

Phase:                       PartiallyFailed (run 'velero restore logs rest-warn-test-1-20240229113221' for more information)
Total items to be restored:  5
Items restored:              5

Started:    2024-02-29 11:32:21 -0800 PST
Completed:  2024-02-29 11:32:22 -0800 PST

Errors:
  Velero:     <none>
  Cluster:    <none>
  Namespaces:
    test-ns:  error preparing persistentvolumeclaims/test-ns/example-vanilla-block-pvc: rpc error: code = Unknown desc = The PVC to be restored is a associated with StorageClass with WaitForFirstConsumer VolumeBindingMode, this is currently not supported

Backup:  rest-warn-test-1

Namespaces:
  Included:  all namespaces found in the backup
  Excluded:  <none>

Resources:
  Included:        *
  Excluded:        nodes, events, events.events.k8s.io, backups.velero.io, restores.velero.io, resticrepositories.velero.io, csinodes.storage.k8s.io, volumeattachments.storage.k8s.io, backuprepositories.velero.io
  Cluster-scoped:  auto

Namespace mappings:  <none>

Label selector:  <none>

Restore PVs:  auto

Existing Resource Policy:   <none>

Preserve Service NodePorts:  auto

time="2024-02-29T19:32:22Z" level=error msg="Namespace test-ns, resource restore error: error preparing persistentvolumeclaims/test-ns/example-vanilla-block-pvc: rpc error: code = Unknown desc = The PVC to be restored is a associated with StorageClass with WaitForFirstConsumer VolumeBindingMode, this is currently not supported" logSource="pkg/controller/restore_controller.go:531" restore=velero/rest-warn-test-1-20240229113221

Does this PR introduce a user-facing change?:

Prevents Restore when the target Restore StorageClass has WaitForFirstConsumer volumeBindingMode

pkg/plugin/util/util.go Outdated Show resolved Hide resolved
pkg/plugin/util/util.go Outdated Show resolved Hide resolved
@xing-yang
Copy link
Contributor

Need rebase?

…onsumer volumeBindingMode

Signed-off-by: Deepak Kinni <[email protected]>
@lipingxue
Copy link
Collaborator

Change looks good to me.

@lipingxue
Copy link
Collaborator

/approve

Copy link
Contributor

@xing-yang xing-yang left a comment

Choose a reason for hiding this comment

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

lgtm

@varunsrinivasan2
Copy link
Contributor

lgtm

@xing-yang xing-yang merged commit 8930bd7 into vmware-tanzu:main Mar 1, 2024
2 checks passed
lipingxue pushed a commit to lipingxue/velero-plugin-for-vsphere that referenced this pull request Mar 11, 2024
…onsumer volumeBindingMode (vmware-tanzu#568)

Signed-off-by: Deepak Kinni <[email protected]>
Co-authored-by: Deepak Kinni <[email protected]>
lipingxue pushed a commit to lipingxue/velero-plugin-for-vsphere that referenced this pull request Mar 11, 2024
…onsumer volumeBindingMode (vmware-tanzu#568)

Signed-off-by: Deepak Kinni <[email protected]>
Co-authored-by: Deepak Kinni <[email protected]>
Signed-off-by: Liping Xue <[email protected]>
lipingxue added a commit that referenced this pull request Mar 11, 2024
* Update support matrix for Vanilla, WCP and GC. (#559)

Signed-off-by: Liping Xue <[email protected]>

* Document change to update known issue. (#560)

* Document change.

Signed-off-by: Liping Xue <[email protected]>

* Address comment from Xing.

Signed-off-by: Liping Xue <[email protected]>

* Remove files that are not needed for this change.

Signed-off-by: Liping Xue <[email protected]>

---------

Signed-off-by: Liping Xue <[email protected]>

* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 (#562)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0.
- [Commits](golang/crypto@v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Liping Xue <[email protected]>

* Update document. (#566)

Signed-off-by: Liping Xue <[email protected]>

* Modify parsing behavior of login credentials to handle Go escape characters (#564)

* Signed-off-by: Varun Srinivasan <[email protected]>

Create common config and new function to parse config data

* Always populate "port" key of parameters map after setting default VC port if config port value is empty

Signed-off-by: Varun Srinivasan <[email protected]>

* Clean up test logging and unit tests

Signed-off-by: Varun Srinivasan <[email protected]>

* Keep only necessary config values

Signed-off-by: Varun Srinivasan <[email protected]>

* Refactor ParseConfig to return error for sanitized error handling

Signed-off-by: Varun Srinivasan <[email protected]>

---------

Signed-off-by: Varun Srinivasan <[email protected]>
Signed-off-by: Liping Xue <[email protected]>

* Only skip PVC creation if --namespace-mapping flag is not used (#565)

* Only skip PVC creation if --namespace-mapping flag is not used

Signed-off-by: Varun Srinivasan <[email protected]>

* Refactor SkipPVCCreation function signature to add target namespace as a parameter

Signed-off-by: Varun Srinivasan <[email protected]>

---------

Signed-off-by: Varun Srinivasan <[email protected]>
Signed-off-by: Liping Xue <[email protected]>

* Add doc that wffc is not supported (#567)

Signed-off-by: xing-yang <[email protected]>
Signed-off-by: Liping Xue <[email protected]>

* Fail the Restore if the StorageClass is associated with WaitForFirstConsumer volumeBindingMode (#568)

Signed-off-by: Deepak Kinni <[email protected]>
Co-authored-by: Deepak Kinni <[email protected]>
Signed-off-by: Liping Xue <[email protected]>

---------

Signed-off-by: Liping Xue <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Varun Srinivasan <[email protected]>
Signed-off-by: xing-yang <[email protected]>
Signed-off-by: Deepak Kinni <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Varun Srinivasan <[email protected]>
Co-authored-by: Xing Yang <[email protected]>
Co-authored-by: Deepak Kinni <[email protected]>
Co-authored-by: Deepak Kinni <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants