From 23a518ac06525f1a819e109f0ef6d21996bc4c41 Mon Sep 17 00:00:00 2001 From: David Newswanger Date: Thu, 20 Jul 2023 08:19:26 -0600 Subject: [PATCH] Fix namespace logos on s3 Issue: AAH-2575 --- .github/workflows/ci_oci-env-integration.yml | 1 + CHANGES/2575.bugfix | 1 + Makefile | 4 ++++ dev/oci_env_integration/actions/minio.py | 14 ++++++++++++++ .../oci_env_configs/minio.compose.env | 19 +++++++++++++++++++ galaxy_ng/app/tasks/namespaces.py | 9 ++++++--- 6 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 CHANGES/2575.bugfix create mode 100644 dev/oci_env_integration/actions/minio.py create mode 100644 dev/oci_env_integration/oci_env_configs/minio.compose.env diff --git a/.github/workflows/ci_oci-env-integration.yml b/.github/workflows/ci_oci-env-integration.yml index 04ff2ddc28..1856c956fe 100644 --- a/.github/workflows/ci_oci-env-integration.yml +++ b/.github/workflows/ci_oci-env-integration.yml @@ -27,6 +27,7 @@ jobs: - TEST_PROFILE: insights - TEST_PROFILE: iqe_rbac - TEST_PROFILE: x_repo_search + - TEST_PROFILE: minio runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/CHANGES/2575.bugfix b/CHANGES/2575.bugfix new file mode 100644 index 0000000000..75c0d3a623 --- /dev/null +++ b/CHANGES/2575.bugfix @@ -0,0 +1 @@ +Fix bug where namespace logos would fail to download with S3 backends. \ No newline at end of file diff --git a/Makefile b/Makefile index 3c0d8fd3f0..e71716d191 100644 --- a/Makefile +++ b/Makefile @@ -142,6 +142,10 @@ gh-action/standalone: gh-action/certified-sync: python3 dev/oci_env_integration/actions/certified-sync.py +.PHONY: gh-action/minio +gh-action/minio: + python3 dev/oci_env_integration/actions/minio.py + .PHONY: docker/loaddata docker/loaddata: ## Load initial data from python script $(call exec_or_run, api, "/bin/bash", "-c", "/entrypoint.sh manage shell < app/dev/common/setup_test_data.py") diff --git a/dev/oci_env_integration/actions/minio.py b/dev/oci_env_integration/actions/minio.py new file mode 100644 index 0000000000..a5a1f42aeb --- /dev/null +++ b/dev/oci_env_integration/actions/minio.py @@ -0,0 +1,14 @@ +import action_lib + +env = action_lib.OCIEnvIntegrationTest( + envs=[ + { + "env_file": "minio.compose.env", + "run_tests": True, + "db_restore": None, + + # the minio client can take a long time to download + "wait_before_tests": 120 + } + ] +) diff --git a/dev/oci_env_integration/oci_env_configs/minio.compose.env b/dev/oci_env_integration/oci_env_configs/minio.compose.env new file mode 100644 index 0000000000..ac40626f14 --- /dev/null +++ b/dev/oci_env_integration/oci_env_configs/minio.compose.env @@ -0,0 +1,19 @@ +COMPOSE_PROFILE=galaxy_ng/base:pminio +COMPOSE_PROJECT_NAME=ci-standalone + +DEV_SOURCE_PATH=galaxy_ng +COMPOSE_BINARY=docker +SETUP_TEST_DATA=1 +UPDATE_UI=0 +ENABLE_SIGNING=1 + +DJANGO_SUPERUSER_USERNAME=admin +DJANGO_SUPERUSER_PASSWORD=admin + +PULP_GALAXY_API_PATH_PREFIX=/api/galaxy/ + +API_PORT=53001 + +S3_ENDPOINT_URL=http://localhost:11651 +MINIO_CONSOLE_PORT=7812 +MINIO_PORT=11651 \ No newline at end of file diff --git a/galaxy_ng/app/tasks/namespaces.py b/galaxy_ng/app/tasks/namespaces.py index 2518ac795e..aa093d830a 100644 --- a/galaxy_ng/app/tasks/namespaces.py +++ b/galaxy_ng/app/tasks/namespaces.py @@ -55,7 +55,12 @@ def _download_avatar(url): print("file is not an image") return - return Artifact.init_and_validate(tf) + # the artifact has to be saved before the file is closed, or s3transfer + # will throw an error. + artifact = Artifact.init_and_validate(tf) + artifact.save() + + return artifact def _create_pulp_namespace(galaxy_ns_pk, download_logo): @@ -99,8 +104,6 @@ def _create_pulp_namespace(galaxy_ns_pk, download_logo): else: with transaction.atomic(): metadata.save() - if avatar_artifact: - avatar_artifact.save() ContentArtifact.objects.create( artifact=avatar_artifact, content=metadata,