From 0da2efa633d8cc64db732704e80a74dd0a4e23b5 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 10 Dec 2018 12:26:20 -0800 Subject: [PATCH] add application_name to pgbouncer connectio string --- controller/PostgreSQL.cpp | 5 ++++- cycle_controllers.sh | 1 + docker/main.sh | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index e4a2a90b2..db0537ec9 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -1349,7 +1349,10 @@ PGconn *PostgreSQL::getPgConn(OverrideMode m) { char *connStr = getenv("PGBOUNCER_CONNSTR"); if (connStr != NULL) { fprintf(stderr, "PGBouncer Override\n"); - return PQconnectdb(connStr); + std::string conn(connStr); + conn += " application_name=controller-"; + conn += _myAddressStr.c_str(); + return PQconnectdb(conn.c_str()); } } diff --git a/cycle_controllers.sh b/cycle_controllers.sh index c02a1f9b0..34acacf4e 100755 --- a/cycle_controllers.sh +++ b/cycle_controllers.sh @@ -5,4 +5,5 @@ CONTROLLERS=`kubectl get pods -o=name | grep controller | sed "s/^.\{4\}//"` for c in ${CONTROLLERS[@]} do kubectl delete pod ${c} + sleep 30 done diff --git a/docker/main.sh b/docker/main.sh index 92b46b204..efb3fe845 100644 --- a/docker/main.sh +++ b/docker/main.sh @@ -12,6 +12,10 @@ if [ -z "$ZT_DB_PORT" ]; then echo '*** FAILED: ZT_DB_PORT environment variable not defined' exit 1 fi +if [ -z "$ZT_DB_NAME" ]; then + echo '*** FAILED: ZT_DB_NAME environment variable not defined' + exit 1 +fi if [ -z "$ZT_DB_USER" ]; then echo '*** FAILED: ZT_DB_USER environment variable not defined' exit 1 @@ -38,7 +42,7 @@ echo "{ \"inot\", \"nat64\" ], - \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=ztc user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} sslmode=require sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\" + \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\" } } " > /var/lib/zerotier-one/local.conf