Skip to content

Commit 29f6f84

Browse files
authored
fix: fixed the retry logic in enable_disable_ocp_console.sh (#603)
1 parent d8d2ff5 commit 29f6f84

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ resource "null_resource" "confirm_network_healthy" {
460460
##############################################################################
461461
resource "null_resource" "ocp_console_management" {
462462

463-
depends_on = [ibm_container_vpc_cluster.cluster, ibm_container_vpc_cluster.autoscaling_cluster, ibm_container_vpc_worker_pool.pool, ibm_container_vpc_worker_pool.autoscaling_pool]
463+
depends_on = [null_resource.confirm_network_healthy]
464464
triggers = {
465465
enable_ocp_console = var.enable_ocp_console
466466
}

scripts/enable_disable_ocp_console.sh

+10-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ set -euo pipefail
66
PATCH_APPLY="oc patch consoles.operator.openshift.io cluster --patch '{\"spec\":{\"managementState\":\"Managed\"}}' --type=merge"
77
PATCH_REMOVE="oc patch consoles.operator.openshift.io cluster --patch '{\"spec\":{\"managementState\":\"Removed\"}}' --type=merge"
88
MAX_ATTEMPTS=10
9-
RETRY_WAIT=5
109

1110
function check_oc_cli() {
1211
if ! command -v oc &> /dev/null; then
@@ -18,17 +17,18 @@ function check_oc_cli() {
1817
function apply_oc_patch() {
1918

2019
local attempt=0
20+
local retry_wait_time=5
21+
2122
while [ $attempt -lt $MAX_ATTEMPTS ]; do
2223
echo "Attempt $((attempt+1)) of $MAX_ATTEMPTS: Applying OpenShift Console patch..."
2324

2425
if eval "$PATCH_APPLY"; then
2526
echo "Patch applied successfully."
2627
return 0
2728
else
28-
echo "Failed to apply patch. Retrying in ${RETRY_WAIT}s..."
29-
sleep $RETRY_WAIT
29+
echo "Failed to apply patch. Retrying in ${retry_wait_time}s..."
30+
sleep $retry_wait_time
3031
((attempt++))
31-
RETRY_WAIT=$((RETRY_WAIT * 2))
3232
fi
3333
done
3434

@@ -39,17 +39,18 @@ function apply_oc_patch() {
3939
function remove_oc_patch() {
4040

4141
local attempt=0
42+
local retry_wait_time=5
43+
4244
while [ $attempt -lt $MAX_ATTEMPTS ]; do
4345
echo "Attempt $((attempt+1)) of $MAX_ATTEMPTS: Removing OpenShift Console patch..."
4446

4547
if eval "$PATCH_REMOVE"; then
4648
echo "Patch removed successfully."
4749
return 0
4850
else
49-
echo "Failed to remove patch. Retrying in ${RETRY_WAIT}s..."
50-
sleep $RETRY_WAIT
51+
echo "Failed to remove patch. Retrying in ${retry_wait_time}s..."
52+
sleep $retry_wait_time
5153
((attempt++))
52-
RETRY_WAIT=$((RETRY_WAIT * 2))
5354
fi
5455
done
5556

@@ -59,8 +60,8 @@ function remove_oc_patch() {
5960

6061
echo "========================================="
6162

62-
if [[ -z "${ENABLE_OCP_CONSOLE}" ]]; then
63-
echo "ENABLE_OCP_CONSOLE must be set" >&2
63+
if [[ -z "${ENABLE_OCP_CONSOLE:-}" ]]; then
64+
echo "ENABLE_OCP_CONSOLE must be set ... exiting." >&2
6465
exit 1
6566
fi
6667

0 commit comments

Comments
 (0)