Skip to content

Commit

Permalink
log message tidyup
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Nov 9, 2021
1 parent 648e3aa commit 3d3a6d1
Showing 1 changed file with 41 additions and 26 deletions.
67 changes: 41 additions & 26 deletions images/kubectl-build-deploy-dind/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function patchBuildStep() {
totalStartTime=$(date -d "${1}" +%s)
startTime=$(date -d "${2}" +%s)
endTime=$(date -d "${3}" +%s)
timeZone=$(date +"%Z")

diffSeconds="$(($endTime-$startTime))"
diffTime=$(date -d @${diffSeconds} +"%H:%M:%S" -u)
Expand All @@ -94,16 +95,26 @@ function patchBuildStep() {
diffTotalTime=$(date -d @${diffTotalSeconds} +"%H:%M:%S" -u)

echo "##############################################"
echo "STEP: ${6}"
echo "STEP: Ended at ${3}"
echo "STEP: Duration ${diffTime}(H:M:S)"
echo "STEP: Total Duration ${diffTotalTime}(H:M:S)"
echo "STEP ${6}: Completed at ${3} (${timeZone}) Duration ${diffTime} Elapsed ${diffTotalTime}"
echo "##############################################"

# patch the buildpod with the buildstep
kubectl patch --insecure-skip-tls-verify -n ${4} pod ${LAGOON_BUILD_NAME} \
-p "{\"metadata\":{\"labels\":{\"lagoon.sh/buildStep\":\"${5}\"}}}"

# tiny sleep to allow patch to complete before logs roll again
sleep 0.5s
}

##############################################
### PREPARATION
##############################################

set +x
buildStartTime="$(date +"%Y-%m-%d %H:%M:%S")"
echo "STEP: Preparation started ${buildStartTime}"
set -x

##############################################
### PUSH the latest .lagoon.yml into lagoon-yaml configmap as a pre-deploy field
##############################################
Expand All @@ -128,15 +139,6 @@ if kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get configmap lagoon-yaml
fi
set -x

##############################################
### PREPARATION
##############################################

set +x
buildStartTime="$(date +"%Y-%m-%d %H:%M:%S")"
echo "STEP: Preparation started ${buildStartTime}"
set -x

# validate .lagoon.yml
if ! lagoon-linter; then
echo "https://docs.lagoon.sh/lagoon/using-lagoon-the-basics/lagoon-yml#restrictions describes some possible reasons for this build failure."
Expand All @@ -146,6 +148,12 @@ else
echo "lagoon-linter found no issues with the .lagoon.yml file"
fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${buildStartTime}" "${currentStepEnd}" "${NAMESPACE}" "initialSetup" "Initial Environment Setup"
previousStepEnd=${currentStepEnd}
set -x

# Load path of docker-compose that should be used
DOCKER_COMPOSE_YAML=($(cat .lagoon.yml | shyaml get-value docker-compose-yaml))

Expand Down Expand Up @@ -450,7 +458,7 @@ done

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${buildStartTime}" "${currentStepEnd}" "${NAMESPACE}" "preparationComplete" "Preparation Complete"
patchBuildStep "${buildStartTime}" "${buildStartTime}" "${currentStepEnd}" "${NAMESPACE}" "configureVars" "Configured Variables"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -604,7 +612,7 @@ fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "imageBuildComplete" "Image Builds Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "imageBuildComplete" "Image Builds"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -639,7 +647,7 @@ fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "preRolloutsCompleted" "Pre-Rollout Tasks Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "preRolloutsCompleted" "Pre-Rollout Tasks"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -745,7 +753,7 @@ fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "serviceConfigurationComplete" "Service Configuration Phase 1 Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "serviceConfigurationComplete" "Service Configuration Phase 1"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -910,7 +918,7 @@ do
MAIN_GENERATED_ROUTE=$SERVICE_NAME
fi


set +x
ROUTE_FASTLY_SERVICE_WATCH=false
# if the builddeploy controller is injecting a featureflag value, load it in
if [ -z $LAGOON_FASTLY_AUTOGENERATED_FEATURE_FLAG ]; then
Expand All @@ -926,6 +934,7 @@ do
LAGOON_FASTLY_AUTOGENERATED=$TEMP_LAGOON_FASTLY_AUTOGENERATED
fi
fi
set -x
# Create the fastly values required
FASTLY_ARGS=()
# if the feature is enabled, then do what is required to generated the labels/annotations etc
Expand Down Expand Up @@ -974,7 +983,7 @@ done

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "serviceConfiguration2Complete" "Service Configuration Phase 2 Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "serviceConfiguration2Complete" "Service Configuration Phase 2"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -1478,7 +1487,7 @@ fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "routeConfigurationComplete" "Route/Ingress Configuration Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "routeConfigurationComplete" "Route/Ingress Configuration"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -1646,7 +1655,7 @@ fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "backupConfigurationComplete" "Backup Configuration Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "backupConfigurationComplete" "Backup Configuration"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -1848,7 +1857,7 @@ fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "imagePushComplete" "Image Push Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "imagePushComplete" "Image Push to Registry"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -1960,7 +1969,7 @@ done

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "deploymentTemplatingComplete" "Deployment Templating Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "deploymentTemplatingComplete" "Deployment Templating"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -2020,7 +2029,7 @@ done

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "deploymentApplyComplete" "Applying Deployments Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "deploymentApplyComplete" "Applying Deployments"
previousStepEnd=${currentStepEnd}
set -x

Expand All @@ -2047,7 +2056,7 @@ done

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "cronjobCleanupComplete" "Cronjob Cleanup Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "cronjobCleanupComplete" "Cronjob Cleanup"
previousStepEnd=${currentStepEnd}
set -x

Expand Down Expand Up @@ -2083,7 +2092,7 @@ fi

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "postRolloutsCompleted" "Post-Rollout Tasks Complete"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "postRolloutsCompleted" "Post-Rollout Tasks"
previousStepEnd=${currentStepEnd}
set -x

Expand All @@ -2100,4 +2109,10 @@ if kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get configmap lagoon-yaml
# create it
kubectl --insecure-skip-tls-verify -n ${NAMESPACE} create configmap lagoon-yaml --from-file=post-deploy=.lagoon.yml
fi
set -x

set +x
currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")"
patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "deployCompleted" "Build and Deploy"
previousStepEnd=${currentStepEnd}
set -x

0 comments on commit 3d3a6d1

Please sign in to comment.