diff --git a/internal/controller/bsl.go b/internal/controller/bsl.go index 0841dc5b578..c09054bd472 100644 --- a/internal/controller/bsl.go +++ b/internal/controller/bsl.go @@ -258,11 +258,12 @@ func (r *DataProtectionApplicationReconciler) ReconcileBackupStorageLocations(lo } } - // Add region from CloudStorage CR if specified - if bucket.Spec.Region != "" && bsl.Spec.Config == nil { - bsl.Spec.Config = make(map[string]string) - } - if bucket.Spec.Region != "" { + // Add region from CloudStorage CR only for AWS provider. + // Currently only AWS supports region in BSL config. + if bucket.Spec.Provider == oadpv1alpha1.AWSBucketProvider && bucket.Spec.Region != "" { + if bsl.Spec.Config == nil { + bsl.Spec.Config = make(map[string]string) + } bsl.Spec.Config["region"] = bucket.Spec.Region } @@ -274,6 +275,12 @@ func (r *DataProtectionApplicationReconciler) ReconcileBackupStorageLocations(lo bsl.Spec.Config[k] = v } + // Defensive cleanup: region is only supported in BSL config for AWS. + // Remove stale region values that might remain from prior reconciliations + if bucket.Spec.Provider != oadpv1alpha1.AWSBucketProvider { + delete(bsl.Spec.Config, "region") + } + // Handle enableSharedConfig from CloudStorage CR if bucket.Spec.EnableSharedConfig != nil && *bucket.Spec.EnableSharedConfig { if bsl.Spec.Config == nil { @@ -478,7 +485,7 @@ func (r *DataProtectionApplicationReconciler) populateBSLFromCloudStorage(bslSpe } // Add region if specified in CloudStorage - if cloudStorage.Spec.Region != "" { + if cloudStorage.Spec.Provider == oadpv1alpha1.AWSBucketProvider && cloudStorage.Spec.Region != "" { bslSpec.Velero.Config["region"] = cloudStorage.Spec.Region } diff --git a/internal/controller/bsl_test.go b/internal/controller/bsl_test.go index 15dc685ad2e..92e441553f8 100644 --- a/internal/controller/bsl_test.go +++ b/internal/controller/bsl_test.go @@ -3336,7 +3336,6 @@ func TestDPAReconciler_ReconcileBackupStorageLocations(t *testing.T) { Config: map[string]string{ "storageAccount": "mystorageaccount", "resourceGroup": "myresourcegroup", - "region": "eastus", }, StorageType: velerov1.StorageType{ ObjectStorage: &velerov1.ObjectStorageLocation{ @@ -4675,7 +4674,6 @@ func TestDPAReconciler_populateBSLFromCloudStorage(t *testing.T) { }, }, Config: map[string]string{ - "region": "eastus", "storageAccount": "mystorageaccount", }, Credential: &corev1.SecretKeySelector{ diff --git a/internal/controller/cloudstorage_providers_integration_test.go b/internal/controller/cloudstorage_providers_integration_test.go index 45b29333f9b..8cb2c07f0da 100644 --- a/internal/controller/cloudstorage_providers_integration_test.go +++ b/internal/controller/cloudstorage_providers_integration_test.go @@ -351,7 +351,6 @@ func TestCloudStorageRefIntegrationGCP(t *testing.T) { expectedBucket: "my-gcp-backup-bucket", expectedConfig: map[string]string{ "project": "my-gcp-project", - "region": "us-central1", }, }, { @@ -427,7 +426,6 @@ func TestCloudStorageRefIntegrationGCP(t *testing.T) { expectedBucket: "legacy-backup-bucket", expectedConfig: map[string]string{ "project": "legacy-project", - "region": "us-west1", "snapshotLocation": "us-west1", }, },