From 3e1eca3a17dfa0496851b2b79fb59f57b38e9492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergen=20Yal=C3=A7=C4=B1n?= Date: Thu, 25 Apr 2024 15:13:41 +0300 Subject: [PATCH 1/3] Add a endpoint based sync point after scaling up the pods in import step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergen Yalçın --- internal/templates/02-import.yaml.tmpl | 38 ++++- internal/templates/renderer_test.go | 190 ++++++++++++++++++++++++- 2 files changed, 222 insertions(+), 6 deletions(-) diff --git a/internal/templates/02-import.yaml.tmpl b/internal/templates/02-import.yaml.tmpl index 615332a..8148fcb 100644 --- a/internal/templates/02-import.yaml.tmpl +++ b/internal/templates/02-import.yaml.tmpl @@ -8,7 +8,43 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get pods --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} wait pods --for=condition=Ready --timeout=60s +- script: | + #!/bin/bash + + function check_endpoints { + endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') + + for endpoint in $endpoints; do + port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') + if [[ -z "${port}" ]]; then + echo "$endpoint - No served ports" + return 1 + else + echo "$endpoint - Ports present" + fi + done + + if ${KUBECTL} get managed ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + while [[ $attempt -le $max_attempts ]]; do + if check_endpoints; then + exit 0 + else + printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 + fi + ((attempt++)) + sleep 5 + done + + exit 1 {{- range $resource := .Resources }} {{- if eq $resource.KindGroup "secret." -}} {{continue}} diff --git a/internal/templates/renderer_test.go b/internal/templates/renderer_test.go index d7e42fe..4aada50 100644 --- a/internal/templates/renderer_test.go +++ b/internal/templates/renderer_test.go @@ -116,7 +116,43 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get pods --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} wait pods --for=condition=Ready --timeout=60s +- script: | + #!/bin/bash + + function check_endpoints { + endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') + + for endpoint in $endpoints; do + port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') + if [[ -z "${port}" ]]; then + echo "$endpoint - No served ports" + return 1 + else + echo "$endpoint - Ports present" + fi + done + + if ${KUBECTL} get managed ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + while [[ $attempt -le $max_attempts ]]; do + if check_endpoints; then + exit 0 + else + printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 + fi + ((attempt++)) + sleep 5 + done + + exit 1 - command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' - script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite @@ -227,7 +263,43 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get pods --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} wait pods --for=condition=Ready --timeout=60s +- script: | + #!/bin/bash + + function check_endpoints { + endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') + + for endpoint in $endpoints; do + port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') + if [[ -z "${port}" ]]; then + echo "$endpoint - No served ports" + return 1 + else + echo "$endpoint - Ports present" + fi + done + + if ${KUBECTL} get managed ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + while [[ $attempt -le $max_attempts ]]; do + if check_endpoints; then + exit 0 + else + printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 + fi + ((attempt++)) + sleep 5 + done + + exit 1 - command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' - script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite @@ -341,7 +413,43 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get pods --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} wait pods --for=condition=Ready --timeout=60s +- script: | + #!/bin/bash + + function check_endpoints { + endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') + + for endpoint in $endpoints; do + port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') + if [[ -z "${port}" ]]; then + echo "$endpoint - No served ports" + return 1 + else + echo "$endpoint - Ports present" + fi + done + + if ${KUBECTL} get managed ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + while [[ $attempt -le $max_attempts ]]; do + if check_endpoints; then + exit 0 + else + printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 + fi + ((attempt++)) + sleep 5 + done + + exit 1 - command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' - script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite @@ -435,7 +543,43 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get pods --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} wait pods --for=condition=Ready --timeout=60s +- script: | + #!/bin/bash + + function check_endpoints { + endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') + + for endpoint in $endpoints; do + port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') + if [[ -z "${port}" ]]; then + echo "$endpoint - No served ports" + return 1 + else + echo "$endpoint - Ports present" + fi + done + + if ${KUBECTL} get managed ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + while [[ $attempt -le $max_attempts ]]; do + if check_endpoints; then + exit 0 + else + printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 + fi + ((attempt++)) + sleep 5 + done + + exit 1 - command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' - script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite @@ -529,7 +673,43 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get pods --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} wait pods --for=condition=Ready --timeout=60s +- script: | + #!/bin/bash + + function check_endpoints { + endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') + + for endpoint in $endpoints; do + port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') + if [[ -z "${port}" ]]; then + echo "$endpoint - No served ports" + return 1 + else + echo "$endpoint - Ports present" + fi + done + + if ${KUBECTL} get managed ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + while [[ $attempt -le $max_attempts ]]; do + if check_endpoints; then + exit 0 + else + printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 + fi + ((attempt++)) + sleep 5 + done + + exit 1 - command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' - script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite From 840f4e7c7d16967ffc101be216ba8a5165295ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergen=20Yal=C3=A7=C4=B1n?= Date: Mon, 6 May 2024 13:35:40 +0300 Subject: [PATCH 2/3] Add a loop for patch statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergen Yalçın --- internal/templates/02-import.yaml.tmpl | 54 ++++- internal/templates/renderer_test.go | 270 +++++++++++++++++++++---- 2 files changed, 276 insertions(+), 48 deletions(-) diff --git a/internal/templates/02-import.yaml.tmpl b/internal/templates/02-import.yaml.tmpl index 8148fcb..b8b1697 100644 --- a/internal/templates/02-import.yaml.tmpl +++ b/internal/templates/02-import.yaml.tmpl @@ -23,12 +23,6 @@ commands: echo "$endpoint - Ports present" fi done - - if ${KUBECTL} get managed ; then - return 0 - else - return 1 - fi } attempt=1 @@ -45,13 +39,57 @@ commands: done exit 1 +- script: | + #!/bin/bash + + function patch { + kindgroup=$1 + name=$2 + if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + # Array of resources + resources=( {{- range $resource := .Resources }} {{- if eq $resource.KindGroup "secret." -}} {{continue}} {{- end -}} {{- if not $resource.Namespace }} -- command: ${KUBECTL} --subresource=status patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=merge -p '{"status":{"conditions":[]}}' -- script: ${KUBECTL} annotate {{ $resource.KindGroup }}/{{ $resource.Name }} uptest-old-id=$(${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.status.atProvider.id}') --overwrite + "{{ $resource.KindGroup }}/{{ $resource.Name }}" {{- end }} {{- end }} + ) + + for resource in "${resources[@]}"; do + kindgroup=$(echo "$resource" | cut -d '/' -f 1) + name=$(echo "$resource" | cut -d '/' -f 2) + + attempt=1 + while [[ $attempt -le $max_attempts ]]; do + if patch "$kindgroup" "$name"; then + echo "Successfully patched $kindgroup/$name" + ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite + break + else + printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 + fi + ((attempt++)) + sleep 5 + done + + if [[ $attempt -gt $max_attempts ]]; then + echo "Failed to patch $kindgroup/$name after $max_attempts attempts" + exit 1 + fi + done + + echo "All resources patched successfully." + exit 0 - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite diff --git a/internal/templates/renderer_test.go b/internal/templates/renderer_test.go index 4aada50..1ec73cf 100644 --- a/internal/templates/renderer_test.go +++ b/internal/templates/renderer_test.go @@ -131,12 +131,6 @@ commands: echo "$endpoint - Ports present" fi done - - if ${KUBECTL} get managed ; then - return 0 - else - return 1 - fi } attempt=1 @@ -153,8 +147,52 @@ commands: done exit 1 -- command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' -- script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite +- script: | + #!/bin/bash + + function patch { + kindgroup=$1 + name=$2 + if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + # Array of resources + resources=( + "s3.aws.upbound.io/example-bucket" + ) + + for resource in "${resources[@]}"; do + kindgroup=$(echo "$resource" | cut -d '/' -f 1) + name=$(echo "$resource" | cut -d '/' -f 2) + + attempt=1 + while [[ $attempt -le $max_attempts ]]; do + if patch "$kindgroup" "$name"; then + echo "Successfully patched $kindgroup/$name" + ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite + break + else + printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 + fi + ((attempt++)) + sleep 5 + done + + if [[ $attempt -gt $max_attempts ]]; then + echo "Failed to patch $kindgroup/$name after $max_attempts attempts" + exit 1 + fi + done + + echo "All resources patched successfully." + exit 0 - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, @@ -278,12 +316,6 @@ commands: echo "$endpoint - Ports present" fi done - - if ${KUBECTL} get managed ; then - return 0 - else - return 1 - fi } attempt=1 @@ -300,8 +332,52 @@ commands: done exit 1 -- command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' -- script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite +- script: | + #!/bin/bash + + function patch { + kindgroup=$1 + name=$2 + if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + # Array of resources + resources=( + "s3.aws.upbound.io/example-bucket" + ) + + for resource in "${resources[@]}"; do + kindgroup=$(echo "$resource" | cut -d '/' -f 1) + name=$(echo "$resource" | cut -d '/' -f 2) + + attempt=1 + while [[ $attempt -le $max_attempts ]]; do + if patch "$kindgroup" "$name"; then + echo "Successfully patched $kindgroup/$name" + ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite + break + else + printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 + fi + ((attempt++)) + sleep 5 + done + + if [[ $attempt -gt $max_attempts ]]; then + echo "Failed to patch $kindgroup/$name after $max_attempts attempts" + exit 1 + fi + done + + echo "All resources patched successfully." + exit 0 - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, "03-assert.yaml": `# This assert file belongs to the resource delete step. @@ -428,12 +504,6 @@ commands: echo "$endpoint - Ports present" fi done - - if ${KUBECTL} get managed ; then - return 0 - else - return 1 - fi } attempt=1 @@ -450,8 +520,52 @@ commands: done exit 1 -- command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' -- script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite +- script: | + #!/bin/bash + + function patch { + kindgroup=$1 + name=$2 + if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + # Array of resources + resources=( + "s3.aws.upbound.io/example-bucket" + ) + + for resource in "${resources[@]}"; do + kindgroup=$(echo "$resource" | cut -d '/' -f 1) + name=$(echo "$resource" | cut -d '/' -f 2) + + attempt=1 + while [[ $attempt -le $max_attempts ]]; do + if patch "$kindgroup" "$name"; then + echo "Successfully patched $kindgroup/$name" + ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite + break + else + printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 + fi + ((attempt++)) + sleep 5 + done + + if [[ $attempt -gt $max_attempts ]]; then + echo "Failed to patch $kindgroup/$name after $max_attempts attempts" + exit 1 + fi + done + + echo "All resources patched successfully." + exit 0 - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, }, @@ -558,12 +672,6 @@ commands: echo "$endpoint - Ports present" fi done - - if ${KUBECTL} get managed ; then - return 0 - else - return 1 - fi } attempt=1 @@ -580,8 +688,52 @@ commands: done exit 1 -- command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' -- script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite +- script: | + #!/bin/bash + + function patch { + kindgroup=$1 + name=$2 + if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + # Array of resources + resources=( + "s3.aws.upbound.io/example-bucket" + ) + + for resource in "${resources[@]}"; do + kindgroup=$(echo "$resource" | cut -d '/' -f 1) + name=$(echo "$resource" | cut -d '/' -f 2) + + attempt=1 + while [[ $attempt -le $max_attempts ]]; do + if patch "$kindgroup" "$name"; then + echo "Successfully patched $kindgroup/$name" + ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite + break + else + printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 + fi + ((attempt++)) + sleep 5 + done + + if [[ $attempt -gt $max_attempts ]]; then + echo "Failed to patch $kindgroup/$name after $max_attempts attempts" + exit 1 + fi + done + + echo "All resources patched successfully." + exit 0 - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, }, @@ -688,12 +840,6 @@ commands: echo "$endpoint - Ports present" fi done - - if ${KUBECTL} get managed ; then - return 0 - else - return 1 - fi } attempt=1 @@ -710,8 +856,52 @@ commands: done exit 1 -- command: ${KUBECTL} --subresource=status patch s3.aws.upbound.io/example-bucket --type=merge -p '{"status":{"conditions":[]}}' -- script: ${KUBECTL} annotate s3.aws.upbound.io/example-bucket uptest-old-id=$(${KUBECTL} get s3.aws.upbound.io/example-bucket -o=jsonpath='{.status.atProvider.id}') --overwrite +- script: | + #!/bin/bash + + function patch { + kindgroup=$1 + name=$2 + if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then + return 0 + else + return 1 + fi + } + + attempt=1 + max_attempts=10 + + # Array of resources + resources=( + "s3.aws.upbound.io/example-bucket" + ) + + for resource in "${resources[@]}"; do + kindgroup=$(echo "$resource" | cut -d '/' -f 1) + name=$(echo "$resource" | cut -d '/' -f 2) + + attempt=1 + while [[ $attempt -le $max_attempts ]]; do + if patch "$kindgroup" "$name"; then + echo "Successfully patched $kindgroup/$name" + ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite + break + else + printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 + fi + ((attempt++)) + sleep 5 + done + + if [[ $attempt -gt $max_attempts ]]; then + echo "Failed to patch $kindgroup/$name after $max_attempts attempts" + exit 1 + fi + done + + echo "All resources patched successfully." + exit 0 - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, }, From 701c15b0132c161564c1d8b414fea6d77a7ab0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergen=20Yal=C3=A7=C4=B1n?= Date: Tue, 7 May 2024 21:04:11 +0300 Subject: [PATCH 3/3] Add scripts for import step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergen Yalçın --- hack/check_endpoints.sh | 27 ++ hack/patch.sh | 33 ++ internal/templates/02-import.yaml.tmpl | 81 +---- internal/templates/renderer_test.go | 405 ++----------------------- 4 files changed, 84 insertions(+), 462 deletions(-) create mode 100755 hack/check_endpoints.sh create mode 100755 hack/patch.sh diff --git a/hack/check_endpoints.sh b/hack/check_endpoints.sh new file mode 100755 index 0000000..75f5bde --- /dev/null +++ b/hack/check_endpoints.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +function check_endpoints { + endpoints=( $("${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" get endpoints --no-headers | grep '^provider-' | awk '{print $1}') ) + for endpoint in ${endpoints[@]}; do + port=$(${KUBECTL} -n "${CROSSPLANE_NAMESPACE}" get endpoints "$endpoint" -o jsonpath='{.subsets[*].ports[0].port}') + if [[ -z "${port}" ]]; then + echo "$endpoint - No served ports" + return 1 + else + echo "$endpoint - Ports present" + fi + done +} + +attempt=1 +max_attempts=10 +while [[ $attempt -le $max_attempts ]]; do + if check_endpoints; then + exit 0 + else + printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 + fi + ((attempt++)) + sleep 5 +done +exit 1 diff --git a/hack/patch.sh b/hack/patch.sh new file mode 100755 index 0000000..6fbc04e --- /dev/null +++ b/hack/patch.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +function patch { + kindgroup=$1; + name=$2; + if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then + return 0; + else + return 1; + fi; +}; + + +kindgroup=$1; +name=$2; +attempt=1; +max_attempts=10; +while [[ $attempt -le $max_attempts ]]; do + if patch "$kindgroup" "$name"; then + echo "Successfully patched $kindgroup/$name"; + ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite; + break; + else + printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2; + fi; + ((attempt++)); + sleep 5; +done; +if [[ $attempt -gt $max_attempts ]]; then + echo "Failed to patch $kindgroup/$name after $max_attempts attempts"; + exit 1; +fi; +exit 0; diff --git a/internal/templates/02-import.yaml.tmpl b/internal/templates/02-import.yaml.tmpl index b8b1697..1fd4392 100644 --- a/internal/templates/02-import.yaml.tmpl +++ b/internal/templates/02-import.yaml.tmpl @@ -8,88 +8,15 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: | - #!/bin/bash - - function check_endpoints { - endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') - - for endpoint in $endpoints; do - port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') - if [[ -z "${port}" ]]; then - echo "$endpoint - No served ports" - return 1 - else - echo "$endpoint - Ports present" - fi - done - } - - attempt=1 - max_attempts=10 - - while [[ $attempt -le $max_attempts ]]; do - if check_endpoints; then - exit 0 - else - printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 - fi - ((attempt++)) - sleep 5 - done - - exit 1 -- script: | - #!/bin/bash - - function patch { - kindgroup=$1 - name=$2 - if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then - return 0 - else - return 1 - fi - } - - attempt=1 - max_attempts=10 - - # Array of resources - resources=( +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/check_endpoints.sh -o /tmp/check_endpoints.sh && chmod +x /tmp/check_endpoints.sh +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/patch.sh -o /tmp/patch.sh && chmod +x /tmp/patch.sh +- script: /tmp/check_endpoints.sh {{- range $resource := .Resources }} {{- if eq $resource.KindGroup "secret." -}} {{continue}} {{- end -}} {{- if not $resource.Namespace }} - "{{ $resource.KindGroup }}/{{ $resource.Name }}" +- script: /tmp/patch.sh {{ $resource.KindGroup }} {{ $resource.Name }} {{- end }} {{- end }} - ) - - for resource in "${resources[@]}"; do - kindgroup=$(echo "$resource" | cut -d '/' -f 1) - name=$(echo "$resource" | cut -d '/' -f 2) - - attempt=1 - while [[ $attempt -le $max_attempts ]]; do - if patch "$kindgroup" "$name"; then - echo "Successfully patched $kindgroup/$name" - ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite - break - else - printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 - fi - ((attempt++)) - sleep 5 - done - - if [[ $attempt -gt $max_attempts ]]; then - echo "Failed to patch $kindgroup/$name after $max_attempts attempts" - exit 1 - fi - done - - echo "All resources patched successfully." - exit 0 - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite diff --git a/internal/templates/renderer_test.go b/internal/templates/renderer_test.go index 1ec73cf..5104883 100644 --- a/internal/templates/renderer_test.go +++ b/internal/templates/renderer_test.go @@ -116,83 +116,10 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: | - #!/bin/bash - - function check_endpoints { - endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') - - for endpoint in $endpoints; do - port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') - if [[ -z "${port}" ]]; then - echo "$endpoint - No served ports" - return 1 - else - echo "$endpoint - Ports present" - fi - done - } - - attempt=1 - max_attempts=10 - - while [[ $attempt -le $max_attempts ]]; do - if check_endpoints; then - exit 0 - else - printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 - fi - ((attempt++)) - sleep 5 - done - - exit 1 -- script: | - #!/bin/bash - - function patch { - kindgroup=$1 - name=$2 - if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then - return 0 - else - return 1 - fi - } - - attempt=1 - max_attempts=10 - - # Array of resources - resources=( - "s3.aws.upbound.io/example-bucket" - ) - - for resource in "${resources[@]}"; do - kindgroup=$(echo "$resource" | cut -d '/' -f 1) - name=$(echo "$resource" | cut -d '/' -f 2) - - attempt=1 - while [[ $attempt -le $max_attempts ]]; do - if patch "$kindgroup" "$name"; then - echo "Successfully patched $kindgroup/$name" - ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite - break - else - printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 - fi - ((attempt++)) - sleep 5 - done - - if [[ $attempt -gt $max_attempts ]]; then - echo "Failed to patch $kindgroup/$name after $max_attempts attempts" - exit 1 - fi - done - - echo "All resources patched successfully." - exit 0 +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/check_endpoints.sh -o /tmp/check_endpoints.sh && chmod +x /tmp/check_endpoints.sh +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/patch.sh -o /tmp/patch.sh && chmod +x /tmp/patch.sh +- script: /tmp/check_endpoints.sh +- script: /tmp/patch.sh s3.aws.upbound.io example-bucket - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, @@ -301,83 +228,10 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: | - #!/bin/bash - - function check_endpoints { - endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') - - for endpoint in $endpoints; do - port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') - if [[ -z "${port}" ]]; then - echo "$endpoint - No served ports" - return 1 - else - echo "$endpoint - Ports present" - fi - done - } - - attempt=1 - max_attempts=10 - - while [[ $attempt -le $max_attempts ]]; do - if check_endpoints; then - exit 0 - else - printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 - fi - ((attempt++)) - sleep 5 - done - - exit 1 -- script: | - #!/bin/bash - - function patch { - kindgroup=$1 - name=$2 - if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then - return 0 - else - return 1 - fi - } - - attempt=1 - max_attempts=10 - - # Array of resources - resources=( - "s3.aws.upbound.io/example-bucket" - ) - - for resource in "${resources[@]}"; do - kindgroup=$(echo "$resource" | cut -d '/' -f 1) - name=$(echo "$resource" | cut -d '/' -f 2) - - attempt=1 - while [[ $attempt -le $max_attempts ]]; do - if patch "$kindgroup" "$name"; then - echo "Successfully patched $kindgroup/$name" - ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite - break - else - printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 - fi - ((attempt++)) - sleep 5 - done - - if [[ $attempt -gt $max_attempts ]]; then - echo "Failed to patch $kindgroup/$name after $max_attempts attempts" - exit 1 - fi - done - - echo "All resources patched successfully." - exit 0 +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/check_endpoints.sh -o /tmp/check_endpoints.sh && chmod +x /tmp/check_endpoints.sh +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/patch.sh -o /tmp/patch.sh && chmod +x /tmp/patch.sh +- script: /tmp/check_endpoints.sh +- script: /tmp/patch.sh s3.aws.upbound.io example-bucket - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, "03-assert.yaml": `# This assert file belongs to the resource delete step. @@ -489,83 +343,10 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: | - #!/bin/bash - - function check_endpoints { - endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') - - for endpoint in $endpoints; do - port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') - if [[ -z "${port}" ]]; then - echo "$endpoint - No served ports" - return 1 - else - echo "$endpoint - Ports present" - fi - done - } - - attempt=1 - max_attempts=10 - - while [[ $attempt -le $max_attempts ]]; do - if check_endpoints; then - exit 0 - else - printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 - fi - ((attempt++)) - sleep 5 - done - - exit 1 -- script: | - #!/bin/bash - - function patch { - kindgroup=$1 - name=$2 - if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then - return 0 - else - return 1 - fi - } - - attempt=1 - max_attempts=10 - - # Array of resources - resources=( - "s3.aws.upbound.io/example-bucket" - ) - - for resource in "${resources[@]}"; do - kindgroup=$(echo "$resource" | cut -d '/' -f 1) - name=$(echo "$resource" | cut -d '/' -f 2) - - attempt=1 - while [[ $attempt -le $max_attempts ]]; do - if patch "$kindgroup" "$name"; then - echo "Successfully patched $kindgroup/$name" - ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite - break - else - printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 - fi - ((attempt++)) - sleep 5 - done - - if [[ $attempt -gt $max_attempts ]]; then - echo "Failed to patch $kindgroup/$name after $max_attempts attempts" - exit 1 - fi - done - - echo "All resources patched successfully." - exit 0 +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/check_endpoints.sh -o /tmp/check_endpoints.sh && chmod +x /tmp/check_endpoints.sh +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/patch.sh -o /tmp/patch.sh && chmod +x /tmp/patch.sh +- script: /tmp/check_endpoints.sh +- script: /tmp/patch.sh s3.aws.upbound.io example-bucket - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, }, @@ -657,83 +438,10 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: | - #!/bin/bash - - function check_endpoints { - endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') - - for endpoint in $endpoints; do - port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') - if [[ -z "${port}" ]]; then - echo "$endpoint - No served ports" - return 1 - else - echo "$endpoint - Ports present" - fi - done - } - - attempt=1 - max_attempts=10 - - while [[ $attempt -le $max_attempts ]]; do - if check_endpoints; then - exit 0 - else - printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 - fi - ((attempt++)) - sleep 5 - done - - exit 1 -- script: | - #!/bin/bash - - function patch { - kindgroup=$1 - name=$2 - if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then - return 0 - else - return 1 - fi - } - - attempt=1 - max_attempts=10 - - # Array of resources - resources=( - "s3.aws.upbound.io/example-bucket" - ) - - for resource in "${resources[@]}"; do - kindgroup=$(echo "$resource" | cut -d '/' -f 1) - name=$(echo "$resource" | cut -d '/' -f 2) - - attempt=1 - while [[ $attempt -le $max_attempts ]]; do - if patch "$kindgroup" "$name"; then - echo "Successfully patched $kindgroup/$name" - ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite - break - else - printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 - fi - ((attempt++)) - sleep 5 - done - - if [[ $attempt -gt $max_attempts ]]; then - echo "Failed to patch $kindgroup/$name after $max_attempts attempts" - exit 1 - fi - done - - echo "All resources patched successfully." - exit 0 +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/check_endpoints.sh -o /tmp/check_endpoints.sh && chmod +x /tmp/check_endpoints.sh +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/patch.sh -o /tmp/patch.sh && chmod +x /tmp/patch.sh +- script: /tmp/check_endpoints.sh +- script: /tmp/patch.sh s3.aws.upbound.io example-bucket - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, }, @@ -825,83 +533,10 @@ commands: - command: sleep 10 - command: ${KUBECTL} scale deployment crossplane -n ${CROSSPLANE_NAMESPACE} --replicas=1 --timeout 10s - script: ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n ${CROSSPLANE_NAMESPACE} scale deploy --replicas=1 -- script: | - #!/bin/bash - - function check_endpoints { - endpoints=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints --no-headers | grep '^provider-' | awk '{print $1}') - - for endpoint in $endpoints; do - port=$(${KUBECTL} -n ${CROSSPLANE_NAMESPACE} get endpoints $endpoint -o jsonpath='{.subsets[*].ports[0].port}') - if [[ -z "${port}" ]]; then - echo "$endpoint - No served ports" - return 1 - else - echo "$endpoint - Ports present" - fi - done - } - - attempt=1 - max_attempts=10 - - while [[ $attempt -le $max_attempts ]]; do - if check_endpoints; then - exit 0 - else - printf "Retrying... (%d/%d)\n" "$attempt" "$max_attempts" >&2 - fi - ((attempt++)) - sleep 5 - done - - exit 1 -- script: | - #!/bin/bash - - function patch { - kindgroup=$1 - name=$2 - if ${KUBECTL} --subresource=status patch "$kindgroup/$name" --type=merge -p '{"status":{"conditions":[]}}' ; then - return 0 - else - return 1 - fi - } - - attempt=1 - max_attempts=10 - - # Array of resources - resources=( - "s3.aws.upbound.io/example-bucket" - ) - - for resource in "${resources[@]}"; do - kindgroup=$(echo "$resource" | cut -d '/' -f 1) - name=$(echo "$resource" | cut -d '/' -f 2) - - attempt=1 - while [[ $attempt -le $max_attempts ]]; do - if patch "$kindgroup" "$name"; then - echo "Successfully patched $kindgroup/$name" - ${KUBECTL} annotate "$kindgroup/$name" uptest-old-id=$(${KUBECTL} get "$kindgroup/$name" -o=jsonpath='{.status.atProvider.id}') --overwrite - break - else - printf "Retrying... (%d/%d) for %s/%s\n" "$attempt" "$max_attempts" "$kindgroup" "$name" >&2 - fi - ((attempt++)) - sleep 5 - done - - if [[ $attempt -gt $max_attempts ]]; then - echo "Failed to patch $kindgroup/$name after $max_attempts attempts" - exit 1 - fi - done - - echo "All resources patched successfully." - exit 0 +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/check_endpoints.sh -o /tmp/check_endpoints.sh && chmod +x /tmp/check_endpoints.sh +- script: curl -sL https://raw.githubusercontent.com/crossplane/uptest/main/hack/patch.sh -o /tmp/patch.sh && chmod +x /tmp/patch.sh +- script: /tmp/check_endpoints.sh +- script: /tmp/patch.sh s3.aws.upbound.io example-bucket - command: ${KUBECTL} annotate managed --all crossplane.io/paused=false --overwrite `, },