Wait for patch propagation
@@ -8,6 +8,27 @@ test_dir=$(realpath $(dirname $0))
cluster='some-name'
+wait_for_sts_generation() {
+ local name="${1}"
+ local desired_generation="${2}"
+ local size="${3}"
+ set +o xtrace
+ retry=0
+ until [[ "$(kubectl_bin get sts $name -o jsonpath='{.status.observedGeneration}')" == "${desired_generation}" \
+ && "$(kubectl_bin get sts $name -o jsonpath='{.status.readyReplicas}')" == "${size}" ]]; do
+ sleep 1
+ echo -n .
+ let retry+=1
+ if [ $retry -ge 140 ]; then
+ kubectl_bin logs $(get_operator_pod)
+ echo max retry count $retry reached. something went wrong with operator or kubernetes cluster
+ exit 1
+ fi
+ echo
+ done
+ set -o xtrace
+}
+
main() {
create_namespace $namespace
deploy_operator
@@ -19,6 +40,8 @@ main() {
API="pxc.percona.com/v1"
apply_config "$conf_dir/$cluster.yml"
wait_for_running "$cluster-pxc" "1"
+ sleep 10
+ wait_for_running "$cluster-pxc" "1"
compare_kubectl service/$cluster-pxc "-100"
compare_kubectl service/$cluster-proxysql "-100"
@@ -30,7 +53,7 @@ main() {
kubectl_bin patch pxc "$cluster" --type=merge --patch '{
"metadata": {"annotations":{ "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"'"$API"'\"}" }}
}'
- wait_for_running "$cluster-pxc" "1"
+ wait_for_sts_generation "$cluster-pxc" "2" "1"
compare_kubectl service/$cluster-pxc "-110"
compare_kubectl service/$cluster-proxysql "-110"
@@ -42,7 +65,7 @@ main() {
kubectl_bin patch pxc "$cluster" --type=merge --patch '{
"metadata": {"annotations":{ "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"'"$API"'\"}" }}
}'
- wait_for_running "$cluster-pxc" "1"
+ wait_for_sts_generation "$cluster-pxc" "2" "1"
compare_kubectl service/$cluster-pxc "-120"
compare_kubectl service/$cluster-proxysql "-120"
@@ -54,7 +77,7 @@ main() {
kubectl_bin patch pxc "$cluster" --type=merge --patch '{
"metadata": {"annotations":{ "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"'"$API"'\"}" }}
}'
- wait_for_running "$cluster-pxc" "1"
+ wait_for_sts_generation "$cluster-pxc" "3" "1"
compare_kubectl service/$cluster-pxc "-130"
compare_kubectl service/$cluster-proxysql "-130"
@@ -66,7 +89,7 @@ main() {
kubectl_bin patch pxc "$cluster" --type=merge --patch '{
"metadata": {"annotations":{ "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"'"$API"'\"}" }}
}'
- wait_for_running "$cluster-pxc" "1"
+ wait_for_sts_generation "$cluster-pxc" "4" "1"
compare_kubectl service/$cluster-pxc "-140"
compare_kubectl service/$cluster-proxysql "-140"
