Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions internal/controller/bsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Comment thread
PrasadJoshi12 marked this conversation as resolved.
if bsl.Spec.Config == nil {
bsl.Spec.Config = make(map[string]string)
}
bsl.Spec.Config["region"] = bucket.Spec.Region
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions internal/controller/bsl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -4675,7 +4674,6 @@ func TestDPAReconciler_populateBSLFromCloudStorage(t *testing.T) {
},
},
Config: map[string]string{
"region": "eastus",
"storageAccount": "mystorageaccount",
},
Credential: &corev1.SecretKeySelector{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
{
Expand Down Expand Up @@ -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",
},
},
Expand Down