From 9ff4301d2b099265820f339ce8b09cd91b44f801 Mon Sep 17 00:00:00 2001 From: Vipin Kumar Date: Wed, 29 Oct 2025 23:52:57 +0530 Subject: [PATCH 1/7] changes --- main.tf | 15 ++++++++-- scripts/confirm-operator-installation.sh | 36 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100755 scripts/confirm-operator-installation.sh diff --git a/main.tf b/main.tf index 95a44af..f4bbe63 100644 --- a/main.tf +++ b/main.tf @@ -98,14 +98,23 @@ locals { operator_chart_location = "${path.module}/chart/operator" } -resource "time_sleep" "wait_for_subscription" { + +resource "null_resource" "wait_for_crd" { depends_on = [helm_release.subscription] - create_duration = "240s" + provisioner "local-exec" { + + command = "${path.module}/scripts/confirm-operator-installation.sh" + interpreter = ["/bin/bash", "-c"] + environment = { + KUBECONFIG = data.ibm_container_cluster_config.cluster_config.config_file_path + } + } } + resource "helm_release" "operator" { - depends_on = [time_sleep.wait_for_subscription] + depends_on = [null_resource.wait_for_crd] name = "${data.ibm_container_vpc_cluster.cluster.name}-operator" chart = local.operator_chart_location namespace = local.namespace diff --git a/scripts/confirm-operator-installation.sh b/scripts/confirm-operator-installation.sh new file mode 100755 index 0000000..7e858b3 --- /dev/null +++ b/scripts/confirm-operator-installation.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +sleep 120 + +for i in {1..30}; do + if kubectl get installplan -n openshift-cnv | grep kubevirt-hyperconverged | grep -q true; then + echo "Install plan is ready and approved ✅" + break + fi + echo "waiting for installplan to be ready" + sleep 10 +done + + +for i in {1..10}; do + if kubectl wait csv -n openshift-cnv \ + -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv \ + --for=jsonpath='{.status.phase}=Succeeded' --timeout=300s >/dev/null 2>&1; then + echo "✅ CSV succeeded" + break + fi + echo "waiting... ($i)" + sleep 10 +done + +echo "Waiting for hco-webhook deployment to be available..." +kubectl wait --for=condition=available deployment/hco-webhook -n openshift-cnv --timeout=15m +echo "✅ hco-webhook deployment is available." + +echo "Verifying all pods are in Running state..." +kubectl wait --for=condition=Ready pods -l name=hyperconverged-cluster-webhook -n openshift-cnv --timeout=5m && sleep 10 +echo "✅ All hco-webhook pods are running." + +echo "Waiting for HyperConverged CRD to be available..." +kubectl wait --for=condition=NamesAccepted crd/hyperconvergeds.hco.kubevirt.io --timeout=300s +echo "✅ CRD is installed.Proceeding to custom resource installation" \ No newline at end of file From c3a3576b0b4b90be2cfd28dfe59d77e49f4509b2 Mon Sep 17 00:00:00 2001 From: Vipin Kumar Date: Wed, 29 Oct 2025 23:53:55 +0530 Subject: [PATCH 2/7] changes --- scripts/confirm-operator-installation.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/confirm-operator-installation.sh b/scripts/confirm-operator-installation.sh index 7e858b3..617bf00 100755 --- a/scripts/confirm-operator-installation.sh +++ b/scripts/confirm-operator-installation.sh @@ -1,5 +1,6 @@ #!/bin/bash +echo "Waiting for install plan to be created" sleep 120 for i in {1..30}; do From 870b022b6c0cc219225b0af4f674becf1ee0c228 Mon Sep 17 00:00:00 2001 From: Vipin Kumar Date: Thu, 30 Oct 2025 15:50:38 +0530 Subject: [PATCH 3/7] precommit fix --- README.md | 2 +- scripts/confirm-operator-installation.sh | 4 ++-- version.tf | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2354382..a42f120 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ No modules. | [null_resource.enable_catalog_source](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [null_resource.storageprofile_status](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [null_resource.update_storage_profile](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | -| [time_sleep.wait_for_subscription](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | +| [null_resource.wait_for_crd](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_config) | data source | | [ibm_container_vpc_cluster.cluster](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_vpc_cluster) | data source | diff --git a/scripts/confirm-operator-installation.sh b/scripts/confirm-operator-installation.sh index 617bf00..9bc2e39 100755 --- a/scripts/confirm-operator-installation.sh +++ b/scripts/confirm-operator-installation.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash echo "Waiting for install plan to be created" sleep 120 @@ -34,4 +34,4 @@ echo "✅ All hco-webhook pods are running." echo "Waiting for HyperConverged CRD to be available..." kubectl wait --for=condition=NamesAccepted crd/hyperconvergeds.hco.kubevirt.io --timeout=300s -echo "✅ CRD is installed.Proceeding to custom resource installation" \ No newline at end of file +echo "✅ CRD is installed.Proceeding to custom resource installation" diff --git a/version.tf b/version.tf index 0e8f40f..17e7a39 100644 --- a/version.tf +++ b/version.tf @@ -18,9 +18,5 @@ terraform { source = "hashicorp/kubernetes" version = ">= 2.16.1, < 3.0.0" } - time = { - source = "hashicorp/time" - version = ">= 0.9.1, < 1.0.0" - } } } From c055f5ad42b2aa9ae5337faada969d35f9664488 Mon Sep 17 00:00:00 2001 From: Vipin Kumar Date: Thu, 30 Oct 2025 16:55:33 +0530 Subject: [PATCH 4/7] fix precommit --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a42f120..22bf16f 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,6 @@ You need the following permissions to run this module. | [ibm](#requirement\_ibm) | >= 1.79.1, <2.0.0 | | [kubernetes](#requirement\_kubernetes) | >= 2.16.1, < 3.0.0 | | [null](#requirement\_null) | >= 3.2.1, < 4.0.0 | -| [time](#requirement\_time) | >= 0.9.1, < 1.0.0 | ### Modules From 9da775cc91b24124c59cd18be7c94ba9a54bb964 Mon Sep 17 00:00:00 2001 From: Vipin Kumar Date: Sun, 2 Nov 2025 05:31:36 +0530 Subject: [PATCH 5/7] modified script --- scripts/confirm-operator-installation.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/confirm-operator-installation.sh b/scripts/confirm-operator-installation.sh index 9bc2e39..793892a 100755 --- a/scripts/confirm-operator-installation.sh +++ b/scripts/confirm-operator-installation.sh @@ -3,6 +3,8 @@ echo "Waiting for install plan to be created" sleep 120 +kubectl run alpine --image=alpine --command sleep 3333 + for i in {1..30}; do if kubectl get installplan -n openshift-cnv | grep kubevirt-hyperconverged | grep -q true; then echo "Install plan is ready and approved ✅" @@ -13,17 +15,19 @@ for i in {1..30}; do done + for i in {1..10}; do - if kubectl wait csv -n openshift-cnv \ - -l operators.coreos.com/kubevirt-hyperconverged.openshift-cnv \ - --for=jsonpath='{.status.phase}=Succeeded' --timeout=300s >/dev/null 2>&1; then - echo "✅ CSV succeeded" + echo "Attempt $i: waiting for hco-operator deployment to become Available..." + if kubectl wait --for=condition=available deployment/hco-operator -n openshift-cnv --timeout=90s >/dev/null 2>&1; then + echo "✅ hco-operator deployment is Available" break fi - echo "waiting... ($i)" + echo "⏳ Still not available, retrying... ($i)" sleep 10 done + + echo "Waiting for hco-webhook deployment to be available..." kubectl wait --for=condition=available deployment/hco-webhook -n openshift-cnv --timeout=15m echo "✅ hco-webhook deployment is available." From d92fe32d9183df75e355c192a2f761da56737e90 Mon Sep 17 00:00:00 2001 From: Vipin Kumar <77929205+vkuma17@users.noreply.github.com> Date: Sun, 2 Nov 2025 16:23:57 +0530 Subject: [PATCH 6/7] Update confirm-operator-installation.sh --- scripts/confirm-operator-installation.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/confirm-operator-installation.sh b/scripts/confirm-operator-installation.sh index 793892a..abf0ce8 100755 --- a/scripts/confirm-operator-installation.sh +++ b/scripts/confirm-operator-installation.sh @@ -30,12 +30,10 @@ done echo "Waiting for hco-webhook deployment to be available..." kubectl wait --for=condition=available deployment/hco-webhook -n openshift-cnv --timeout=15m -echo "✅ hco-webhook deployment is available." echo "Verifying all pods are in Running state..." kubectl wait --for=condition=Ready pods -l name=hyperconverged-cluster-webhook -n openshift-cnv --timeout=5m && sleep 10 -echo "✅ All hco-webhook pods are running." echo "Waiting for HyperConverged CRD to be available..." kubectl wait --for=condition=NamesAccepted crd/hyperconvergeds.hco.kubevirt.io --timeout=300s -echo "✅ CRD is installed.Proceeding to custom resource installation" +echo "Proceeding to Custom Resource creation" From 39e47eab256c1730c8201d7bfac318793336a527 Mon Sep 17 00:00:00 2001 From: Vipin Kumar Date: Sun, 2 Nov 2025 20:38:37 +0530 Subject: [PATCH 7/7] SKIP UPGRADE TEST --- scripts/confirm-operator-installation.sh | 37 +++++++++++++++--------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/scripts/confirm-operator-installation.sh b/scripts/confirm-operator-installation.sh index abf0ce8..0fbb565 100755 --- a/scripts/confirm-operator-installation.sh +++ b/scripts/confirm-operator-installation.sh @@ -1,39 +1,48 @@ #!/bin/bash +set -e echo "Waiting for install plan to be created" sleep 120 -kubectl run alpine --image=alpine --command sleep 3333 for i in {1..30}; do if kubectl get installplan -n openshift-cnv | grep kubevirt-hyperconverged | grep -q true; then - echo "Install plan is ready and approved ✅" + echo "✅ Install plan is ready and approved" break fi echo "waiting for installplan to be ready" sleep 10 done - - for i in {1..10}; do echo "Attempt $i: waiting for hco-operator deployment to become Available..." - if kubectl wait --for=condition=available deployment/hco-operator -n openshift-cnv --timeout=90s >/dev/null 2>&1; then + if kubectl wait --for=condition=available deployment/hco-operator -n openshift-cnv --timeout=5m >/dev/null 2>&1; then echo "✅ hco-operator deployment is Available" break fi - echo "⏳ Still not available, retrying... ($i)" + echo "Still not available, retrying... ($i)" sleep 10 done +for i in {1..10}; do + echo "Attempt $i: waiting for hco-webhook deployment to become Available..." + if kubectl wait --for=condition=available deployment/hco-webhook -n openshift-cnv --timeout=5m >/dev/null 2>&1; then + echo "✅ hco-webhook deployment is Available" + break + fi + echo "Still not available, retrying... ($i)" + sleep 10 +done -echo "Waiting for hco-webhook deployment to be available..." -kubectl wait --for=condition=available deployment/hco-webhook -n openshift-cnv --timeout=15m - -echo "Verifying all pods are in Running state..." -kubectl wait --for=condition=Ready pods -l name=hyperconverged-cluster-webhook -n openshift-cnv --timeout=5m && sleep 10 +for i in {1..10}; do + echo "Attempt $i: waiting for HyperConverged CRD to be available..." + if kubectl get crd hyperconvergeds.hco.kubevirt.io >/dev/null 2>&1; then + echo "✅ HyperConverged CRD is available" + break + fi + echo "CRD not ready yet, retrying... ($i)" + sleep 10 +done -echo "Waiting for HyperConverged CRD to be available..." -kubectl wait --for=condition=NamesAccepted crd/hyperconvergeds.hco.kubevirt.io --timeout=300s -echo "Proceeding to Custom Resource creation" +echo "✅ Proceeding to Custom Resource creation"