Skip to content

Commit

Permalink
Merge pull request #1221 from ORNL/1219-daps-bug-gitlab-ci-gcs-log
Browse files Browse the repository at this point in the history
1219 daps bug gitlab ci gcs log
  • Loading branch information
JoshuaSBrown authored Jan 9, 2025
2 parents f60d2f7 + 28918ef commit 5e52a0a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
17 changes: 16 additions & 1 deletion .gitlab/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,22 @@
stage: log
script:
- BRANCH_LOWER=$(echo "$CI_COMMIT_REF_NAME" | tr '[:upper:]' '[:lower:]')
- docker logs $(docker ps -a --filter "ancestor=${REGISTRY}/${PROJECT}/${COMPONENT}-${BRANCH_LOWER}" --format "{{.Names}}")
- FULL_IMAGE_NAME="${REGISTRY}/${PROJECT}/${COMPONENT}-${BRANCH_LOWER}"
- echo "Full image name is $FULL_IMAGE_NAME"
- ANCESTOR_CONTAINERS=$(docker ps -a --filter "ancestor=${FULL_IMAGE_NAME}" --format "{{.Names}}")
- echo "${ANCESTOR_CONTAINERS}"
# It is possible to return more than one container with the same ancestor
# for instance if two different branches have the exact same build but
# different names. Or one image was built on top of another and share the
# same base.
- MATCHING_CONTAINERS=$( echo "$ANCESTOR_CONTAINERS" | grep "${COMPONENT}-${BRANCH_LOWER}" || echo "")
- if [ -z "$MATCHING_CONTAINERS" ]; then
echo "No matching containers found for image ${FULL_IMAGE_NAME} and component ${COMPONENT}-${BRANCH_LOWER}";
else
echo "Getting log output for the following."
echo "$MATCHING_CONTAINERS"
docker logs $MATCHING_CONTAINERS;
fi
rules:
- when: always

Expand Down
6 changes: 3 additions & 3 deletions .gitlab/end_to_end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ end-to-end-repo-setup:

# Requires setting up Globus Connect Server, requires firewall exceptions on
# the machine running this.
# Note we need the certificates to be available on the gcs-authz container
# Note we need the certificates to be available on the gcs container
# if it is meant to be run on the same machine as the metadata services
# because the Apache web server can then route traffic appropriately, if
# run separate from the metadata services it should not be needed.
Expand Down Expand Up @@ -312,13 +312,13 @@ end-to-end-gcs-authz-setup:
- chown gitlab-runner "$HOST_LOG_FILE_PATH"
- ./scripts/generate_datafed.sh
- docker login "${REGISTRY}" -u "${HARBOR_USER}" -p "${HARBOR_DATAFED_GITLAB_CI_REGISTRY_TOKEN}"
- ./scripts/container_stop.sh -n "gcs-authz" -p
- ./scripts/container_stop.sh -n "${COMPONENT}" -p
- random_string=$(bash -c "cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w "10" | head -n 1")
- cat $CI_DATAFED_CORE_PUB_KEY > /shared/datafed-repo-key.pub
- cat $CI_DATAFED_CORE_PRIV_KEY > /shared/datafed-repo-key.priv
- echo "#!/bin/bash" > run_globus.sh
- echo "docker run -d \\" >> run_globus.sh
- echo "--name \"gcs-authz-${BRANCH_LOWER}-${CI_COMMIT_SHORT_SHA}-${random_string}\" \\" >> run_globus.sh
- echo "--name \"${COMPONENT}-${BRANCH_LOWER}-${CI_COMMIT_SHORT_SHA}-${random_string}\" \\" >> run_globus.sh
- echo "--network host \\" >> run_globus.sh
- echo "-e DATAFED_GLOBUS_APP_SECRET=\"$CI_DATAFED_GLOBUS_APP_SECRET\" \\" >> run_globus.sh
- echo "-e DATAFED_GLOBUS_APP_ID=\"$CI_DATAFED_GLOBUS_APP_ID\" \\" >> run_globus.sh
Expand Down
4 changes: 2 additions & 2 deletions .gitlab/stage_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ run-authz-unit-job:
- chown gitlab-runner "$HOST_LOG_FILE_PATH"
- ./scripts/generate_datafed.sh
- docker login "${REGISTRY}" -u "${HARBOR_USER}" -p "${HARBOR_DATAFED_GITLAB_CI_REGISTRY_TOKEN}"
- ./scripts/container_stop.sh -n "gcs-authz" -p
- ./scripts/container_stop.sh -n "${COMPONENT}" -p
- random_string=$(bash -c "cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w "10" | head -n 1")
- echo "#!/bin/bash" > run_globus.sh
- echo "docker run \\" >> run_globus.sh
- echo "--name \"gcs-authz-${BRANCH_LOWER}-${CI_COMMIT_SHORT_SHA}-${random_string}\" \\" >> run_globus.sh
- echo "--name \"${COMPONENT}-${BRANCH_LOWER}-${CI_COMMIT_SHORT_SHA}-${random_string}\" \\" >> run_globus.sh
- echo "--network host \\" >> run_globus.sh
- echo "-e DATAFED_GLOBUS_APP_SECRET=\"$CI_DATAFED_GLOBUS_APP_SECRET\" \\" >> run_globus.sh
- echo "-e DATAFED_GLOBUS_APP_ID=\"$CI_DATAFED_GLOBUS_APP_ID\" \\" >> run_globus.sh
Expand Down

0 comments on commit 5e52a0a

Please sign in to comment.