From d3ac3010a8b066a86cfd364023dadc0a044738f2 Mon Sep 17 00:00:00 2001 From: Shreyas Rao <42259948+shreyas-s-rao@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:39:46 +0530 Subject: [PATCH] Remove usage of *_STORAGE_API_ENDPOINT` environment variables for providers (#856) * Remove usage of `*_STORAGE_API_ENDPOINT` environment variables for providers * update TODO comment --- config/samples/etcd-secret-azurite.yaml | 1 + hack/ci-e2e-kind-azure.sh | 1 - internal/common/constants.go | 4 ---- internal/store/store.go | 2 -- test/e2e/utils.go | 1 + .../controllers/compaction/reconciler_test.go | 24 ------------------- 6 files changed, 2 insertions(+), 31 deletions(-) diff --git a/config/samples/etcd-secret-azurite.yaml b/config/samples/etcd-secret-azurite.yaml index 81c7d8b9f..9a7e707bc 100644 --- a/config/samples/etcd-secret-azurite.yaml +++ b/config/samples/etcd-secret-azurite.yaml @@ -10,4 +10,5 @@ data: storageAccount: ZGV2c3RvcmVhY2NvdW50MQ== storageKey: RWJ5OHZkTTAyeE5PY3FGbHFVd0pQTGxtRXRsQ0RYSjFPVXpGVDUwdVNSWjZJRnN1RnEyVVZFckN6NEk2dHEvSzFTWkZQVE90ci9LQkhCZWtzb0dNR3c9PQ== emulatorEnabled: dHJ1ZQ== # true + # TODO: replace with `domain` once we support using [production-style URLs](https://github.com/Azure/Azurite?tab=readme-ov-file#production-style-url) for Azurite storageAPIEndpoint: aHR0cDovL2F6dXJpdGUtc2VydmljZToxMDAwMA== # http://azurite-service:10000, emulatorEnabled has to be true diff --git a/hack/ci-e2e-kind-azure.sh b/hack/ci-e2e-kind-azure.sh index 2733a087b..05110e791 100755 --- a/hack/ci-e2e-kind-azure.sh +++ b/hack/ci-e2e-kind-azure.sh @@ -33,7 +33,6 @@ echo -n "${STORAGE_KEY}" > "${AZURE_APPLICATION_CREDENTIALS}/storageKey" make deploy-azurite make STORAGE_ACCOUNT="${STORAGE_ACCOUNT}" \ STORAGE_KEY="${STORAGE_KEY}" \ - AZURE_STORAGE_API_ENDPOINT="${AZURITE_ENDPOINT}" \ AZURE_EMULATOR_ENABLED="true" \ AZURITE_HOST="${AZURITE_HOST}" \ AZURE_STORAGE_CONNECTION_STRING="${AZURE_STORAGE_CONNECTION_STRING}" \ diff --git a/internal/common/constants.go b/internal/common/constants.go index 86d54060e..d6d1524c3 100644 --- a/internal/common/constants.go +++ b/internal/common/constants.go @@ -67,12 +67,8 @@ const ( EnvAzureApplicationCredentials = "AZURE_APPLICATION_CREDENTIALS" // EnvAzureEmulatorEnabled is the environment variable key that is checked to see if the Azure storage emulator Azurite is enabled. EnvAzureEmulatorEnabled = "AZURE_EMULATOR_ENABLED" - // EnvAzureStorageAPIEndpoint is the environment variable key for Azure storage API endpoint override. - EnvAzureStorageAPIEndpoint = "AZURE_STORAGE_API_ENDPOINT" // EnvGoogleApplicationCredentials is the environment variable key for Google application credentials. EnvGoogleApplicationCredentials = "GOOGLE_APPLICATION_CREDENTIALS" - // EnvGoogleStorageAPIEndpoint is the environment variable key for Google storage API endpoint override. - EnvGoogleStorageAPIEndpoint = "GOOGLE_STORAGE_API_ENDPOINT" // EnvOpenstackApplicationCredentials is the environment variable key for OpenStack application credentials. EnvOpenstackApplicationCredentials = "OPENSTACK_APPLICATION_CREDENTIALS" // EnvAlicloudApplicationCredentials is the environment variable key for Alicloud application credentials. diff --git a/internal/store/store.go b/internal/store/store.go index 0c9bdfc79..688f9f4f6 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -126,11 +126,9 @@ func GetProviderEnvVars(store *druidv1alpha1.StoreSpec) ([]corev1.EnvVar, error) case ABS: envVars = append(envVars, utils.GetEnvVarFromValue(common.EnvAzureApplicationCredentials, common.VolumeMountPathNonGCSProviderBackupSecret)) envVars = append(envVars, utils.GetEnvVarFromSecret(common.EnvAzureEmulatorEnabled, store.SecretRef.Name, "emulatorEnabled", true)) - envVars = append(envVars, utils.GetEnvVarFromSecret(common.EnvAzureStorageAPIEndpoint, store.SecretRef.Name, "storageAPIEndpoint", true)) case GCS: envVars = append(envVars, utils.GetEnvVarFromValue(common.EnvGoogleApplicationCredentials, fmt.Sprintf("%sserviceaccount.json", common.VolumeMountPathGCSBackupSecret))) - envVars = append(envVars, utils.GetEnvVarFromSecret(common.EnvGoogleStorageAPIEndpoint, store.SecretRef.Name, "storageAPIEndpoint", true)) case Swift: envVars = append(envVars, utils.GetEnvVarFromValue(common.EnvOpenstackApplicationCredentials, common.VolumeMountPathNonGCSProviderBackupSecret)) diff --git a/test/e2e/utils.go b/test/e2e/utils.go index c7a06315f..7cf3bd540 100644 --- a/test/e2e/utils.go +++ b/test/e2e/utils.go @@ -362,6 +362,7 @@ func getProviders() ([]TestProvider, error) { azuriteHost := getEnvOrFallback("AZURITE_HOST", "") if azuriteHost != "" { provider.Storage.SecretData["emulatorEnabled"] = []byte("true") + // TODO: replace with `domain` provider.Storage.SecretData["storageAPIEndpoint"] = []byte("http://" + azuriteHost) } } diff --git a/test/integration/controllers/compaction/reconciler_test.go b/test/integration/controllers/compaction/reconciler_test.go index ea80332c3..fbd2894c7 100644 --- a/test/integration/controllers/compaction/reconciler_test.go +++ b/test/integration/controllers/compaction/reconciler_test.go @@ -420,18 +420,6 @@ func validateStoreGCPForCompactionJob(instance *druidv1alpha1.Etcd, j *batchv1.J "Name": Equal(common.EnvGoogleApplicationCredentials), "Value": Equal("/var/.gcp/serviceaccount.json"), }), - common.EnvGoogleStorageAPIEndpoint: MatchFields(IgnoreExtras, Fields{ - "Name": Equal(common.EnvGoogleStorageAPIEndpoint), - "ValueFrom": PointTo(MatchFields(IgnoreExtras, Fields{ - "SecretKeyRef": PointTo(MatchFields(IgnoreExtras, Fields{ - "LocalObjectReference": MatchFields(IgnoreExtras, Fields{ - "Name": Equal(instance.Spec.Backup.Store.SecretRef.Name), - }), - "Key": Equal("storageAPIEndpoint"), - "Optional": Equal(ptr.To(true)), - })), - })), - }), }), }), }), @@ -556,18 +544,6 @@ func validateStoreAzureForCompactionJob(instance *druidv1alpha1.Etcd, j *batchv1 })), })), }), - common.EnvAzureStorageAPIEndpoint: MatchFields(IgnoreExtras, Fields{ - "Name": Equal(common.EnvAzureStorageAPIEndpoint), - "ValueFrom": PointTo(MatchFields(IgnoreExtras, Fields{ - "SecretKeyRef": PointTo(MatchFields(IgnoreExtras, Fields{ - "LocalObjectReference": MatchFields(IgnoreExtras, Fields{ - "Name": Equal(instance.Spec.Backup.Store.SecretRef.Name), - }), - "Key": Equal("storageAPIEndpoint"), - "Optional": Equal(ptr.To(true)), - })), - })), - }), }), }), }),