Skip to content

Commit 012e2a1

Browse files
committed
Merge branch 'okeconv42' into 'release/4.2'
update Create OKE script to add retry in case of connection to Kubernetes server error See merge request weblogic-cloud/weblogic-kubernetes-operator!4760
2 parents 03db091 + 9f6e170 commit 012e2a1

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

Jenkinsfile.oke

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ EOF
425425
mkdir -p ${WORKSPACE}/terraform/terraforminstall
426426
sh ${WORKSPACE}/terraform/oke.create.sh ${OCI_PROP_FILE} ${WORKSPACE}/terraform
427427

428-
clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == '\"${CLUSTER_NAME}\"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
428+
clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == "'"${CLUSTER_NAME}"'" and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
429429

430430
echo "clusterIp : $clusterIP"
431431
clusterPublicIP=${clusterIP:1:-6}
@@ -468,8 +468,7 @@ EOF
468468
echo "getting MountTarget ID"
469469
mount_target_id=${MOUNT_TARGET_OCID}
470470

471-
clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == '\"${CLUSTER_NAME}\"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
472-
471+
clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == "'"${CLUSTER_NAME}"'" and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
473472
echo "clusterIp : $clusterIP"
474473
clusterPublicIP=${clusterIP:1:-6}
475474
echo " clusterPublicIP : ${clusterPublicIP}"
@@ -530,7 +529,7 @@ EOF
530529
touch ${WORKSPACE}/.mvn/maven.config
531530
export KUBECONFIG=${kubeconfig_file}
532531

533-
clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == '\"${CLUSTER_NAME}\"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
532+
clusterIP=$(oci ce cluster list --compartment-id=${compartment_id} | jq '.data[] | select(."name" == "'"${CLUSTER_NAME}"'" and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
534533
echo "clusterIp : $clusterIP"
535534
clusterPublicIP=${clusterIP:1:-6}
536535
echo " clusterPublicIP : ${clusterPublicIP}"

integration-tests/src/test/resources/oke/terraform/okemodule/oke.create.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,32 @@ createRoleBindings () {
8484
checkClusterRunning () {
8585

8686
echo "Confirm we have ${KUBERNETES_CLI:-kubectl} working..."
87-
myline=`${KUBERNETES_CLI:-kubectl} get nodes | awk '{print $2}'| tail -n+2`
88-
status="NotReady"
89-
max=50
90-
count=1
91-
92-
privateIP=${vcn_cidr_prefix//./\\.}\\.10\\.
9387
privateIP=${vcn_cidr_prefix}
88+
myline_output=$(${KUBERNETES_CLI:-kubectl} get nodes -o wide 2>&1)
89+
if echo "$myline_output" | grep -q "Unable to connect to the server: net/http: TLS handshake timeout"; then
90+
echo "[ERROR] Unable to connect to the server: net/http: TLS handshake timeout"
91+
92+
echo '- could not talk to OKE cluster, aborting'
93+
cd ${terraformVarDir}
94+
terraform destroy -auto-approve -var-file=${terraformVarDir}/${clusterTFVarsFile}.tfvars
95+
terraform apply -auto-approve -var-file=${terraformVarDir}/${clusterTFVarsFile}.tfvars
96+
echo "retrying to execute KUBERNETES_CLI"
97+
clusterIP=$(oci ce cluster list --compartment-id=${compartment_ocid} | jq '.data[] | select(."name" == '"${okeclustername}"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
98+
echo "clusterIp : $clusterIP"
99+
clusterPublicIP=${clusterIP:1:-6}
100+
echo " clusterPublicIP : ${clusterPublicIP}"
101+
echo "NO_PROXY before : ${NO_PROXY}"
102+
export NO_PROXY=${clusterPublicIP}
103+
echo "NO_PROXY:" $NO_PROXY
104+
myline_output=$(${KUBERNETES_CLI:-kubectl} get nodes -o wide 2>&1)
105+
if echo "$myline_output" | grep -q "Unable to connect to the server: net/http: TLS handshake timeout"; then
106+
echo "[ERROR] Unable to connect to the server: net/http: TLS handshake timeout"
107+
echo '- could not talk to OKE cluster, aborting'
108+
cd ${terraformVarDir}
109+
terraform destroy -auto-approve -var-file=${terraformVarDir}/${clusterTFVarsFile}.tfvars
110+
exit 1
111+
fi
112+
fi
94113
declare -a myline
95114
myline=(`${KUBERNETES_CLI:-kubectl} get nodes -o wide | grep "${privateIP}" | awk '{print $2}'`)
96115
NODE_IP=`${KUBERNETES_CLI:-kubectl} get nodes -o wide| grep "${privateIP}" | awk '{print $7}'`
@@ -116,7 +135,7 @@ checkClusterRunning () {
116135
if [ "$NODES" == "2" ]; then
117136
echo '- looks good'
118137
else
119-
echo '- could not talk to cluster, aborting'
138+
echo '- could not talk to OKE cluster, aborting'
120139
cd ${terraformVarDir}
121140
terraform destroy -auto-approve -var-file=${terraformVarDir}/${clusterTFVarsFile}.tfvars
122141
exit 1
@@ -183,15 +202,15 @@ export KUBECONFIG=${terraformVarDir}/${okeclustername}_kubeconfig
183202
export okeclustername=\"${okeclustername}\"
184203

185204

186-
echo " oci ce cluster list --compartment-id=${compartment_ocid} | jq '.data[] | select(."name" == '"${okeclustername}"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"'"
205+
echo " oci ce cluster list --compartment-id=${compartment_ocid} | jq '.data[] | select(."name" == '"${okeclustername}"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"'"
187206

188207
clusterIP=$(oci ce cluster list --compartment-id=${compartment_ocid} | jq '.data[] | select(."name" == '"${okeclustername}"' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"')
189208
echo "clusterIp : $clusterIP"
190209
clusterPublicIP=${clusterIP:1:-6}
191210
echo " clusterPublicIP : ${clusterPublicIP}"
192-
export NO_PROXY=$NO_PROXY,${clusterPublicIP}
211+
echo "NO_PROXY before : ${NO_PROXY}"
212+
export NO_PROXY=${clusterPublicIP}
193213
echo "NO_PROXY:" $NO_PROXY
194214

195-
196215
checkClusterRunning
197216
echo "$okeclustername is up and running}"

0 commit comments

Comments
 (0)