Skip to content

Commit df30d89

Browse files
authored
Merge pull request #151 from vwbusguy/bugfix/rancher-connection-info-fail
Cleanup and exit if cannot download valid connection info.
2 parents 806ef42 + a375cff commit df30d89

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

install.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,8 @@ retrieve_connection_info() {
763763
case "${RESPONSE}" in
764764
200)
765765
info "Successfully downloaded Rancher connection information"
766-
break
766+
umask "${UMASK}"
767+
return 0
767768
;;
768769
*)
769770
i=$((i + 1))
@@ -773,7 +774,11 @@ retrieve_connection_info() {
773774
;;
774775
esac
775776
done
777+
error "Failed to download Rancher connection information in ${i} attempts"
776778
umask "${UMASK}"
779+
# Clean up invalid rancher2_connection_info.json file
780+
rm -f ${CATTLE_AGENT_VAR_DIR}/rancher2_connection_info.json
781+
return 1
777782
fi
778783
}
779784

@@ -882,7 +887,7 @@ do_install() {
882887

883888
if [ -n "${CATTLE_TOKEN}" ]; then
884889
generate_cattle_identifier
885-
retrieve_connection_info # Only retrieve connection information from Rancher if a token was passed in.
890+
retrieve_connection_info || fatal "Aborting system-agent installation due to failure to retrieve Rancher connection information"
886891
fi
887892
create_systemd_service_file
888893
create_env_file

0 commit comments

Comments
 (0)