@@ -111,7 +111,7 @@ wait_until() {
111
111
local start_time=$( timestamp)
112
112
info " Waiting for $@ "
113
113
until timeout_from $start_time || eval " $@ " ; do
114
- info " ... still waiting"
114
+ info " ... still waiting for condition "
115
115
sleep 1
116
116
done
117
117
! timeout_from $start_time
@@ -267,42 +267,30 @@ get_amb_addr() {
267
267
fi
268
268
}
269
269
270
+ check_amb_has_addr () {
271
+ test -n " $( get_amb_addr $@ ) "
272
+ }
273
+
270
274
# wait_amb_addr <KUBECTL_ARGS...>
271
275
# wait untils Ambassador has an address
272
276
wait_amb_addr () {
273
- i=0
274
- timeout=$DEF_WAIT_TIMEOUT
275
- until [ -n " $( get_amb_addr $@ ) " ] || [ $i -ge $timeout ]; do
276
- info " waiting for Ambassador to have an IP ($i secs elapsed)"
277
- i=$(( i + 1 ))
278
- sleep 1
279
- done
280
-
281
- if [ $i -ge $timeout ]; then
277
+ wait_until check_amb_has_addr $@ || {
282
278
warn " Timeout waiting for Ambassador's IP. Current services:"
283
279
kubectl get services $@
284
- warn " Ambassador did not get an IP after $timeout seconds "
280
+ warn " Ambassador IP address: $( get_amb_addr $@ ) "
285
281
return 1
286
- fi
282
+ }
287
283
}
288
284
289
285
# wait_not_amb_addr <KUBECTL_ARGS...>
290
286
# wait untils Ambassador does not have an address
291
287
wait_not_amb_addr () {
292
- i=0
293
- timeout=$DEF_WAIT_TIMEOUT
294
- until [ -z " $( get_amb_addr $@ ) " ] || [ $i -ge $timeout ]; do
295
- info " waiting for Ambassador to have an IP ($i secs elapsed)"
296
- i=$(( i + 1 ))
297
- sleep 1
298
- done
299
-
300
- if [ $i -ge $timeout ]; then
301
- warn " Timeout waiting for Ambassador not not have an IP. Current services:"
288
+ wait_until " ! check_amb_has_addr $@ " || {
289
+ warn " Timeout waiting for Ambassador to NOT have an IP. Current services:"
302
290
kubectl get services $@
303
- warn " Ambassador had an IP after $timeout seconds "
291
+ warn " Ambassador IP address: $( get_amb_addr $@ ) "
304
292
return 1
305
- fi
293
+ }
306
294
}
307
295
308
296
# kubectl_apply_host
@@ -989,12 +977,15 @@ kube_check_resource_empty() {
989
977
# amb_inst_delete <KUBECTL_ARGS...>
990
978
# delete an `AmbassadorInstallation`
991
979
amb_inst_delete () {
992
- info " Removing the AmbassadorInstallation"
993
- kubectl delete $@ --wait=true --ignore-not-found=true --timeout=60s \
994
- ambassadorinstallations " ${AMB_INSTALLATION_NAME} " ||
995
- return 1
996
- wait_missing " $@ ambassadorinstallations ${AMB_INSTALLATION_NAME} " || return 1
997
- passed " ... AmbassadorInstallation removed."
980
+ lst=$( kubectl get $@ ambassadorinstallations --no-headers -o custom-columns=" :metadata.name" 2> /dev/null)
981
+ info " Removing all the AmbassadorInstallations: $lst "
982
+ for k in $lst ; do
983
+ kubectl delete $KUBECTL_DELETE_ARGS $@ ambassadorinstallations " $k " || return 1
984
+ wait_missing " $@ ambassadorinstallations $k " || return 1
985
+ passed " ... AmbassadorInstallation $k removed."
986
+ done
987
+ info " Current list of AmbassadorInstallations: " && kubectl get $@ ambassadorinstallations 2> /dev/null
988
+ return 0
998
989
}
999
990
1000
991
amb_inst_describe () {
@@ -1038,21 +1029,28 @@ oper_uninstall() {
1038
1029
1039
1030
amb_inst_delete -n " $namespace " || {
1040
1031
oper_logs_dump -n " $namespace "
1041
- abort " could not remove AmbassadorInstallation in namespace $namespace "
1032
+ abort " could not remove AmbassadorInstallations in namespace $namespace "
1042
1033
}
1043
- sleep 5
1044
1034
1045
- info " Removing the operator"
1035
+ info " Removing the operator... "
1046
1036
cat_setting_image " $TOP_DIR /deploy/operator.yaml" | kubectl delete $KUBECTL_DELETE_ARGS -n " $namespace " -f -
1047
- kubectl delete -n " $namespace " $KUBECTL_DELETE_ARGS -f " $TOP_DIR /deploy/role_binding.yaml"
1048
- kubectl delete -n " $namespace " $KUBECTL_DELETE_ARGS -f " $TOP_DIR /deploy/role.yaml"
1049
- kubectl delete -n " $namespace " $KUBECTL_DELETE_ARGS -f " $TOP_DIR /deploy/service_account.yaml"
1050
- kubectl delete -n " $namespace " $KUBECTL_DELETE_ARGS -f $CRDS
1037
+ for f in $CRDS " $TOP_DIR /deploy/role_binding.yaml" " $TOP_DIR /deploy/role.yaml" " $TOP_DIR /deploy/service_account.yaml" ; do
1038
+ info " ... removing $f "
1039
+ kubectl delete -n " $namespace " $KUBECTL_DELETE_ARGS -f $f || {
1040
+ oper_logs_dump -n " $namespace "
1041
+ abort " could not delete $f "
1042
+ }
1043
+ done
1051
1044
1045
+ # note: it is important have deleted all the AmbassadorInstallations at this point,
1046
+ # otherwise the removal of the namespace will fail
1052
1047
info " Removing namespace $namespace ..."
1053
- kubectl delete namespace $KUBECTL_DELETE_ARGS " $namespace " &&
1054
- wait_namespace_missing " $namespace " || abort " namespace $namespace still present"
1055
-
1048
+ kubectl delete namespace $KUBECTL_DELETE_ARGS " $namespace " || abort " could not delete namespace $namespace "
1049
+ wait_namespace_missing " $namespace " || {
1050
+ oper_logs_dump -n " $namespace "
1051
+ kubectl get all -n " $namespace "
1052
+ abort " namespace $namespace still present"
1053
+ }
1056
1054
passed " ... namespace $namespace removed."
1057
1055
}
1058
1056
@@ -1120,6 +1118,7 @@ oper_install_helm() {
1120
1118
}
1121
1119
1122
1120
oper_logs_dump () {
1121
+ kubectl logs $@ deployment/" $AMB_OPER_DEPLOY " --previous
1123
1122
kubectl logs $@ deployment/" $AMB_OPER_DEPLOY "
1124
1123
}
1125
1124
0 commit comments