diff --git a/CODEOWNERS b/CODEOWNERS index 28031fb87d0b..6ea631302f69 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -5,7 +5,7 @@ # For more details, read the following article on GitHub: https://help.github.com/articles/about-codeowners/. # These are the default owners for the whole content of the `kyma` repository. The default owners are automatically added as reviewers when you open a pull request, unless different owners are specified in the file. -* @derberg @pbochynski @PK85 @a-thaler @lszymik +* @derberg @pbochynski @PK85 @a-thaler @lszymik @piotrmsc /common/ @mszostok @aszecowka @piotrmiskiewicz @sjanota @Tomasz-Smelcerz-SAP @strekm @crabtree @akgalwas @janmedrek @Szymongib @sayanh @radufa @suleymanakbas91 diff --git a/ci.Dockerfile b/ci.Dockerfile index ef3773a8ef18..9a251529b3c9 100644 --- a/ci.Dockerfile +++ b/ci.Dockerfile @@ -59,7 +59,7 @@ RUN echo 'alias kc="kubectl"' >> ~/.bashrc # minikube and docker start must be done on starting container to make it work ENTRYPOINT /kyma/installation/scripts/docker-start.sh \ && /kyma/installation/cmd/run.sh --vm-driver none \ - && /kyma/installation/scripts/is-installed.sh \ + && /kyma/installation/scripts/is-installed.sh --timeout 30m \ && /kyma/installation/scripts/watch-pods.sh \ && (($RUN_TESTS && /kyma/installation/scripts/testing.sh) || $IGNORE_TEST_FAIL) \ && exec bash \ No newline at end of file diff --git a/docs/kyma/docs/033-inst-local-installation-scripts.md b/docs/kyma/docs/033-inst-local-installation-scripts.md index 66b49b316cf5..77db2b28d149 100644 --- a/docs/kyma/docs/033-inst-local-installation-scripts.md +++ b/docs/kyma/docs/033-inst-local-installation-scripts.md @@ -76,3 +76,7 @@ The `installation/scripts/installer.sh` script creates the default RBAC role, in The script applies the Installation custom resource and marks it with the `action=install` label, which triggers the Kyma installation. >**NOTE:** The Kyma installation runs in the background. Execute the `./installation/scripts/is-installed.sh` script to follow the installation process. + +## The is-installed.sh script + +The `installation/scripts/is-installed.sh` script shows the status of Kyma installation in real time. The script checks the status of the Installation custom resource. When it detects that the status changed to `Installed`, the script exits. If you define a timeout period and the status doesn't change to `Installed` within that period, the script fetches the installer logs. If you don't set a timeout period, the script waits for the change of the status until you terminate it. diff --git a/installation/scripts/is-installed.sh b/installation/scripts/is-installed.sh index b174540b7b74..9b845c80ee44 100755 --- a/installation/scripts/is-installed.sh +++ b/installation/scripts/is-installed.sh @@ -1,5 +1,47 @@ #!/bin/bash +################################################################################# +# +# Follow the process of Kyma installation +# Returns exit code 0 if Kyma is installed successfully +# +# Options: +# --verbose - reduce the delay between status checks; print the installation CR +# and status of all pods in every check +# --timeout - set the timeout after which the logs from installer will be printed +# and script will return exit code 1; the time accuracy depends on +# the delay between status checks; after the flag provide the time +# in the seconds (s/S), minutes (m/M) or hours (h/H) in the following +# format: +# +# Samples: +# bash is-installed.sh --timeout 25m +# bash is-installed.sh --verbose +# +################################################################################# + +function parse_timeout { + TIME=$(echo "$TIMEOUT" | tr -dc '0-9') + UNIT=$(echo "$TIMEOUT" | tr -d '0-9' | tr -d ' ') + + case "${UNIT}" in + "s"|"S") TIMEOUT=TIME ;; + "m"|"M") TIMEOUT=$(( TIME*60 )) ;; + "h"|"H") TIMEOUT=$(( TIME*3600 )) ;; + "") + echo "time unit not provided" + exit 1 + ;; + *) + echo "unknown time unit: ${UNIT}" + exit 1 + ;; + esac +} + +TIMEOUT="" +TIMEOUT_SET=0 +ITERATIONS_LEFT=0 VERBOSE=0 DELAY=10 @@ -14,6 +56,12 @@ do DELAY=5 shift # past flag ;; + --timeout) + TIMEOUT_SET=1 + TIMEOUT="$2" + shift # past flag + shift # past value + ;; *) # unknown option POSITIONAL+=("$1") # save it in an array for later shift # past argument @@ -22,6 +70,11 @@ do done set -- "${POSITIONAL[@]}" # restore positional parameters +if [ "$TIMEOUT_SET" -ne 0 ]; then + parse_timeout + ITERATIONS_LEFT=$(( TIMEOUT/DELAY )) +fi + echo "Checking state of kyma installation...hold on" while : do @@ -33,18 +86,30 @@ do break elif [ "$STATUS" = "Error" ] then - echo "kyma installation error... ${DESC}" - echo "----------" - echo "$(kubectl logs -n kyma-installer $(kubectl get pods --all-namespaces -l name=kyma-installer --no-headers -o jsonpath='{.items[*].metadata.name}'))" - echo "----------" - exit 1 + echo "kyma installation error, description: ${DESC}" + if [ "$TIMEOUT_SET" -eq 0 ]; then + echo "to fetch the logs from the installer execute: kubectl logs -n kyma-installer $(kubectl get pods --all-namespaces -l name=kyma-installer --no-headers -o jsonpath='{.items[*].metadata.name}')" + fi + if [ "$TIMEOUT_SET" -ne 0 ] && [ "$ITERATIONS_LEFT" -le 0 ]; then + echo "Fetching logs from the installer due to timeout:" + echo "----------" + kubectl logs -n kyma-installer $(kubectl get pods --all-namespaces -l name=kyma-installer --no-headers -o jsonpath='{.items[*].metadata.name}') + echo "----------" + echo "timeout reached on kyma installation error. Exiting" + exit 1 + fi else echo "Status: ${STATUS}, description: ${DESC}" - if [ "${VERBOSE}" -eq 1 ]; then - echo "$(kubectl get installation/kyma-installation -o yaml)" - echo "----------" - echo "$(kubectl get po --all-namespaces)" + if [ "$TIMEOUT_SET" -ne 0 ] && [ "$ITERATIONS_LEFT" -le 0 ]; then + echo "timeout reached. Exiting" + exit 1 fi - sleep $DELAY fi + if [ "${VERBOSE}" -eq 1 ]; then + kubectl get installation/kyma-installation -o yaml + echo "----------" + kubectl get po --all-namespaces + fi + sleep $DELAY + ITERATIONS_LEFT=$(( ITERATIONS_LEFT-1 )) done \ No newline at end of file diff --git a/prow/kyma-integration-on-debian/deploy-and-test-kyma.sh b/prow/kyma-integration-on-debian/deploy-and-test-kyma.sh index 7b870ab5751c..03b5c28c2dc8 100755 --- a/prow/kyma-integration-on-debian/deploy-and-test-kyma.sh +++ b/prow/kyma-integration-on-debian/deploy-and-test-kyma.sh @@ -11,5 +11,5 @@ ROOT_DIR=${CURRENT_DIR}/../../ sudo ${CURRENT_DIR}/install-deps-debian.sh sudo ${ROOT_DIR}/installation/cmd/run.sh --vm-driver "none" -sudo ${ROOT_DIR}/installation/scripts/is-installed.sh +sudo ${ROOT_DIR}/installation/scripts/is-installed.sh --timeout 30m sudo ${ROOT_DIR}/installation/scripts/testing.sh \ No newline at end of file