Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postgres pod status check for k8s tests in CI #1320

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cosmos/operators/airflow_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class DbtSourceAirflowAsyncOperator(DbtBaseAirflowAsyncOperator, DbtSourceLocalO
pass


# Test
pankajkoti marked this conversation as resolved.
Show resolved Hide resolved
class DbtRunAirflowAsyncOperator(BigQueryInsertJobOperator): # type: ignore

template_fields: Sequence[str] = (
Expand Down
21 changes: 21 additions & 0 deletions scripts/test/kubernetes-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ kind load docker-image dbt-jaffle-shop:1.0.0
# The output is filtered to get the first pod's name
POD_NAME=$(kubectl get pods -n default -l app=postgres -o jsonpath='{.items[0].metadata.name}')

# Wait for the PostgreSQL pod to be in the 'Running' and 'Ready' state
echo "Waiting for PostgreSQL pod to be ready..."
while true; do
pankajkoti marked this conversation as resolved.
Show resolved Hide resolved
POD_STATUS=$(kubectl get pod "$POD_NAME" -n default -o jsonpath='{.status.phase}')

if [ "$POD_STATUS" = "Running" ] && [ "$(kubectl get pod "$POD_NAME" -n default -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}')" = "True" ]; then
echo "PostgreSQL pod is up and running!"
break
elif [ "$POD_STATUS" = "Error" ]; then
echo "Error: PostgreSQL pod failed to start. Exiting..."
kubectl describe pod "$POD_NAME" -n default # Show details for debugging
exit 1
else
echo "Pod $POD_NAME is not ready yet (status: $POD_STATUS). Waiting..."
sleep 5
fi
done
#while [ "$(kubectl get pod "$POD_NAME" -n default -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}')" != "True" ]; do
# echo "Pod $POD_NAME is not ready yet. Waiting..."
# sleep 5
#done
pankajkoti marked this conversation as resolved.
Show resolved Hide resolved
# Print the name of the PostgreSQL pod
echo "$POD_NAME"

Expand Down
Loading