Skip to content

Commit 8dfad49

Browse files
committed
Make the make install output less daunting
The current output is a bit daunting for first-time users as it outputs things like the following a few times: customresourcedefinition.apiextensions.k8s.io/patterns.gitops.hybrid-cloud-patterns.io created configmap/patterns-operator-config created subscription.operators.coreos.com/patterns-operator created error: resource mapping not found for name: "rhoai-patterns-demo" namespace: "openshift-operators" from "STDIN": no matches for kind "Pattern" in version "gitops.hybrid-cloud-patterns.io/v1alpha1" ensure CRDs are installed first Let's switch to something a bit more user-friendly: make -f common/Makefile operator-deploy make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops' Checking repository: https://github.com/mbaldessari/multicloud-gitops.git - branch 'luis-demo': OK Checking cluster: cluster-info: OK storageclass: WARNING: No storageclass found Installing pattern: Done ... Do some magic with file descriptors so we still manage to capture the helm template stderr and the oc apply stdout+stderr and output them at the end in case of failure. In such cases the output will be something like the following: Installing pattern: .....Installation failed [5/5]. Error: Pulled: quay.io/hybridcloudpatterns/pattern-install:0.0.3 Digest: sha256:dd2d35d462b75aa8358ff278757dca0ee3c878cadafa64df8c68f880b59569ef E1015 18:41:31.585465 196315 memcache.go:265] couldn't get current server API group list: Get "https://api.sno3.ocplab.ocp:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate signed by un known authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kube-apiserver-lb-signer") ... Suggested-by: Luis Tomas Bolivar <[email protected]>
1 parent 87776c6 commit 8dfad49

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ preview-%:
6868

6969
.PHONY: operator-deploy
7070
operator-deploy operator-upgrade: validate-prereq validate-origin validate-cluster ## runs helm install
71-
@set -e -o pipefail
72-
# Retry five times because the CRD might not be fully installed yet
73-
for i in {1..5}; do \
74-
helm template --include-crds --name-template $(NAME) $(PATTERN_INSTALL_CHART) $(HELM_OPTS) | oc apply -f- && break || sleep 10; \
75-
done
71+
@common/scripts/deploy-pattern.sh $(NAME) $(PATTERN_INSTALL_CHART) $(HELM_OPTS)
7672

7773
.PHONY: uninstall
7874
uninstall: ## runs helm uninstall

scripts/deploy-pattern.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -o pipefail
3+
4+
RUNS=5
5+
# Retry five times because the CRD might not be fully installed yet
6+
echo -n "Installing pattern: "
7+
for i in $(seq 1 ${RUNS}); do \
8+
exec 3>&1 4>&2
9+
OUT=$( { helm template --include-crds --name-template $* 2>&4 | oc apply -f- 2>&4 1>&3; } 4>&1 3>&1)
10+
exec 3>&- 4>&-
11+
ret=$?
12+
if [ ${ret} -eq 0 ]; then
13+
break;
14+
else
15+
echo -n "."
16+
sleep 10
17+
fi
18+
done
19+
20+
# All the runs failed
21+
if [ ${i} -eq ${RUNS} ]; then
22+
echo "Installation failed [${i}/${RUNS}]. Error:"
23+
echo "${OUT}"
24+
exit 1
25+
fi
26+
echo "Done"

0 commit comments

Comments
 (0)