From 2dd425ae863a10c4b4af04f484cef8c151d9ffeb Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 17 May 2022 15:41:59 -0400 Subject: [PATCH 1/5] OADP-524 mtc operator type Enables alternative behavior when OADP is consumed by MTC --- api/v1alpha1/oadp_types.go | 3 + controllers/validator.go | 4 + controllers/validator_test.go | 97 ++++++++ controllers/velero.go | 9 +- controllers/velero_test.go | 309 +++++++++++++++++++++++++ pkg/credentials/credentials.go | 4 +- tests/e2e/dpa_deployment_suite_test.go | 6 +- 7 files changed, 426 insertions(+), 6 deletions(-) diff --git a/api/v1alpha1/oadp_types.go b/api/v1alpha1/oadp_types.go index 8971fe737cf..11cc38cef41 100644 --- a/api/v1alpha1/oadp_types.go +++ b/api/v1alpha1/oadp_types.go @@ -56,6 +56,9 @@ const CSIPluginImageKey UnsupportedImageKey = "csiPluginImageFqin" const ResticRestoreImageKey UnsupportedImageKey = "resticRestoreImageFqin" const RegistryImageKey UnsupportedImageKey = "registryImageFqin" const KubeVirtPluginImageKey UnsupportedImageKey = "kubevirtPluginImageFqin" +const OperatorTypeKey UnsupportedImageKey = "operator-type" + +const OperatorTypeMTC = "mtc" type VeleroConfig struct { // FeatureFlags defines the list of features to enable for Velero instance diff --git a/controllers/validator.go b/controllers/validator.go index f8ad8aa4c23..4d8d10a8bc1 100644 --- a/controllers/validator.go +++ b/controllers/validator.go @@ -45,6 +45,10 @@ func (r *DPAReconciler) ValidateDataProtectionCR(log logr.Logger) (bool, error) } } + if val, found := dpa.Spec.UnsupportedOverrides[oadpv1alpha1.OperatorTypeKey]; found && val != oadpv1alpha1.OperatorTypeMTC { + return false, errors.New("only mtc operator type override is supported") + } + if _, err := r.ValidateVeleroPlugins(r.Log); err != nil { return false, err } diff --git a/controllers/validator_test.go b/controllers/validator_test.go index ed2d3cbfe4f..fa65ecc1a6e 100644 --- a/controllers/validator_test.go +++ b/controllers/validator_test.go @@ -10,6 +10,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" + "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -47,6 +48,102 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { }, }, }, + // objects: []client.Object{}, + wantErr: false, + want: true, + }, + { + name: "given valid DPA CR, no default backup location, no backup images, MTC type override, no error case", + dpa: &oadpv1alpha1.DataProtectionApplication{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-DPA-CR", + Namespace: "test-ns", + }, + Spec: oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + DefaultPlugins: []oadpv1alpha1.DefaultPlugin{ + oadpv1alpha1.DefaultPluginAWS, + }, + NoDefaultBackupLocation: true, + }, + }, + BackupImages: pointer.Bool(false), + UnsupportedOverrides: map[oadpv1alpha1.UnsupportedImageKey]string{ + oadpv1alpha1.OperatorTypeKey: oadpv1alpha1.OperatorTypeMTC, + }, + }, + }, + objects: []client.Object{ + &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cloud-credentials", + Namespace: "test-ns", + }, + }, + }, + wantErr: false, + want: true, + }, + { + name: "given valid DPA CR, no default backup location, no backup images, notMTC type override, no error case", + dpa: &oadpv1alpha1.DataProtectionApplication{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-DPA-CR", + Namespace: "test-ns", + }, + Spec: oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + DefaultPlugins: []oadpv1alpha1.DefaultPlugin{ + oadpv1alpha1.DefaultPluginAWS, + }, + NoDefaultBackupLocation: true, + }, + }, + BackupImages: pointer.Bool(false), + UnsupportedOverrides: map[oadpv1alpha1.UnsupportedImageKey]string{ + oadpv1alpha1.OperatorTypeKey: "not" + oadpv1alpha1.OperatorTypeMTC, + }, + }, + }, + objects: []client.Object{ + &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cloud-credentials", + Namespace: "test-ns", + }, + }, + }, + wantErr: true, + want: false, + }, + { + name: "given valid DPA CR, no default backup location, backup images cannot be nil, error case", + dpa: &oadpv1alpha1.DataProtectionApplication{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-DPA-CR", + Namespace: "test-ns", + }, + Spec: oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + DefaultPlugins: []oadpv1alpha1.DefaultPlugin{ + oadpv1alpha1.DefaultPluginAWS, + }, + NoDefaultBackupLocation: true, + }, + }, + }, + }, + objects: []client.Object{ + &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cloud-credentials", + Namespace: "test-ns", + }, + }, + }, wantErr: false, want: true, }, diff --git a/controllers/velero.go b/controllers/velero.go index b95ace1b745..90477ffc185 100644 --- a/controllers/velero.go +++ b/controllers/velero.go @@ -713,10 +713,16 @@ func (r DPAReconciler) noDefaultCredentials(dpa oadpv1alpha1.DataProtectionAppli providerNeedsDefaultCreds := map[string]bool{} hasCloudStorage := false if dpa.Spec.Configuration.Velero.NoDefaultBackupLocation { + needDefaultCred := false + + if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.OperatorTypeKey] == oadpv1alpha1.OperatorTypeMTC { + // MTC requires default credentials + needDefaultCred = true + } // go through cloudprovider plugins and mark providerNeedsDefaultCreds to false for _, provider := range dpa.Spec.Configuration.Velero.DefaultPlugins { if psf, ok := credentials.PluginSpecificFields[provider]; ok && psf.IsCloudProvider { - providerNeedsDefaultCreds[psf.PluginName] = false + providerNeedsDefaultCreds[psf.PluginName] = needDefaultCred } } } else { @@ -761,4 +767,3 @@ func (r DPAReconciler) noDefaultCredentials(dpa oadpv1alpha1.DataProtectionAppli return providerNeedsDefaultCreds, hasCloudStorage, nil } - diff --git a/controllers/velero_test.go b/controllers/velero_test.go index c11a9dd901f..2143b9fc09d 100644 --- a/controllers/velero_test.go +++ b/controllers/velero_test.go @@ -246,6 +246,315 @@ func TestDPAReconciler_buildVeleroDeployment(t *testing.T) { }, }, }, + { + name: "given valid DPA CR, noDefaultBackupLocation, unsupportedOverrides operatorType MTC, vel deployment has secret volumes", + veleroDeployment: &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-velero-deployment", + Namespace: "test-ns", + }, + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app.kubernetes.io/name": common.Velero, + "app.kubernetes.io/instance": "test-Velero-CR", + "app.kubernetes.io/managed-by": common.OADPOperator, + "app.kubernetes.io/component": Server, + "component": "velero", + "deploy": "velero", + oadpv1alpha1.OadpOperatorLabel: "True", + }, + }, + }, + }, + dpa: &oadpv1alpha1.DataProtectionApplication{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-Velero-CR", + Namespace: "test-ns", + }, + Spec: oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + NoDefaultBackupLocation: true, + DefaultPlugins: allDefaultPluginsList, + }, + }, + UnsupportedOverrides: map[oadpv1alpha1.UnsupportedImageKey]string{ + oadpv1alpha1.OperatorTypeKey: oadpv1alpha1.OperatorTypeMTC, + }, + }, + }, + wantErr: false, + wantVeleroDeployment: &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-velero-deployment", + Namespace: "test-ns", + Labels: map[string]string{ + "app.kubernetes.io/name": common.Velero, + "app.kubernetes.io/instance": "test-Velero-CR", + "app.kubernetes.io/managed-by": common.OADPOperator, + "app.kubernetes.io/component": Server, + "component": "velero", + oadpv1alpha1.OadpOperatorLabel: "True", + }, + }, + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: appsv1.SchemeGroupVersion.String(), + }, + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app.kubernetes.io/name": common.Velero, + "app.kubernetes.io/instance": "test-Velero-CR", + "app.kubernetes.io/managed-by": common.OADPOperator, + "app.kubernetes.io/component": Server, + "component": "velero", + "deploy": "velero", + oadpv1alpha1.OadpOperatorLabel: "True", + }, + }, + Replicas: pointer.Int32(1), + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "app.kubernetes.io/name": common.Velero, + "app.kubernetes.io/instance": "test-Velero-CR", + "app.kubernetes.io/managed-by": common.OADPOperator, + "app.kubernetes.io/component": Server, + "component": "velero", + "deploy": "velero", + oadpv1alpha1.OadpOperatorLabel: "True", + }, + Annotations: map[string]string{ + "prometheus.io/scrape": "true", + "prometheus.io/port": "8085", + "prometheus.io/path": "/metrics", + }, + }, + Spec: corev1.PodSpec{ + RestartPolicy: corev1.RestartPolicyAlways, + ServiceAccountName: common.Velero, + Containers: []corev1.Container{ + { + Name: common.Velero, + Image: common.VeleroImage, + ImagePullPolicy: corev1.PullAlways, + Ports: []corev1.ContainerPort{ + { + Name: "metrics", + ContainerPort: 8085, + }, + }, + Resources: corev1.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("1"), + corev1.ResourceMemory: resource.MustParse("512Mi"), + }, + Requests: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("500m"), + corev1.ResourceMemory: resource.MustParse("128Mi"), + }, + }, + Command: []string{"/velero"}, + Args: []string{ + "server", + "--features=EnableCSI", + "--restic-timeout=1h", + }, + VolumeMounts: []corev1.VolumeMount{ + { + Name: "plugins", + MountPath: "/plugins", + }, + { + Name: "scratch", + MountPath: "/scratch", + }, + { + Name: "certs", + MountPath: "/etc/ssl/certs", + }, + { + Name: "cloud-credentials", + MountPath: "/credentials", + }, + { + Name: "cloud-credentials-gcp", + MountPath: "/credentials-gcp", + }, + { + Name: "cloud-credentials-azure", + MountPath: "/credentials-azure", + }, + }, + Env: []corev1.EnvVar{ + { + Name: common.VeleroScratchDirEnvKey, + Value: "/scratch", + }, + { + Name: common.VeleroNamespaceEnvKey, + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.namespace", + }, + }, + }, + { + Name: common.LDLibraryPathEnvKey, + Value: "/plugins", + }, + { + Name: common.AWSSharedCredentialsFileEnvKey, + Value: "/credentials/cloud", + }, + { + Name: common.GCPCredentialsEnvKey, + Value: "/credentials-gcp/cloud", + }, + { + Name: common.AzureCredentialsFileEnvKey, + Value: "/credentials-azure/cloud", + }, + }, + }, + }, + Volumes: []corev1.Volume{ + { + Name: "plugins", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }, + { + Name: "scratch", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }, + { + Name: "certs", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }, + { + Name: "cloud-credentials", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: "cloud-credentials", + }, + }, + }, + { + Name: "cloud-credentials-gcp", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: "cloud-credentials-gcp", + }, + }, + }, + { + Name: "cloud-credentials-azure", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: "cloud-credentials-azure", + }, + }, + }, + }, + InitContainers: []corev1.Container{ + { + Image: common.AWSPluginImage, + Name: common.VeleroPluginForAWS, + ImagePullPolicy: corev1.PullAlways, + Resources: corev1.ResourceRequirements{}, + TerminationMessagePath: "/dev/termination-log", + TerminationMessagePolicy: "File", + VolumeMounts: []corev1.VolumeMount{ + { + MountPath: "/target", + Name: "plugins", + }, + }, + }, + { + Image: common.GCPPluginImage, + Name: common.VeleroPluginForGCP, + ImagePullPolicy: corev1.PullAlways, + Resources: corev1.ResourceRequirements{}, + TerminationMessagePath: "/dev/termination-log", + TerminationMessagePolicy: "File", + VolumeMounts: []corev1.VolumeMount{ + { + MountPath: "/target", + Name: "plugins", + }, + }, + }, + { + Image: common.AzurePluginImage, + Name: common.VeleroPluginForAzure, + ImagePullPolicy: corev1.PullAlways, + Resources: corev1.ResourceRequirements{}, + TerminationMessagePath: "/dev/termination-log", + TerminationMessagePolicy: "File", + VolumeMounts: []corev1.VolumeMount{ + { + MountPath: "/target", + Name: "plugins", + }, + }, + }, + { + Image: common.KubeVirtPluginImage, + Name: common.KubeVirtPlugin, + ImagePullPolicy: corev1.PullAlways, + Resources: corev1.ResourceRequirements{}, + TerminationMessagePath: "/dev/termination-log", + TerminationMessagePolicy: "File", + VolumeMounts: []corev1.VolumeMount{ + { + MountPath: "/target", + Name: "plugins", + }, + }, + }, + { + Image: common.OpenshiftPluginImage, + Name: common.VeleroPluginForOpenshift, + ImagePullPolicy: corev1.PullAlways, + Resources: corev1.ResourceRequirements{}, + TerminationMessagePath: "/dev/termination-log", + TerminationMessagePolicy: "File", + VolumeMounts: []corev1.VolumeMount{ + { + MountPath: "/target", + Name: "plugins", + }, + }, + }, + { + Image: common.CSIPluginImage, + Name: common.VeleroPluginForCSI, + ImagePullPolicy: corev1.PullAlways, + Resources: corev1.ResourceRequirements{}, + TerminationMessagePath: "/dev/termination-log", + TerminationMessagePolicy: "File", + VolumeMounts: []corev1.VolumeMount{ + { + MountPath: "/target", + Name: "plugins", + }, + }, + }, + }, + }, + }, + }, + }, + }, { name: "given valid DPA CR with proxy env var, appropriate Velero Deployment is built", veleroDeployment: &appsv1.Deployment{ diff --git a/pkg/credentials/credentials.go b/pkg/credentials/credentials.go index c4edaf759e0..612e30db6c0 100644 --- a/pkg/credentials/credentials.go +++ b/pkg/credentials/credentials.go @@ -286,7 +286,9 @@ func AppendPluginSpecificSpecs(dpa *oadpv1alpha1.DataProtectionApplication, vele if !pluginSpecificMap.IsCloudProvider || !pluginNeedsCheck { continue } - if dpa.Spec.Configuration.Velero.NoDefaultBackupLocation && pluginSpecificMap.IsCloudProvider { + if dpa.Spec.Configuration.Velero.NoDefaultBackupLocation && + dpa.Spec.UnsupportedOverrides[oadpv1alpha1.OperatorTypeKey] != oadpv1alpha1.OperatorTypeMTC && + pluginSpecificMap.IsCloudProvider { continue } // set default secret name to use diff --git a/tests/e2e/dpa_deployment_suite_test.go b/tests/e2e/dpa_deployment_suite_test.go index 6d675db6308..2aaa91b457f 100644 --- a/tests/e2e/dpa_deployment_suite_test.go +++ b/tests/e2e/dpa_deployment_suite_test.go @@ -632,11 +632,11 @@ var _ = Describe("Configuration testing for DPA Custom Resource", func() { }, genericTests, ) - + type deletionCase struct { WantError bool } - DescribeTable("DPA Deletion test", + DescribeTable("DPA Deletion test", func(installCase deletionCase) { log.Printf("Building dpa") err := dpaCR.Build(RESTIC) @@ -663,5 +663,5 @@ var _ = Describe("Configuration testing for DPA Custom Resource", func() { } }, Entry("Should succeed", deletionCase{WantError: false}), - ) + ) }) From 43f79a1927cff894827a0a34895575073e25f554 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 17 May 2022 16:37:27 -0400 Subject: [PATCH 2/5] Remove unused comment. --- controllers/validator_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/validator_test.go b/controllers/validator_test.go index fa65ecc1a6e..6e824516f78 100644 --- a/controllers/validator_test.go +++ b/controllers/validator_test.go @@ -48,7 +48,6 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { }, }, }, - // objects: []client.Object{}, wantErr: false, want: true, }, From 75b67b960f01450eea8074db9975d4adaf40e5d2 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 19 Apr 2022 12:45:48 -0400 Subject: [PATCH 3/5] Don't getProviderSecret when noDefaultBackupLocation: true, backupImages: false (#607) * Don't getProviderSecret when noDefaultBackupLocation flag set Signed-off-by: Tiger Kaovilai * add check that when NoDefaultBackupLocation is set, dpa.Spec.BackupImages is false Use BackupImages functions when checking conditions * fix test case --- controllers/validator.go | 6 +++++- controllers/validator_test.go | 39 +++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/controllers/validator.go b/controllers/validator.go index 4d8d10a8bc1..6e2eaa798e8 100644 --- a/controllers/validator.go +++ b/controllers/validator.go @@ -28,6 +28,10 @@ func (r *DPAReconciler) ValidateDataProtectionCR(log logr.Logger) (bool, error) } } + if dpa.Spec.Configuration.Velero.NoDefaultBackupLocation && dpa.BackupImages() { + return false, errors.New("backupImages needs to be set to false when noDefaultLocationBackupLocation is set") + } + if len(dpa.Spec.BackupLocations) > 0 { for _, location := range dpa.Spec.BackupLocations { // check for velero BSL config or cloud storage config @@ -80,7 +84,7 @@ func (r *DPAReconciler) ValidateVeleroPlugins(log logr.Logger) (bool, error) { pluginNeedsCheck = true } - if ok && pluginSpecificMap.IsCloudProvider && pluginNeedsCheck { + if ok && pluginSpecificMap.IsCloudProvider && pluginNeedsCheck && !dpa.Spec.Configuration.Velero.NoDefaultBackupLocation { secretName := pluginSpecificMap.SecretName _, err := r.getProviderSecret(secretName) if err != nil { diff --git a/controllers/validator_test.go b/controllers/validator_test.go index 6e824516f78..f9b0ff98744 100644 --- a/controllers/validator_test.go +++ b/controllers/validator_test.go @@ -23,7 +23,7 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { wantErr bool }{ { - name: "given valid DPA CR, no error case", + name: "given valid DPA CR, no default backup location, no backup images, no error case", dpa: &oadpv1alpha1.DataProtectionApplication{ ObjectMeta: metav1.ObjectMeta{ Name: "test-DPA-CR", @@ -38,18 +38,34 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { NoDefaultBackupLocation: true, }, }, + BackupImages: pointer.Bool(false), }, }, - objects: []client.Object{ - &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cloud-credentials", - Namespace: "test-ns", + objects: []client.Object{}, + wantErr: false, + want: true, + }, + { + name: "given valid DPA CR, no default backup location, backup images cannot be nil, error case", + dpa: &oadpv1alpha1.DataProtectionApplication{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-DPA-CR", + Namespace: "test-ns", + }, + Spec: oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + DefaultPlugins: []oadpv1alpha1.DefaultPlugin{ + oadpv1alpha1.DefaultPluginAWS, + }, + NoDefaultBackupLocation: true, + }, }, }, }, - wantErr: false, - want: true, + objects: []client.Object{}, + wantErr: true, + want: false, }, { name: "given valid DPA CR, no default backup location, no backup images, MTC type override, no error case", @@ -143,11 +159,11 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { }, }, }, - wantErr: false, - want: true, + wantErr: true, + want: false, }, { - name: "given valid DPA CR, error case", + name: "given valid DPA CR, no default backup location, backup images cannot be true, error case", dpa: &oadpv1alpha1.DataProtectionApplication{ ObjectMeta: metav1.ObjectMeta{ Name: "test-DPA-CR", @@ -162,6 +178,7 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { NoDefaultBackupLocation: true, }, }, + BackupImages: pointer.Bool(true), }, }, objects: []client.Object{}, From 4d5fd4e0f87c19fe2dcd0ff598181f5e2bea7f82 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 17 May 2022 17:02:20 -0400 Subject: [PATCH 4/5] remove duplicate test entry --- controllers/validator_test.go | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/controllers/validator_test.go b/controllers/validator_test.go index f9b0ff98744..a9d8add2a9a 100644 --- a/controllers/validator_test.go +++ b/controllers/validator_test.go @@ -45,28 +45,6 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { wantErr: false, want: true, }, - { - name: "given valid DPA CR, no default backup location, backup images cannot be nil, error case", - dpa: &oadpv1alpha1.DataProtectionApplication{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-DPA-CR", - Namespace: "test-ns", - }, - Spec: oadpv1alpha1.DataProtectionApplicationSpec{ - Configuration: &oadpv1alpha1.ApplicationConfig{ - Velero: &oadpv1alpha1.VeleroConfig{ - DefaultPlugins: []oadpv1alpha1.DefaultPlugin{ - oadpv1alpha1.DefaultPluginAWS, - }, - NoDefaultBackupLocation: true, - }, - }, - }, - }, - objects: []client.Object{}, - wantErr: true, - want: false, - }, { name: "given valid DPA CR, no default backup location, no backup images, MTC type override, no error case", dpa: &oadpv1alpha1.DataProtectionApplication{ @@ -151,14 +129,7 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { }, }, }, - objects: []client.Object{ - &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cloud-credentials", - Namespace: "test-ns", - }, - }, - }, + objects: []client.Object{}, wantErr: true, want: false, }, From 3178a14428662887e6facc9422f2c9cf7554373d Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 17 May 2022 17:20:00 -0400 Subject: [PATCH 5/5] test case name typo --- controllers/validator_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/validator_test.go b/controllers/validator_test.go index a9d8add2a9a..d0780264733 100644 --- a/controllers/validator_test.go +++ b/controllers/validator_test.go @@ -79,7 +79,7 @@ func TestDPAReconciler_ValidateDataProtectionCR(t *testing.T) { want: true, }, { - name: "given valid DPA CR, no default backup location, no backup images, notMTC type override, no error case", + name: "given valid DPA CR, no default backup location, no backup images, notMTC type override, error case", dpa: &oadpv1alpha1.DataProtectionApplication{ ObjectMeta: metav1.ObjectMeta{ Name: "test-DPA-CR",