Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from gitpod-io/tarun/preemptable-nodes-false
Browse files Browse the repository at this point in the history
use `--preemptable` appropriately when set to false

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`.
  • Loading branch information
Pothulapati authored Feb 14, 2022
2 parents 964cedf + eaa5287 commit 72c92b9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit 72c92b9

Please sign in to comment.