From 2a0ac7f235290b75f888b43e2697570064e9c742 Mon Sep 17 00:00:00 2001 From: Brandon Squizzato Date: Mon, 18 Oct 2021 16:12:42 -0400 Subject: [PATCH] Add set -x in a few specific areas --- cicd/build.sh | 12 ++++++++++++ cicd/cji_smoke_test.sh | 5 +++++ cicd/deploy_ephemeral_db.sh | 2 ++ cicd/deploy_ephemeral_env.sh | 2 ++ 4 files changed, 21 insertions(+) diff --git a/cicd/build.sh b/cicd/build.sh index 4ad87d01..3753b516 100644 --- a/cicd/build.sh +++ b/cicd/build.sh @@ -38,31 +38,43 @@ function build { function docker_build { DOCKER_CONF="$PWD/.docker" mkdir -p "$DOCKER_CONF" + set -x docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io docker --config="$DOCKER_CONF" login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io + set +x if [ "$CACHE_FROM_LATEST_IMAGE" == "true" ]; then echo "Attempting to build image using cache" { + set -x docker --config="$DOCKER_CONF" pull "${IMAGE}" && docker --config="$DOCKER_CONF" build -t "${IMAGE}:${IMAGE_TAG}" $APP_ROOT -f $APP_ROOT/$DOCKERFILE --cache-from "${IMAGE}" + set +x } || { echo "Build from cache failed, attempting build without cache" + set -x docker --config="$DOCKER_CONF" build -t "${IMAGE}:${IMAGE_TAG}" $APP_ROOT -f $APP_ROOT/$DOCKERFILE + set +x } else + set -x docker --config="$DOCKER_CONF" build -t "${IMAGE}:${IMAGE_TAG}" $APP_ROOT -f $APP_ROOT/$DOCKERFILE + set +x fi + set -x docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}" + set +x } function podman_build { AUTH_CONF_DIR="$(pwd)/.podman" mkdir -p $AUTH_CONF_DIR export REGISTRY_AUTH_FILE="$AUTH_CONF_DIR/auth.json" + set -x podman login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io podman login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io podman build -f $APP_ROOT/$DOCKERFILE -t "${IMAGE}:${IMAGE_TAG}" $APP_ROOT podman push "${IMAGE}:${IMAGE_TAG}" + set +x } diff --git a/cicd/cji_smoke_test.sh b/cicd/cji_smoke_test.sh index bb5d319b..e579c2f0 100644 --- a/cicd/cji_smoke_test.sh +++ b/cicd/cji_smoke_test.sh @@ -28,6 +28,7 @@ if [[ -z $IQE_CJI_TIMEOUT ]]; then fi # Invoke the CJI using the options set via env vars +set -x pod=$( bonfire deploy-iqe-cji $COMPONENT_NAME \ --marker "$IQE_MARKER_EXPRESSION" \ @@ -39,13 +40,16 @@ pod=$( --env "clowder_smoke" \ --cji-name $CJI_NAME \ --namespace $NAMESPACE) +set +x # Pipe logs to background to keep them rolling in jenkins oc logs -n $NAMESPACE $pod -f & # Wait for the job to Complete or Fail before we try to grab artifacts # condition=complete does trigger when the job fails +set -x oc wait --timeout=$IQE_CJI_TIMEOUT --for=condition=JobInvocationComplete -n $NAMESPACE cji/$CJI_NAME +set +x # Get the minio client # TODO: bake this into jenkins agent template @@ -68,6 +72,7 @@ export MINIO_HOST=localhost export MINIO_PORT=$LOCAL_SVC_PORT # Setup the minio client to auth to the local eph minio in the ns +echo "Fetching artifacts from minio..." ./mc alias set minio http://$MINIO_HOST:$MINIO_PORT $MINIO_ACCESS $MINIO_SECRET_KEY # "mirror" copies the entire artifacts dir from the pod and writes it to the jenkins node diff --git a/cicd/deploy_ephemeral_db.sh b/cicd/deploy_ephemeral_db.sh index f62632c1..8134feee 100644 --- a/cicd/deploy_ephemeral_db.sh +++ b/cicd/deploy_ephemeral_db.sh @@ -11,6 +11,7 @@ DB_DEPLOYMENT_NAME="${DB_DEPLOYMENT_NAME:-$COMPONENT_NAME-db}" NAMESPACE=$(bonfire namespace reserve) # TODO: add code to bonfire to deploy an app if it is defined in 'sharedAppDbName' on the ClowdApp # TODO: add a bonfire command to deploy just an app's DB +set -x bonfire process \ $APP_NAME \ --source=appsre \ @@ -23,6 +24,7 @@ bonfire process \ $COMPONENTS_RESOURCES_ARG | oc apply -f - -n $NAMESPACE bonfire namespace wait-on-resources $NAMESPACE --db-only +set +x # Set up port-forward for DB LOCAL_DB_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()') diff --git a/cicd/deploy_ephemeral_env.sh b/cicd/deploy_ephemeral_env.sh index 1bdb352d..90ce0046 100644 --- a/cicd/deploy_ephemeral_env.sh +++ b/cicd/deploy_ephemeral_env.sh @@ -3,6 +3,7 @@ source ${CICD_ROOT}/_common_deploy_logic.sh # Deploy k8s resources for app and its dependencies (use insights-stage instead of insights-production for now) # -> use this PR as the template ref when downloading configurations for this component # -> use this PR's newly built image in the deployed configurations +set -x export NAMESPACE=$(bonfire namespace reserve) bonfire deploy \ ${APP_NAME} \ @@ -14,3 +15,4 @@ bonfire deploy \ --timeout ${DEPLOY_TIMEOUT} \ ${COMPONENTS_ARG} \ ${COMPONENTS_RESOURCES_ARG} +set +x