Skip to content

Commit 8846ec3

Browse files
authored
Merge pull request #345 from mbaldessari/argo-healthcheck
Introduce an argo-healthcheck make target
2 parents f1ba40e + dcb9a3e commit 8846ec3

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,30 @@ validate-prereq: ## verify pre-requisites
122122
@if ! ansible-galaxy collection list | grep kubernetes.core > /dev/null 2>&1; then echo "Not found"; exit 1; fi
123123
@echo "OK"
124124

125+
.PHONY: argo-healthcheck
126+
argo-healthcheck: ## Checks if all argo applications are synced
127+
@echo "Checking argo applications"
128+
$(eval APPS := $(shell oc get applications -A -o jsonpath='{range .items[*]}{@.metadata.namespace}{","}{@.metadata.name}{"\n"}{end}'))
129+
@NOTOK=0; \
130+
for i in $(APPS); do\
131+
n=`echo "$${i}" | cut -f1 -d,`;\
132+
a=`echo "$${i}" | cut -f2 -d,`;\
133+
STATUS=`oc get -n "$${n}" application/"$${a}" -o jsonpath='{.status.sync.status}'`;\
134+
if [[ $$STATUS != "Synced" ]]; then\
135+
NOTOK=$$(( $${NOTOK} + 1));\
136+
fi;\
137+
HEALTH=`oc get -n "$${n}" application/"$${a}" -o jsonpath='{.status.health.status}'`;\
138+
if [[ $$HEALTH != "Healthy" ]]; then\
139+
NOTOK=$$(( $${NOTOK} + 1));\
140+
fi;\
141+
echo "$${n} $${a} -> Sync: $${STATUS} - Health: $${HEALTH}";\
142+
done;\
143+
if [ $${NOTOK} -gt 0 ]; then\
144+
echo "Some applications are not synced or are unhealthy";\
145+
exit 1;\
146+
fi
147+
148+
125149
##@ Test and Linters Tasks
126150

127151
CHARTS=$(shell find . -type f -iname 'Chart.yaml' -exec dirname "{}" \; | grep -v examples | sed -e 's/.\///')

0 commit comments

Comments
 (0)