Skip to content

Commit 8661b0c

Browse files
committed
foo
1 parent 6d81e8b commit 8661b0c

File tree

1 file changed

+80
-7
lines changed

1 file changed

+80
-7
lines changed

charts/eoapi/templates/knative-init.yaml

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,80 @@ spec:
3232
set -e
3333
echo "=== Knative Initialization ==="
3434
35-
# Wait for knative-operator to be ready
36-
echo "Waiting for knative-operator..."
37-
kubectl rollout status deployment/knative-operator -n default --timeout={{ .Values.knative.initTimeout | default "600s" }}
35+
# Wait for knative-operator with exponential backoff
36+
echo "Waiting for knative-operator deployment to be available..."
37+
RELEASE_NAMESPACE="{{ .Release.Namespace }}"
38+
OPERATOR_NAMESPACE=""
39+
max_attempts=60
40+
attempt=1
41+
backoff=5
42+
43+
while [ $attempt -le $max_attempts ]; do
44+
echo "Attempt $attempt/$max_attempts: Looking for knative-operator..."
45+
46+
# First check the release namespace (most likely location for Helm dependency)
47+
if kubectl get deployment knative-operator -n "$RELEASE_NAMESPACE" >/dev/null 2>&1; then
48+
OPERATOR_NAMESPACE="$RELEASE_NAMESPACE"
49+
echo "✅ Found knative-operator in release namespace: $OPERATOR_NAMESPACE"
50+
break
51+
fi
52+
53+
# Fallback: check all namespaces
54+
OPERATOR_NAMESPACE=$(kubectl get deployment knative-operator --all-namespaces -o jsonpath='{.items[0].metadata.namespace}' 2>/dev/null || echo "")
55+
if [ -n "$OPERATOR_NAMESPACE" ]; then
56+
echo "✅ Found knative-operator in namespace: $OPERATOR_NAMESPACE"
57+
break
58+
fi
59+
60+
echo "⏳ knative-operator not found, waiting ${backoff}s before retry..."
61+
sleep $backoff
62+
attempt=$((attempt + 1))
63+
64+
# Exponential backoff with max of 30s
65+
if [ $backoff -lt 30 ]; then
66+
backoff=$((backoff * 2))
67+
fi
68+
done
69+
70+
if [ -z "$OPERATOR_NAMESPACE" ]; then
71+
echo "❌ knative-operator deployment not found after $max_attempts attempts"
72+
echo ""
73+
echo "=== Debugging Information ==="
74+
echo "Current namespace: $RELEASE_NAMESPACE"
75+
echo ""
76+
echo "Helm releases in current namespace:"
77+
helm list -n "$RELEASE_NAMESPACE" || echo "No helm releases found"
78+
echo ""
79+
echo "All deployments in current namespace:"
80+
kubectl get deployments -n "$RELEASE_NAMESPACE" -o wide || echo "No deployments found"
81+
echo ""
82+
echo "All deployments across all namespaces (first 20):"
83+
kubectl get deployments --all-namespaces | head -21
84+
echo ""
85+
echo "Knative-related resources:"
86+
kubectl get all --all-namespaces | grep -i knative || echo "No knative resources found"
87+
echo ""
88+
echo "Recent events in current namespace:"
89+
kubectl get events -n "$RELEASE_NAMESPACE" --sort-by='.lastTimestamp' | tail -10 || echo "No events found"
90+
echo ""
91+
echo "Pod status in current namespace:"
92+
kubectl get pods -n "$RELEASE_NAMESPACE" -o wide || echo "No pods found"
93+
exit 1
94+
fi
95+
96+
echo "Waiting for knative-operator deployment to be ready..."
97+
if ! kubectl rollout status deployment/knative-operator -n "$OPERATOR_NAMESPACE" --timeout=600s; then
98+
echo "❌ knative-operator failed to become ready within timeout"
99+
echo "Deployment status:"
100+
kubectl describe deployment knative-operator -n "$OPERATOR_NAMESPACE"
101+
echo "Pod status:"
102+
kubectl get pods -n "$OPERATOR_NAMESPACE" -l name=knative-operator -o wide
103+
echo "Recent events:"
104+
kubectl get events -n "$OPERATOR_NAMESPACE" --sort-by='.lastTimestamp' | tail -10
105+
exit 1
106+
fi
107+
108+
echo "✅ knative-operator is ready, proceeding with Knative setup..."
38109
39110
# Create namespaces
40111
kubectl create namespace knative-serving --dry-run=client -o yaml | kubectl apply -f -
@@ -55,7 +126,8 @@ spec:
55126
echo "✅ KnativeServing created successfully"
56127
else
57128
echo "❌ Failed to create KnativeServing. Checking operator status..."
58-
kubectl get pods -n default -l name=knative-operator
129+
kubectl get pods -n "$OPERATOR_NAMESPACE" -l name=knative-operator
130+
kubectl logs -n "$OPERATOR_NAMESPACE" -l name=knative-operator --tail=20
59131
exit 1
60132
fi
61133
@@ -74,7 +146,8 @@ spec:
74146
echo "✅ KnativeEventing created successfully"
75147
else
76148
echo "❌ Failed to create KnativeEventing. Checking operator status..."
77-
kubectl get pods -n default -l name=knative-operator
149+
kubectl get pods -n "$OPERATOR_NAMESPACE" -l name=knative-operator
150+
kubectl logs -n "$OPERATOR_NAMESPACE" -l name=knative-operator --tail=20
78151
exit 1
79152
fi
80153
@@ -87,6 +160,6 @@ spec:
87160
limits:
88161
cpu: 50m
89162
memory: 64Mi
90-
backoffLimit: 3
91-
activeDeadlineSeconds: 600
163+
backoffLimit: 1
164+
activeDeadlineSeconds: 1200
92165
{{- end }}

0 commit comments

Comments
 (0)