Skip to content

Commit

Permalink
Merge remote-tracking branch 'common/main' into newer-common
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaldessari committed Oct 25, 2024
2 parents 8119b8f + cacdd23 commit 5bc0e00
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
22 changes: 14 additions & 8 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ preview-%:

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

.PHONY: uninstall
uninstall: ## runs helm uninstall
Expand Down Expand Up @@ -129,12 +125,22 @@ token-kubeconfig: ## Create a local ~/.kube/config with password (not usually ne

# We only check the remote ssh git branch's existance if we're not running inside a container
# as getting ssh auth working inside a container seems a bit brittle
# If the main repoUpstreamURL field is set, then we need to check against
# that and not target_repo
.PHONY: validate-origin
validate-origin: ## verify the git origin is available
@echo "Checking repository:"
@echo -n " $(TARGET_REPO) - branch '$(TARGET_BRANCH)': "
@git ls-remote --exit-code --heads $(TARGET_REPO) $(TARGET_BRANCH) >/dev/null &&\
echo "OK" || (echo "NOT FOUND"; exit 1)
$(eval UPSTREAMURL := $(shell yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml))
@if [ -z "$(UPSTREAMURL)" ]; then\
echo -n " $(TARGET_REPO) - branch '$(TARGET_BRANCH)': ";\
git ls-remote --exit-code --heads $(TARGET_REPO) $(TARGET_BRANCH) >/dev/null &&\
echo "OK" || (echo "NOT FOUND"; exit 1);\
else\
echo "Upstream URL set to: $(UPSTREAMURL)";\
echo -n " $(UPSTREAMURL) - branch '$(TARGET_BRANCH)': ";\
git ls-remote --exit-code --heads $(UPSTREAMURL) $(TARGET_BRANCH) >/dev/null &&\
echo "OK" || (echo "NOT FOUND"; exit 1);\
fi

.PHONY: validate-cluster
validate-cluster: ## Do some cluster validations before installing
Expand Down
26 changes: 26 additions & 0 deletions common/scripts/deploy-pattern.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -o pipefail

RUNS=5
# Retry five times because the CRD might not be fully installed yet
echo -n "Installing pattern: "
for i in $(seq 1 ${RUNS}); do \
exec 3>&1 4>&2
OUT=$( { helm template --include-crds --name-template $* 2>&4 | oc apply -f- 2>&4 1>&3; } 4>&1 3>&1)
ret=$?
exec 3>&- 4>&-
if [ ${ret} -eq 0 ]; then
break;
else
echo -n "."
sleep 10
fi
done

# All the runs failed
if [ ${i} -eq ${RUNS} ]; then
echo "Installation failed [${i}/${RUNS}]. Error:"
echo "${OUT}"
exit 1
fi
echo "Done"

0 comments on commit 5bc0e00

Please sign in to comment.