Skip to content

Commit

Permalink
Cherry-pick changes to release-1.5 branch. (#570)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
6 people authored Mar 11, 2024
1 parent e956a53 commit 0b9a8de
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 79 deletions.
1 change: 1 addition & 0 deletions docs/guest.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This document discusses the velero vSphere plugin installation process in a **Ta

| Velero Plugin for vSphere Version | vSphere Version | Kubernetes Version | vSphere CSI Driver Version | Velero Version | vSphere Plugin Deprecated | vSphere Plugin EOL Date |
|-----------------------------------|--------------------|--------------------|----------------------------|----------------|------------|---------------|
1.5.1 | 8.0P02/8.0U2 | 1.23-1.25 | Bundled with TKGS | 1.11.1 | No | N/A |
| 1.5.1 | 8.0U1 | 1.24 | Bundled with TKGS | 1.10.2 | No | N/A |
| 1.5.1 | 8.0c | 1.24 | Bundled with TKGS | 1.10.2 | No | N/A |
| 1.4.2 | 8.0 | 1.20-1.23 | Bundled with TKGS | 1.9.2 | No | N/A |
Expand Down
21 changes: 21 additions & 0 deletions docs/known_issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,24 @@ Users might require ways to provide registry credentials when deploying velero a
## Volume Expansion Not Supported when there are Snapshots

If upload fails during a backup, the local snapshot will not be deleted. Velero vSphere Plugin will keep retrying the upload. If the user wants to expand volume, it will fail because volume expansion is not supported when there are snapshots on the volume.

## Backup and Restore with vSphere with IPV6

Users may hit the following error `too many colons in address` if they specify VC IP in IPV6 format in `csi-vsphere.conf` file and create `velero-vsphere-config-secret` from this file when deploying Velero Plugin for vSphere.

```
time="2023-11-06T10:53:21Z" level=error msg="Failed at copying to remote repository" Local PEID="ivd:fdc85e45-7c61-453f-9487-b7e47d020cd9:a6183167-d52d-4a83-932f-77104fac93e3" error="dial tcp: address 2620:124:6020:c304:0:a:0:763:443: too many colons in address" logSource="/go/src/github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/dataMover/data_mover.go:120"
```
The workaround to this problem is to use VC FQDN instead of IPV6 format in `csi-vsphere.conf` file. See the following example.

```
[Global]
cluster-id = "cluster0"
[VirtualCenter "vCenter-FQDN"]
insecure-flag = "true"
user = "[email protected]"
password = "password"
port = "443"
datacenters = "dc0"
```
2 changes: 1 addition & 1 deletion docs/self-signed-certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To keep consistency with velero, Velero plugin for vsphere also supports using v
* Guest cluster: supported since v1.1.1
* Supervisor cluster: not supported

To install with a storage provider secured by a self-signed certificate, the --cacert option needs to be added to provide a path to a certificate bundle to trust.
To install with a storage provider secured by a self-signed certificate, the --cacert option needs to be added to provide a path to a certificate bundle to trust. This certificate is used to verify TLS connection to the object store when backing up and restoring. The object store is specified with ` --backup-location-config` in the install command.

Here is an example install command:
```text
Expand Down
3 changes: 3 additions & 0 deletions docs/supervisor-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Below is the networking diagram of velero-plugin-for-vsphere in vSphere with Tan

Certain resources with the **vSphere with Tanzu** Supervisor Cluster need to be created by the Supervisor Cluster and cannot be restored. The **Velero Plugin for vSphere** blocks backup and restore of these resources and will generate errors if an attempt is made to backup or restore these resources and the backup or restore will be marked as "Partially Failed".

Similarly, certain resources with the **Tanzu Kubernetes Grid** multicloud (TKGm) need to be created by the TKGm cluster and cannot be restored. The **Velero Plugin for vSphere** blocks backup and restore of these resources and will generate errors if an attempt is made to backup or restore these resources and the backup or restore will be marked as "Partially Failed".

A configmap named `velero-vsphere-plugin-blocked-resources-list` will be created in the namespace where you install velero during **Velero Plugin for vSphere** installation. Exclude the resources in the configmap from your backups to avoid these errors. After the plugin is deployed, users can edit the configmap to remove resources from being blocked, or add more resources to be blocked. Users should not delete the configmap.

**Note**: The configmap `velero-vsphere-plugin-blocked-resources-list` will be reset to the default list only when user try to reboot velero pod.
Expand All @@ -32,6 +34,7 @@ The default list of blocked resources in configmap is:
certificaterequests.cert-manager.io
certificates.cert-manager.io
challenges.acme.cert-manager.io
clusterclasses.cluster.x-k8s.io
clusterissuers.cert-manager.io
clusternetworkinfos.nsx.vmware.com
clusterresourcesetbindings.addons.cluster.x-k8s.io
Expand Down
3 changes: 2 additions & 1 deletion docs/supervisor.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

| Velero Plugin for vSphere Version | vSphere Version | Kubernetes Version | vSphere CSI Driver Version | Velero Version | Velero vSphere Operator Version | Data Manager Version | vSphere Plugin Deprecated | vSphere Plugin EOL Date |
|-----------------------------------|---------------------|-------------------------------------------------------------------|----------------------------|----------------|---------------------------------|---------------|------------|---------------|
| 1.5.1 | 8.0P02/8.0U2 | Bundled with vSphere (1.24-1.26) | Bundled with vSphere | 1.11.1 | 1.5.0 | 1.2.0 | No | N/A |
| 1.5.1 | 8.0U1 | Bundled with vSphere (1.24) | Bundled with vSphere | 1.10.2 | 1.4.0 | 1.2.0 | No | N/A |
| 1.5.1 | 8.0c | Bundled with vSphere (1.24) | Bundled with vSphere | 1.10.2 | 1.4.0 | 1.2.0 | No | N/A |
| 1.4.2 | 8.0 | Bundled with vSphere (1.22-1.23) | Bundled with vSphere | 1.9.2 | 1.3.0 | 1.2.0 | No | N/A |
Expand Down Expand Up @@ -47,7 +48,7 @@ for the detail.

### Install with self-signed certificate

**Note**: Currently self-signed certificate is not supported on supervisor cluster, please refer to [velero-plugin-for-vsphere with a storage provider secured by a self-signed certificate](self-signed-certificate.md).
**Note**: Currently using self-signed certificate to connect to the object store is not supported on supervisor cluster. please refer to [velero-plugin-for-vsphere with a storage provider secured by a self-signed certificate](self-signed-certificate.md).

## Uninstall

Expand Down
3 changes: 3 additions & 0 deletions docs/vanilla.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

| Velero Plugin for vSphere Version | vSphere Version | Kubernetes Version | vSphere CSI Driver Version | Velero Version | vSphere Plugin Deprecated | vSphere Plugin EOL Date |
|-----------------------------------|------------------------|--------------------|-----------------------------------|----------------|------------|---------------|
1.5.2 | 8.0P02 | 1.28 | 3.1.1 | 1.12.1 | No | N/A |
1.5.1 | 8.0U2 | 1.27 | 3.0.1 | 1.11.1 | No | N/A |
1.5.1 | 8.0U1 | 1.26-1.27 | 3.0.1 | 1.10.2, 1.11.1 | No | N/A |
| 1.4.2 | 8.0 | 1.24-1.25 | 2.7.0 | 1.9.2 | No | N/A |
Expand Down Expand Up @@ -363,6 +364,8 @@ Below is an example command of Velero restore.
velero restore create --from-backup <your-backup-name>
```

Note that a StorageClass with the WaitForFirstConsumer Volume Binding Mode is not supported at restore time. Only a StorageClass with the Immediate Volume Binding Mode is supported at restore time. You'll have to change the Volume Binding Mode from WaitForFirstConsumer to Immediate for restore to work.

For the volume restores with changing storage class, please refer to [StorageClass Mapping](storageclass-mapping.md)

For more restore options, please refer to [Velero Document](https://velero.io/docs/v1.5/).
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/vmware-tanzu/velero v1.10.2
github.com/vmware/govmomi v0.22.2-0.20200329013745-f2eef8fc745f
github.com/vmware/virtual-disks v0.0.4
gopkg.in/gcfg.v1 v1.2.3
k8s.io/api v0.24.2
k8s.io/apiextensions-apiserver v0.24.2
k8s.io/apimachinery v0.24.2
Expand Down Expand Up @@ -134,14 +135,14 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20210916165020-5cb4fee858ee // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
Expand All @@ -152,6 +153,7 @@ require (
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/cli-runtime v0.24.0 // indirect
Expand Down
20 changes: 12 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,8 @@ golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -1157,13 +1157,13 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1174,8 +1174,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1390,6 +1390,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs=
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand All @@ -1401,6 +1403,8 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
20 changes: 20 additions & 0 deletions pkg/common/config/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package config

type Config struct {
Global struct {
VCenterIP string `gcfg:"ip"`
ClusterID string `gcfg:"cluster-id"`
ClusterDistribution string `gcfg:"cluster-distribution"`
CAFile string `gcfg:"ca-file"`
}
// Virtual Center configurations
VirtualCenter map[string]*VirtualCenterConfig
}

type VirtualCenterConfig struct {
User string `gcfg:"user"`
Password string `gcfg:"password"`
VCenterPort string `gcfg:"port"`
InsecureFlag bool `gcfg:"insecure-flag"`
Datacenters string `gcfg:"datacenters"`
}
17 changes: 13 additions & 4 deletions pkg/plugin/restore_pvc_action_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ package plugin
import (
"context"
"fmt"
"os"

"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/cmd"
"k8s.io/client-go/kubernetes"
"os"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
backupdriverv1 "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/apis/backupdriver/v1alpha1"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/backuprepository"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/constants"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
backupdriverTypedV1 "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/generated/clientset/versioned/typed/backupdriver/v1alpha1"
pluginItem "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/plugin/util"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/snapshotUtils"
"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/utils"
"github.com/vmware-tanzu/velero/pkg/plugin/velero"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -173,12 +174,14 @@ func (p *NewPVCRestoreItemAction) Execute(input *velero.RestoreItemActionExecute
return nil, errors.WithStack(err)
}

bSkipPVC, err := pluginItem.SkipPVCCreation(ctx, restConfig, &pvc, p.Log)
bSkipPVC, err := pluginItem.SkipPVCCreation(ctx, restConfig, &pvc, targetNamespace, p.Log)
if err != nil {
return nil, errors.WithStack(err)
} else if bSkipPVC {
}
if bSkipPVC {
// Skip PVCRestoreItemAction for PVC creation
// as it already exists
// and Restore is not remapping namespace
return &velero.RestoreItemActionExecuteOutput{
UpdatedItem: item,
}, nil
Expand All @@ -201,6 +204,12 @@ func (p *NewPVCRestoreItemAction) Execute(input *velero.RestoreItemActionExecute
}
}

// Check the StorageClass to validate that volumeBindingMode is not WaitForFirstConsumer
if err = pluginItem.ValidateRestoreStorageClass(restConfig, &itemSnapshot, p.Log); err != nil {
p.Log.Errorf("Failed to validate restore StorageClass VolumeBindingMode")
return nil, errors.WithStack(err)
}

snapshotID := itemSnapshot.Status.SnapshotID
snapshotMetadata := itemSnapshot.Status.Metadata
apiGroup := itemSnapshot.Spec.APIGroup
Expand Down
Loading

0 comments on commit 0b9a8de

Please sign in to comment.