|
| 1 | +#!/bin/sh |
| 2 | +# Copyright (c) 2022 Gitpod GmbH. All rights reserved. |
| 3 | +# Licensed under the MIT License. See License-MIT.txt in the project root for license information. |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +cat <<EOF |
| 8 | +================================== |
| 9 | +=== Gitpod Installation Status === |
| 10 | +================================== |
| 11 | +
|
| 12 | +This deployment checks if Gitpod has been installed to your |
| 13 | +cluster successfully. If this deployment is running then |
| 14 | +Gitpod has installed successfully. |
| 15 | +
|
| 16 | +If this deployment is in a failed state, it means that |
| 17 | +either your Gitpod installation is still in progress or |
| 18 | +that the installation job has failed. |
| 19 | +
|
| 20 | +If this deployment is in a failed state, it is almost |
| 21 | +certainly a symptom of a problem elsewhere and not the |
| 22 | +root cause. |
| 23 | +
|
| 24 | +================================== |
| 25 | +
|
| 26 | +
|
| 27 | +EOF |
| 28 | + |
| 29 | +DISPLAY_MESSAGE="1" |
| 30 | + |
| 31 | +while true |
| 32 | +do |
| 33 | + if [ "$(helm status -n "${NAMESPACE}" gitpod -o json | jq '.info.status == "deployed"')" != "true" ]; then |
| 34 | + # We are now in a failed state |
| 35 | + if [ "${DISPLAY_MESSAGE}" = "1" ]; then |
| 36 | + # Don't display a message if it's already shown success - this could confuse users |
| 37 | + if [ "$(kubectl get jobs.batch -n "${NAMESPACE}" -l component=gitpod-installer -o json | jq '.items | length')" = "0" ]; then |
| 38 | + # The Installer has crashed |
| 39 | + cat <<EOF |
| 40 | +The Gitpod installation job has failed. You can either: |
| 41 | + - go to the "Troubleshoot" section in the KOTS |
| 42 | + dashboard and run through the tests in there |
| 43 | + - redeploy Gitpod in the KOTS dashboard and watch |
| 44 | + the logs. The command for that is: |
| 45 | + "kubectl logs -f -n ${NAMESPACE} -l component=gitpod-installer --tail=-1" |
| 46 | +
|
| 47 | +To access the KOTS dashboard, you may need to run |
| 48 | +"kubectl kots admin-console -n ${NAMESPACE}" |
| 49 | +EOF |
| 50 | + else |
| 51 | + # Installation is still in progress |
| 52 | + echo "Your Gitpod installation is in progress. Please wait." |
| 53 | + fi |
| 54 | + fi |
| 55 | + |
| 56 | + # Exit with error code |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + |
| 60 | + # Gitpod is currently successfully installed |
| 61 | + if [ "${DISPLAY_MESSAGE}" = "1" ]; then |
| 62 | + # Once we've displayed this message, never show any more status messages |
| 63 | + DISPLAY_MESSAGE="0" |
| 64 | + |
| 65 | + cat <<EOF |
| 66 | +Gitpod is installed successfully. Your installation |
| 67 | +should be available at https://${DOMAIN}. |
| 68 | +EOF |
| 69 | + fi |
| 70 | + |
| 71 | + # Check installation status again in 10 seconds |
| 72 | + # This status may change in future which is why we keep checking |
| 73 | + sleep 10 |
| 74 | +done |
0 commit comments