From 27bf8b0e1cc30dc0dba132aaa0d3168e5ecefcd0 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Thu, 7 Oct 2021 20:47:29 -0400 Subject: [PATCH 1/2] Add --no-default-backup-location --- api/v1alpha1/velero_types.go | 4 ++++ .../crd/bases/oadp.openshift.io_veleroes.yaml | 6 +++-- controllers/bsl.go | 2 +- controllers/bsl_test.go | 22 ++++++++++++++++++- tests/e2e/install_suite_test.go | 15 +++++++++++++ 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/velero_types.go b/api/v1alpha1/velero_types.go index dfa72df828e..a220830803d 100644 --- a/api/v1alpha1/velero_types.go +++ b/api/v1alpha1/velero_types.go @@ -56,6 +56,7 @@ const ResticRestoreImageKey UnsupportedImageKey = "resticRestoreImageFqin" // VeleroSpec defines the desired state of Velero type VeleroSpec struct { // BackupStorageLocations defines the list of desired configuration to use for BackupStorageLocations + // +optional BackupStorageLocations []velero.BackupStorageLocationSpec `json:"backupStorageLocations"` // VolumeSnapshotLocations defines the list of desired configuration to use for VolumeSnapshotLocations // +optional @@ -118,6 +119,9 @@ type VeleroSpec struct { // BackupImages is used to specify whether you want to deploy a registry for enabling backup and restore of images // +optional BackupImages *bool `json:"backupImages,omitempty"` + // If you need to install Velero without a default backup storage location NoDefaultBackupLocation flag is required for confirmation + // +optional + NoDefaultBackupLocation bool `json:"noDefaultBackupLocation,omitempty"` } // VeleroStatus defines the observed state of Velero diff --git a/config/crd/bases/oadp.openshift.io_veleroes.yaml b/config/crd/bases/oadp.openshift.io_veleroes.yaml index 38aa4abecfe..7ad02b3e1d9 100644 --- a/config/crd/bases/oadp.openshift.io_veleroes.yaml +++ b/config/crd/bases/oadp.openshift.io_veleroes.yaml @@ -144,6 +144,10 @@ spec: description: EnableRestic is a boolean to specify if restic daemonset instance should be created or not type: boolean + noDefaultBackupLocation: + description: If you need to install Velero without a default backup + storage location NoDefaultBackupLocation flag is required for confirmation + type: boolean noobaa: description: Noobaa is a boolean to specify if we should install backup storage from OCS operator with Noobaa @@ -380,8 +384,6 @@ spec: - provider type: object type: array - required: - - backupStorageLocations type: object status: description: VeleroStatus defines the observed state of Velero diff --git a/controllers/bsl.go b/controllers/bsl.go index f4b60589fb0..150c78ec9ed 100644 --- a/controllers/bsl.go +++ b/controllers/bsl.go @@ -18,7 +18,7 @@ func (r *VeleroReconciler) ValidateBackupStorageLocations(log logr.Logger) (bool return false, err } // Ensure we have a BSL or user has specified noobaa install - if len(velero.Spec.BackupStorageLocations) == 0 && !velero.Spec.Noobaa { + if len(velero.Spec.BackupStorageLocations) == 0 && !(velero.Spec.Noobaa || velero.Spec.NoDefaultBackupLocation) { return false, errors.New("no backupstoragelocations configured, ensure a backupstoragelocation or noobaa has been configured") } diff --git a/controllers/bsl_test.go b/controllers/bsl_test.go index 182c7137720..f550d24590c 100644 --- a/controllers/bsl_test.go +++ b/controllers/bsl_test.go @@ -52,7 +52,7 @@ func TestVeleroReconciler_ValidateBackupStorageLocations(t *testing.T) { wantErr bool }{ { - name: "test no BSLs, no noobaa", + name: "test no BSLs, no noobaa, no NoDefaultBackupLocation", VeleroCR: &oadpv1alpha1.Velero{ ObjectMeta: metav1.ObjectMeta{ Name: "foo", @@ -69,6 +69,26 @@ func TestVeleroReconciler_ValidateBackupStorageLocations(t *testing.T) { }, }, }, + { + name: "test no BSLs, no noobaa, with NoDefaultBackupLocation", + VeleroCR: &oadpv1alpha1.Velero{ + ObjectMeta: metav1.ObjectMeta{ + Name: "foo", + Namespace: "test-ns", + }, + Spec: oadpv1alpha1.VeleroSpec{ + NoDefaultBackupLocation: true, + }, + }, + want: true, + wantErr: false, + secret: &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cloud-credentials", + Namespace: "test-ns", + }, + }, + }, { name: "test BSLs specified, no noobaa", VeleroCR: &oadpv1alpha1.Velero{ diff --git a/tests/e2e/install_suite_test.go b/tests/e2e/install_suite_test.go index 93097585800..d5f3e392b05 100755 --- a/tests/e2e/install_suite_test.go +++ b/tests/e2e/install_suite_test.go @@ -216,5 +216,20 @@ var _ = Describe("Configuration testing for Velero Custom Resource", func() { "foo": "bar", }, }, nil), + Entry("NoDefaultBackupLocation", InstallCase{ + Name: "default-cr-node-selector", + VeleroSpec: &oadpv1alpha1.VeleroSpec{ + EnableRestic: pointer.Bool(true), + BackupStorageLocations: []velero.BackupStorageLocationSpec{}, + NoDefaultBackupLocation: true, + DefaultVeleroPlugins: []oadpv1alpha1.DefaultPlugin{ + oadpv1alpha1.DefaultPluginOpenShift, + }, + }, + ExpectRestic: true, + ExpectedPlugins: []string{ + common.VeleroPluginForOpenshift, + }, + }, nil), ) }) From 2c3ed66bd3c3e5d140340e0d84537b735a62ac86 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Thu, 7 Oct 2021 20:59:29 -0400 Subject: [PATCH 2/2] API_Ref update --- docs/API_ref.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/API_ref.md b/docs/API_ref.md index c1bc2eae136..e04d27c2109 100644 --- a/docs/API_ref.md +++ b/docs/API_ref.md @@ -21,4 +21,5 @@ | veleroResourceAllocations | [corev1.ResourceRequirements](https://pkg.go.dev/k8s.io/api/core/v1#ResourceRequirements) | Set specific resource `limits` and `requests` for the Velero pod. For more information, go [here](docs/config/resource_req_limits.md). | | veleroTolerations | [[]corev1.Toleration](https://pkg.go.dev/k8s.io/api/core/v1#Toleration) | | | volumeSnapshotLocations | [[]velero.VolumeSnapshotLocationSpec](https://velero.io/docs/v1.6/api-types/volumesnapshotlocation/) | Location to store volume snapshots. For further deatils, see [here](docs/config/bsl_and_vsl.md). | +| NoDefaultBackupLocation | [bool](https://pkg.go.dev/builtin#bool) | Assert that you do not want to use velero with a backup storage location. See [Velero Docs](https://velero.io/docs/v1.7/customize-installation/#do-not-configure-a-backup-storage-location-during-install). |