From eaa52870bb3e05cd06543ff898075734d6aa6fb7 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Wed, 2 Feb 2022 13:10:28 +0530 Subject: [PATCH] use `--preemptable` appropriately when set to false Related to https://github.com/gitpod-io/gitpod-gke-guide/pull/7 Currently, As we seem to use the `{PREEMPTABLE}` env directly, It causes the following error when set to `false`: ``` ERROR: (gcloud.container.clusters.create) unrecognized arguments: false ``` This PR updates to use a separate variable, which is set `--preemptable` when `PREEMPTABLE` is set to true, **empty otherwise**. Thus, preventing `false` to mistakenly passed as an argument. This PR also updates the usage at `gcloud.container.node-pools.create` to not pass empty argument when the value is `false`. Signed-off-by: Tarun Pothulapati --- setup.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 74e1eaf..9b05032 100755 --- a/setup.sh +++ b/setup.sh @@ -61,10 +61,11 @@ function check_prerequisites() { export REGION fi + PREEMPTIBLE_NODES= if [ -n "${PREEMPTIBLE}" ] && [ "${PREEMPTIBLE}" == "true" ]; then - PREEMPTIBLE="--preemptible" - export PREEMPTIBLE + PREEMPTIBLE_NODES="--preemptible" fi + export PREEMPTIBLE_NODES NODES_LOCATIONS= if [ -n "${ZONES}" ]; then @@ -90,7 +91,7 @@ function create_node_pool() { --node-labels="${NODES_LABEL}" \ --max-pods-per-node=110 --min-nodes=1 --max-nodes=50 \ --region="${REGION}" \ - "${PREEMPTIBLE}" + ${PREEMPTIBLE_NODES} } function create_secrets() { @@ -362,7 +363,7 @@ function install() { --max-pods-per-node=110 --default-max-pods-per-node=110 \ --min-nodes=0 --max-nodes=1 \ --addons=HorizontalPodAutoscaling,NodeLocalDNS,NetworkPolicy \ - ${NODES_LOCATIONS} ${PREEMPTIBLE} + ${NODES_LOCATIONS} ${PREEMPTIBLE_NODES} # delete default node pool (is not possible to create a cluster without nodes) gcloud --quiet container node-pools delete default-pool --cluster="${CLUSTER_NAME}" --region="${REGION}"