Skip to content

Commit e3e0852

Browse files
authored
Merge pull request #3417 from jackfrancis/cherry-pick-3411-release-1.7
[release-1.7] return 1 in ci-entrypoint funcs when necessary
2 parents 52f03fb + 2131a97 commit e3e0852

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

scripts/ci-entrypoint.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ create_cluster() {
144144
# and any statement must be idempotent so that subsequent retry attempts can make forward progress.
145145
get_cidrs() {
146146
# Get cluster CIDRs from Cluster object
147-
CIDR0=$(${KUBECTL} get cluster "${CLUSTER_NAME}" -o=jsonpath='{.spec.clusterNetwork.pods.cidrBlocks[0]}')
147+
CIDR0=$(${KUBECTL} get cluster "${CLUSTER_NAME}" -o=jsonpath='{.spec.clusterNetwork.pods.cidrBlocks[0]}') || return 1
148148
export CIDR0
149-
CIDR_LENGTH=$(${KUBECTL} get cluster "${CLUSTER_NAME}" -o=jsonpath='{.spec.clusterNetwork.pods.cidrBlocks}' | jq '. | length')
149+
CIDR_LENGTH=$(${KUBECTL} get cluster "${CLUSTER_NAME}" -o=jsonpath='{.spec.clusterNetwork.pods.cidrBlocks}' | jq '. | length') || return 1
150150
if [[ "${CIDR_LENGTH}" == "2" ]]; then
151-
CIDR1=$(${KUBECTL} get cluster "${CLUSTER_NAME}" -o=jsonpath='{.spec.clusterNetwork.pods.cidrBlocks[1]}')
151+
CIDR1=$(${KUBECTL} get cluster "${CLUSTER_NAME}" -o=jsonpath='{.spec.clusterNetwork.pods.cidrBlocks[1]}') || return 1
152152
export CIDR1
153153
fi
154154
}
@@ -161,10 +161,12 @@ install_calico() {
161161
# Copy the kubeadm configmap to the calico-system namespace.
162162
# This is a workaround needed for the calico-node-windows daemonset
163163
# to be able to run in the calico-system namespace.
164-
"${KUBECTL}" create namespace calico-system --dry-run=client -o yaml | kubectl apply -f -
164+
# First, validate that the kubeadm-config configmap has been created.
165+
"${KUBECTL}" get configmap kubeadm-config --namespace=kube-system -o yaml || return 1
166+
"${KUBECTL}" create namespace calico-system --dry-run=client -o yaml | kubectl apply -f - || return 1
165167
if ! "${KUBECTL}" get configmap kubeadm-config --namespace=calico-system; then
166-
"${KUBECTL}" get configmap kubeadm-config --namespace=kube-system -o yaml > kubeadm-config-kube-system
167-
sed 's/namespace: kube-system/namespace: calico-system/' kubeadm-config-kube-system | "${KUBECTL}" apply -f -
168+
"${KUBECTL}" get configmap kubeadm-config --namespace=kube-system -o yaml > kubeadm-config-kube-system || return 1
169+
sed 's/namespace: kube-system/namespace: calico-system/' kubeadm-config-kube-system | "${KUBECTL}" apply -f - || return 1
168170
rm kubeadm-config-kube-system
169171
fi
170172
# install Calico CNI
@@ -197,7 +199,7 @@ install_cloud_provider_azure() {
197199
CLOUD_CONFIG=""
198200
CONFIG_SECRET_NAME="azure-cloud-provider"
199201
ENABLE_DYNAMIC_RELOADING=true
200-
copy_secret
202+
copy_secret || return 1
201203
fi
202204

203205
CCM_CLUSTER_CIDR="${CIDR0}"
@@ -221,7 +223,7 @@ install_cloud_provider_azure() {
221223
--set cloudControllerManager.cloudConfig="${CLOUD_CONFIG}" \
222224
--set cloudControllerManager.cloudConfigSecretName="${CONFIG_SECRET_NAME}" \
223225
--set cloudControllerManager.logVerbosity="${CCM_LOG_VERBOSITY}" \
224-
--set-string cloudControllerManager.clusterCIDR="${CCM_CLUSTER_CIDR}"
226+
--set-string cloudControllerManager.clusterCIDR="${CCM_CLUSTER_CIDR}" || return 1
225227
}
226228

227229
# wait_for_nodes returns when all nodes in the workload cluster are Ready.
@@ -286,11 +288,11 @@ install_addons() {
286288

287289
copy_secret() {
288290
# point at the management cluster
289-
"${KUBECTL}" --kubeconfig "${REPO_ROOT}/${KIND_CLUSTER_NAME}.kubeconfig" get secret "${CLUSTER_NAME}-control-plane-azure-json" -o jsonpath='{.data.control-plane-azure\.json}' | base64 --decode >azure_json
291+
"${KUBECTL}" --kubeconfig "${REPO_ROOT}/${KIND_CLUSTER_NAME}.kubeconfig" get secret "${CLUSTER_NAME}-control-plane-azure-json" -o jsonpath='{.data.control-plane-azure\.json}' | base64 --decode >azure_json || return 1
290292

291293
# create the secret on the workload cluster
292294
"${KUBECTL}" create secret generic "${CONFIG_SECRET_NAME}" -n kube-system \
293-
--from-file=cloud-config=azure_json
295+
--from-file=cloud-config=azure_json || return 1
294296
rm azure_json
295297
}
296298

0 commit comments

Comments
 (0)