diff --git a/README.md b/README.md
index 2354382..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
@@ -136,7 +135,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/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..0fbb565
--- /dev/null
+++ b/scripts/confirm-operator-installation.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+set -e
+
+echo "Waiting for install plan to be created"
+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
+ echo "Attempt $i: waiting for hco-operator deployment to become Available..."
+ 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)"
+ 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
+
+
+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 "✅ Proceeding to Custom Resource creation"
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"
- }
}
}