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

Merge/v1.10.2 #383

Merged
merged 8 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Build and push :main image

on:
push:
branches: [ main ]
branches:
- main
- 'release/**'

env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand Down
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pipeline {
anyOf {
branch 'main'
branch 'hotfix/*'
branch 'release/*'
}
expression { !isPrBuild() }
}
Expand Down
71 changes: 55 additions & 16 deletions dbproxy/scripts/start-pgbouncer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,65 @@ set -e
command -v pgbouncer
set +e

until timeout 10 psql "$(cat /dbproxy/uri_dsn.txt)" -c 'SELECT 1'; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done
echo "PostgreSQL is ready!"
# Function to test PostgreSQL connection
test_postgres() {
local dsn="$1"
if psql "$dsn" -c 'SELECT 1' >/dev/null 2>&1; then
return 0
fi
return 1
}

# Function to run all connection tests with global timeout
run_connection_tests() {
local start_time=$(date +%s)
local timeout=60
local ssl_ok=0
local nonssl_ok=0

while [ $ssl_ok -eq 0 ] || [ $nonssl_ok -eq 0 ]; do
current_time=$(date +%s)
if [ $((current_time - start_time)) -ge $timeout ]; then
echo "Timed out waiting for PostgreSQL after ${timeout} seconds"
return 1
fi

if [ $ssl_ok -eq 0 ] && test_postgres "postgres://localhost:5432/?sslmode=require"; then
echo "SSL connection successful"
ssl_ok=1
fi

if [ $nonssl_ok -eq 0 ] && test_postgres "postgres://localhost:5432/?sslmode=disable"; then
echo "Non-SSL connection successful"
nonssl_ok=1
fi

if [ $ssl_ok -eq 0 ] || [ $nonssl_ok -eq 0 ]; then
echo "Waiting for PostgreSQL connections to be ready..."
sleep 2
fi
done
return 0
}

# Initial PostgreSQL check
if ! test_postgres "$(cat /dbproxy/uri_dsn.txt)"; then
echo "Initial PostgreSQL connection failed"
exit 1
fi
echo "Initial PostgreSQL connection successful!"

# Generate certificates
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout dbproxy-server.key -out dbproxy-server.crt -subj "/C=US/CN=dbproxy-server/ST=CA/L=Santa Clara/O=Infoblox/OU=Blox in a Box"
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout dbproxy-client.key -out dbproxy-client.crt -subj "/C=US/CN=dbproxy-client/ST=CA/L=Santa Clara/O=Infoblox/OU=Blox in a Box"

# Start pgbouncer
pgbouncer -d -v pgbouncer.ini

# Test that both SSL and non-SSL connections work
until timeout 10 psql postgres://localhost:5432/?sslmode=require -c 'SELECT 1'; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done

until timeout 10 psql postgres://localhost:5432/?sslmode=disable -c 'SELECT 1'; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done
# Test both SSL and non-SSL connections concurrently
if ! run_connection_tests; then
echo "Connection tests failed"
exit 1
fi

echo "PostgreSQL is ready!"
echo "All PostgreSQL connections are ready!"
Loading
Loading