@@ -13,34 +13,49 @@ deploy_postgres() {
1313 if ! kubectl get crd clusters.postgresql.cnpg.io > /dev/null 2>&1 ; then
1414 echo " [INFO]: CloudNativePG operator not found, installing..."
1515
16- # Create namespace first to ensure it exists
17- kubectl create namespace cnpg-system --dry-run=client -o yaml | kubectl apply -f -
18-
19- # Use helm template + kubectl apply to completely avoid Helm client timeouts
20- # This is the most reliable method for slow/busy clusters (e2e, MicroShift)
21- echo " [INFO]: Rendering operator manifests from Helm chart..."
22- helm template cnpg-operator cloudnative-pg/cloudnative-pg \
16+ # Try installing with wait first
17+ if ! helm install cnpg-operator cloudnative-pg/cloudnative-pg \
2318 --values src/test/infrastructure/cloudnativepg/operator-values.yaml \
2419 --namespace cnpg-system \
25- --include-crds > /tmp/cnpg-operator-manifests.yaml
26-
27- echo " [INFO]: Applying operator manifests to cluster..."
28- # Apply with server-side apply to handle large CRD annotations
29- if ! kubectl apply --server-side=true -f /tmp/cnpg-operator-manifests.yaml 2>&1 | tee /tmp/cnpg-apply.log; then
30- # Check if it's just the poolers CRD annotation issue (non-fatal)
31- if grep -q " poolers.postgresql.cnpg.io.*Too long" /tmp/cnpg-apply.log && \
32- kubectl get deployment -n cnpg-system cnpg-operator-cloudnative-pg > /dev/null 2>&1 ; then
33- echo " [WARN]: Poolers CRD has annotation size issue, but operator deployment was created"
34- echo " [INFO]: Continuing with deployment..."
20+ --create-namespace \
21+ --wait --timeout=10m 2>&1 ; then
22+
23+ echo " [WARN]: Initial installation failed, checking if resources were created..."
24+ kubectl get pods -n cnpg-system || true
25+
26+ # If resources exist, the install might have partially succeeded
27+ if kubectl get deployment -n cnpg-system cnpg-cloudnative-pg > /dev/null 2>&1 ; then
28+ echo " [INFO]: Operator deployment exists, waiting for it to become ready..."
3529 else
36- echo " [ERROR]: Failed to apply operator manifests"
37- echo " [DEBUG]: Checking what was created..."
38- kubectl get all -n cnpg-system || true
39- exit 1
30+ # Try again without --wait flag for microshift compatibility
31+ echo " [INFO]: Retrying installation without wait flag (microshift compatibility)..."
32+ helm uninstall cnpg-operator -n cnpg-system 2> /dev/null || true
33+ sleep 5
34+
35+ # First check what would be installed
36+ echo " [DEBUG]: Checking Helm template output..."
37+ helm template cnpg-operator cloudnative-pg/cloudnative-pg \
38+ --values src/test/infrastructure/cloudnativepg/operator-values.yaml \
39+ --namespace cnpg-system | grep -A 5 " kind: Deployment" || echo " No Deployment found in template"
40+
41+ if ! helm install cnpg-operator cloudnative-pg/cloudnative-pg \
42+ --values src/test/infrastructure/cloudnativepg/operator-values.yaml \
43+ --namespace cnpg-system \
44+ --create-namespace \
45+ --timeout=10m; then
46+ echo " [ERROR]: Failed to install CloudNativePG operator even without wait flag"
47+ echo " [DEBUG]: Helm list..."
48+ helm list -n cnpg-system
49+ echo " [DEBUG]: Checking all resources in cnpg-system namespace..."
50+ kubectl get all -n cnpg-system || true
51+ echo " [DEBUG]: Checking operator deployment..."
52+ kubectl describe deployment -n cnpg-system || true
53+ echo " [DEBUG]: Getting Helm manifest..."
54+ helm get manifest cnpg-operator -n cnpg-system || true
55+ exit 1
56+ fi
4057 fi
4158 fi
42-
43- echo " [INFO]: Operator manifests applied successfully"
4459 else
4560 echo " [INFO]: CloudNativePG operator already installed, skipping..."
4661 fi
@@ -198,9 +213,9 @@ create_secrets() {
198213 # Only create it if it doesn't exist
199214 if ! kubectl get secret ${DC_APP} -db-credentials -n atlassian > /dev/null 2>&1 ; then
200215 kubectl create secret generic ${DC_APP} -db-credentials \
201- --from-literal=username=" ${DC_APP} " \
202- --from-literal=password=" ${DC_APP} pwd" \
203- -n atlassian
216+ --from-literal=username=" ${DC_APP} " \
217+ --from-literal=password=" ${DC_APP} pwd" \
218+ -n atlassian
204219 fi
205220 kubectl create secret generic ${DC_APP} -admin \
206221 --from-literal=username=" admin" \
0 commit comments