From 4f3c30a3a15bf89c8971828caf633b30052dc62d Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Mon, 21 Aug 2023 10:12:51 +0200 Subject: [PATCH 01/10] Add env variable to allow eth prod to fix the hapi-fhir image tag --- .env.cluster | 2 ++ .env.remote | 2 ++ fhir-datastore-hapi-fhir/docker-compose.yml | 4 ++-- fhir-datastore-hapi-fhir/package-metadata.json | 4 +++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.env.cluster b/.env.cluster index 5e8e70b7..0c501267 100644 --- a/.env.cluster +++ b/.env.cluster @@ -19,6 +19,8 @@ OPENHIM_MONGO_ATNAURL=mongodb://mongo-1:27017,mongo-2:27017,mongo-3:27017/openhi # FHIR Datastore - HAPI FHIR HAPI_FHIR_INSTANCES=3 +# (pool size * instances) should be less than 100 +HF_MAX_POOL_SIZE=30 REPMGR_PARTNER_NODES=postgres-1,postgres-2,postgres-3 POSTGRES_REPLICA_SET=postgres-1:5432,postgres-2:5432,postgres-3:5432 HAPI_DB_SET=pgpool-1:5432,pgpool-2:5432,pgpool-3:5432 diff --git a/.env.remote b/.env.remote index 882cf140..bee8a87c 100644 --- a/.env.remote +++ b/.env.remote @@ -15,6 +15,8 @@ ES_HOSTS="\"analytics-datastore-elastic-search-01:9200","analytics-datastore-ela CLICKHOUSE_HOST=analytics-datastore-clickhouse-01 # FHIR Datastore - HAPI FHIR +HAPI_FHIR_INSTANCES=3 +HF_MAX_POOL_SIZE=30 REPMGR_PARTNER_NODES=postgres-1,postgres-2,postgres-3 POSTGRES_REPLICA_SET=postgres-1:5432,postgres-2:5432,postgres-3:5432 HAPI_DB_SET=postgres-1:5432,postgres-2:5432,postgres-3:5432 diff --git a/fhir-datastore-hapi-fhir/docker-compose.yml b/fhir-datastore-hapi-fhir/docker-compose.yml index 8546fd48..ea5a012a 100644 --- a/fhir-datastore-hapi-fhir/docker-compose.yml +++ b/fhir-datastore-hapi-fhir/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.9' services: hapi-fhir: - image: jembi/hapi:v6.0.1-wget + image: jembi/hapi:${HF_IMAGE_TAG} networks: mpi: public: @@ -13,7 +13,7 @@ services: - spring.datasource.password=${HF_POSTGRESQL_PASSWORD} - spring.datasource.driverClassName=org.postgresql.Driver - spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect - - spring.datasource.hikari.maximumPoolSize=250 + - spring.datasource.hikari.maximumPoolSize=${HF_MAX_POOL_SIZE} - spring.datasource.hikari.minimumIdle=20 - spring.datasource.hikari.connectionTimeout=60000 - spring.datasource.hikari.idleTimeout=600000 diff --git a/fhir-datastore-hapi-fhir/package-metadata.json b/fhir-datastore-hapi-fhir/package-metadata.json index e267fb88..be2a141b 100644 --- a/fhir-datastore-hapi-fhir/package-metadata.json +++ b/fhir-datastore-hapi-fhir/package-metadata.json @@ -32,6 +32,8 @@ "HF_PGPOOL_MEMORY_LIMIT": "500M", "HF_PGPOOL_CPU_RESERVE": "0.05", "HF_PGPOOL_MEMORY_RESERVE": "50M", - "HF_JAVA_OPTS": "-Xmx2g" + "HF_JAVA_OPTS": "-Xmx2g", + "HF_IMAGE_TAG": "v6.0.1-wget", + "HF_MAX_POOL_SIZE": "80" } } From dcbb26b38117054b5dc7cffcfdaec9f80efde5fe Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Mon, 21 Aug 2023 10:13:19 +0200 Subject: [PATCH 02/10] Update platfomr image tag --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 4471237d..a4047aba 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ projectName: platform -image: jembi/platform:2.4.1 +image: jembi/platform:2.4.2 logPath: /tmp/logs packages: From 65b8c583d5c357fdf50f7f14ddba9946a082bd5e Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Tue, 22 Aug 2023 09:11:08 +0200 Subject: [PATCH 03/10] Set pgpool to only have 1 instance running on 1 node --- .../docker-compose-postgres.cluster.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml index 87ea782d..41bdae41 100644 --- a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml +++ b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml @@ -75,7 +75,9 @@ services: image: bitnami/pgpool:4.4.3 deploy: placement: - max_replicas_per_node: 1 + constraints: + - "node.labels.name==node-1" + replicas: 1 resources: limits: cpus: ${HF_PGPOOL_CPU_LIMIT} @@ -109,7 +111,9 @@ services: image: bitnami/pgpool:4.4.3 deploy: placement: - max_replicas_per_node: 1 + constraints: + - "node.labels.name==node-2" + replicas: 1 resources: limits: cpus: ${HF_PGPOOL_CPU_LIMIT} @@ -143,7 +147,9 @@ services: image: bitnami/pgpool:4.4.3 deploy: placement: - max_replicas_per_node: 1 + constraints: + - "node.labels.name==node-3" + replicas: 1 resources: limits: cpus: ${HF_PGPOOL_CPU_LIMIT} From 31f4d05118e991b0aab2f6eb5fdedec2bb73c2d0 Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Thu, 24 Aug 2023 12:40:15 +0200 Subject: [PATCH 04/10] Add custom postgresql.conf file to override certain postgresql defaults --- fhir-datastore-hapi-fhir/config/custom_postgresql.conf | 2 ++ .../docker-compose-postgres.cluster.yml | 6 ++++++ fhir-datastore-hapi-fhir/docker-compose-postgres.yml | 10 ++++++++++ 3 files changed, 18 insertions(+) create mode 100644 fhir-datastore-hapi-fhir/config/custom_postgresql.conf diff --git a/fhir-datastore-hapi-fhir/config/custom_postgresql.conf b/fhir-datastore-hapi-fhir/config/custom_postgresql.conf new file mode 100644 index 00000000..f4543c51 --- /dev/null +++ b/fhir-datastore-hapi-fhir/config/custom_postgresql.conf @@ -0,0 +1,2 @@ +max_connections = 250 +shared_buffers = 768MB diff --git a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml index 41bdae41..042b1158 100644 --- a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml +++ b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml @@ -24,6 +24,9 @@ services: POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} volumes: - 'hapi-postgres-2-data:/bitnami/postgresql' + configs: + - target: /bitnami/postgresql/conf/conf.d/custom_postgresql.conf + source: postgresql.conf deploy: placement: constraints: @@ -55,6 +58,9 @@ services: POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} volumes: - 'hapi-postgres-3-data:/bitnami/postgresql' + configs: + - target: /bitnami/postgresql/conf/conf.d/custom_postgresql.conf + source: postgresql.conf deploy: placement: constraints: diff --git a/fhir-datastore-hapi-fhir/docker-compose-postgres.yml b/fhir-datastore-hapi-fhir/docker-compose-postgres.yml index d338f52f..c95d073e 100644 --- a/fhir-datastore-hapi-fhir/docker-compose-postgres.yml +++ b/fhir-datastore-hapi-fhir/docker-compose-postgres.yml @@ -16,6 +16,9 @@ services: POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} volumes: - "hapi-postgres-1-data:/bitnami/postgresql" + configs: + - target: /bitnami/postgresql/conf/conf.d/custom_postgresql.conf + source: postgresql.conf deploy: replicas: 1 resources: @@ -33,6 +36,13 @@ services: volumes: hapi-postgres-1-data: +configs: + postgresql.conf: + name: postgresql_conf-${postgresql_conf_DIGEST:?err} + file: ./config/custom_postgresql.conf + labels: + name: hapi-fhir + networks: default: hapi-fhir-postgres: From 4a4c4782eaa23e132ff6c9e9336fe26a6dbfa550 Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Fri, 25 Aug 2023 09:37:40 +0200 Subject: [PATCH 05/10] Revert back to old hapi-fhir healthcheck --- fhir-datastore-hapi-fhir/docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fhir-datastore-hapi-fhir/docker-compose.yml b/fhir-datastore-hapi-fhir/docker-compose.yml index ea5a012a..53f6379f 100644 --- a/fhir-datastore-hapi-fhir/docker-compose.yml +++ b/fhir-datastore-hapi-fhir/docker-compose.yml @@ -34,10 +34,10 @@ services: cpus: ${HAPI_FHIR_CPU_RESERVE} memory: ${HAPI_FHIR_MEMORY_RESERVE} healthcheck: - test: /bin/wget --no-verbose --tries=1 --spider http://localhost:8080/fhir/Organization?identifier=urn:healthcheck + test: /bin/wget --no-verbose --tries=1 --spider http://localhost:8080 && exit 0 || exit 1 interval: 30s - timeout: 30s - retries: 2 + timeout: 5s + retries: 5 start_period: 2m networks: From 012fc93456bbaa69e371dba26b0360d610d159ad Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Fri, 25 Aug 2023 09:40:23 +0200 Subject: [PATCH 06/10] Update pgpool config to be less authoritative --- fhir-datastore-hapi-fhir/config/custom_pgpool.conf | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fhir-datastore-hapi-fhir/config/custom_pgpool.conf b/fhir-datastore-hapi-fhir/config/custom_pgpool.conf index 88a7ce68..a0885000 100644 --- a/fhir-datastore-hapi-fhir/config/custom_pgpool.conf +++ b/fhir-datastore-hapi-fhir/config/custom_pgpool.conf @@ -1,14 +1,9 @@ -failover_on_backend_error='on' -detach_false_primary='on' auto_failback='on' health_check_period=25 health_check_max_retries=3 health_check_user='postgres' -reserved_connections=1 -max_pool=6 +max_pool=5 client_idle_limit=300 -connection_life_time=300 -child_max_connections=25 use_watchdog='on' hostname0='pgpool-1' From 9f846fe5a377aa41f6ddf27fa74f76076006f90e Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Thu, 31 Aug 2023 12:18:50 +0200 Subject: [PATCH 07/10] Add ability to switch hapi-fhir postgres failover to manual and disable pgpool --- .../docker-compose-postgres.cluster.yml | 10 +++++++--- fhir-datastore-hapi-fhir/docker-compose-postgres.yml | 2 ++ fhir-datastore-hapi-fhir/package-metadata.json | 7 ++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml index 042b1158..9ccc245c 100644 --- a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml +++ b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml @@ -22,6 +22,8 @@ services: REPMGR_PRIMARY_HOST: ${REPMGR_PRIMARY_HOST} REPMGR_PARTNER_NODES: ${REPMGR_PARTNER_NODES} POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + REPMGR_FAILOVER: ${HF_POSTGRES_FAILOVER} + REPMGR_DEGRADED_MONITORING_TIMEOUT: ${HF_POSTGRES_DEGRADED_MONITORING_TIMEOUT} volumes: - 'hapi-postgres-2-data:/bitnami/postgresql' configs: @@ -56,6 +58,8 @@ services: REPMGR_PRIMARY_HOST: ${REPMGR_PRIMARY_HOST} REPMGR_PARTNER_NODES: ${REPMGR_PARTNER_NODES} POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + REPMGR_FAILOVER: ${HF_POSTGRES_FAILOVER} + REPMGR_DEGRADED_MONITORING_TIMEOUT: ${HF_POSTGRES_DEGRADED_MONITORING_TIMEOUT} volumes: - 'hapi-postgres-3-data:/bitnami/postgresql' configs: @@ -83,7 +87,7 @@ services: placement: constraints: - "node.labels.name==node-1" - replicas: 1 + replicas: ${HF_PGPOOL_1_REPLICAS} resources: limits: cpus: ${HF_PGPOOL_CPU_LIMIT} @@ -119,7 +123,7 @@ services: placement: constraints: - "node.labels.name==node-2" - replicas: 1 + replicas: ${HF_PGPOOL_2_REPLICAS} resources: limits: cpus: ${HF_PGPOOL_CPU_LIMIT} @@ -155,7 +159,7 @@ services: placement: constraints: - "node.labels.name==node-3" - replicas: 1 + replicas: ${HF_PGPOOL_3_REPLICAS} resources: limits: cpus: ${HF_PGPOOL_CPU_LIMIT} diff --git a/fhir-datastore-hapi-fhir/docker-compose-postgres.yml b/fhir-datastore-hapi-fhir/docker-compose-postgres.yml index c95d073e..4045cf57 100644 --- a/fhir-datastore-hapi-fhir/docker-compose-postgres.yml +++ b/fhir-datastore-hapi-fhir/docker-compose-postgres.yml @@ -14,6 +14,8 @@ services: REPMGR_PRIMARY_HOST: ${REPMGR_PRIMARY_HOST} REPMGR_PARTNER_NODES: ${REPMGR_PARTNER_NODES} POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + REPMGR_FAILOVER: ${HF_POSTGRES_FAILOVER} + REPMGR_DEGRADED_MONITORING_TIMEOUT: ${HF_POSTGRES_DEGRADED_MONITORING_TIMEOUT} volumes: - "hapi-postgres-1-data:/bitnami/postgresql" configs: diff --git a/fhir-datastore-hapi-fhir/package-metadata.json b/fhir-datastore-hapi-fhir/package-metadata.json index be2a141b..224246c5 100644 --- a/fhir-datastore-hapi-fhir/package-metadata.json +++ b/fhir-datastore-hapi-fhir/package-metadata.json @@ -34,6 +34,11 @@ "HF_PGPOOL_MEMORY_RESERVE": "50M", "HF_JAVA_OPTS": "-Xmx2g", "HF_IMAGE_TAG": "v6.0.1-wget", - "HF_MAX_POOL_SIZE": "80" + "HF_MAX_POOL_SIZE": "80", + "HF_PGPOOL_1_REPLICAS": "1", + "HF_PGPOOL_2_REPLICAS": "1", + "HF_PGPOOL_3_REPLICAS": "1", + "HF_POSTGRES_FAILOVER": "automatic", + "HF_POSTGRES_DEGRADED_MONITORING_TIMEOUT": "5" } } From 19854caf88915cbdb1f7d42062925682a1a57f07 Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Thu, 31 Aug 2023 12:59:20 +0200 Subject: [PATCH 08/10] Revert hapi-fhir's healthcheck to do a database lookup again --- fhir-datastore-hapi-fhir/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fhir-datastore-hapi-fhir/docker-compose.yml b/fhir-datastore-hapi-fhir/docker-compose.yml index 53f6379f..010b5aee 100644 --- a/fhir-datastore-hapi-fhir/docker-compose.yml +++ b/fhir-datastore-hapi-fhir/docker-compose.yml @@ -34,7 +34,7 @@ services: cpus: ${HAPI_FHIR_CPU_RESERVE} memory: ${HAPI_FHIR_MEMORY_RESERVE} healthcheck: - test: /bin/wget --no-verbose --tries=1 --spider http://localhost:8080 && exit 0 || exit 1 + test: /bin/wget --no-verbose --tries=1 --spider http://localhost:8080/fhir/Organization?identifier=urn:healthcheck interval: 30s timeout: 5s retries: 5 From 25de4104a8a8ed651584cd9fbbab0bae90083492 Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Fri, 1 Sep 2023 11:25:44 +0200 Subject: [PATCH 09/10] Seperate pgpool from postgres and add environment variable to enable/disable pgpool --- .../docker-compose-pgpool.cluster.yml | 132 ++++++++++++++++++ .../docker-compose-postgres.cluster.yml | 130 ----------------- .../package-metadata.json | 4 +- fhir-datastore-hapi-fhir/swarm.sh | 4 + 4 files changed, 137 insertions(+), 133 deletions(-) create mode 100644 fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml diff --git a/fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml b/fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml new file mode 100644 index 00000000..9c1fd310 --- /dev/null +++ b/fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml @@ -0,0 +1,132 @@ +version: '3.9' + +services: + pgpool-1: + image: bitnami/pgpool:4.4.3 + deploy: + placement: + constraints: + - "node.labels.name==node-1" + replicas: 1 + resources: + limits: + cpus: ${HF_PGPOOL_CPU_LIMIT} + memory: ${HF_PGPOOL_MEMORY_LIMIT} + reservations: + cpus: ${HF_PGPOOL_CPU_RESERVE} + memory: ${HF_PGPOOL_MEMORY_RESERVE} + configs: + - target: /config/custom_pgpool.conf + source: pgpool.conf + - target: /opt/bitnami/pgpool/conf/pgpool_node_id + source: pgpool_node_id0.conf + environment: + PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES} + PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES} + PGPOOL_SR_CHECK_USER: postgres + PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + PGPOOL_POSTGRES_USERNAME: postgres + PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME} + PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD} + PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME} + PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD} + PGPOOL_ENABLE_LOAD_BALANCING: "no" + PGPOOL_AUTO_FAILBACK: "yes" + PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" + networks: + default: + + pgpool-2: + image: bitnami/pgpool:4.4.3 + deploy: + placement: + constraints: + - "node.labels.name==node-2" + replicas: 1 + resources: + limits: + cpus: ${HF_PGPOOL_CPU_LIMIT} + memory: ${HF_PGPOOL_MEMORY_LIMIT} + reservations: + cpus: ${HF_PGPOOL_CPU_RESERVE} + memory: ${HF_PGPOOL_MEMORY_RESERVE} + configs: + - target: /config/custom_pgpool.conf + source: pgpool.conf + - target: /opt/bitnami/pgpool/conf/pgpool_node_id + source: pgpool_node_id1.conf + environment: + PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES} + PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES} + PGPOOL_SR_CHECK_USER: postgres + PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + PGPOOL_POSTGRES_USERNAME: postgres + PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME} + PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD} + PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME} + PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD} + PGPOOL_ENABLE_LOAD_BALANCING: "no" + PGPOOL_AUTO_FAILBACK: "yes" + PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" + networks: + default: + + pgpool-3: + image: bitnami/pgpool:4.4.3 + deploy: + placement: + constraints: + - "node.labels.name==node-3" + replicas: 1 + resources: + limits: + cpus: ${HF_PGPOOL_CPU_LIMIT} + memory: ${HF_PGPOOL_MEMORY_LIMIT} + reservations: + cpus: ${HF_PGPOOL_CPU_RESERVE} + memory: ${HF_PGPOOL_MEMORY_RESERVE} + configs: + - target: /config/custom_pgpool.conf + source: pgpool.conf + - target: /opt/bitnami/pgpool/conf/pgpool_node_id + source: pgpool_node_id2.conf + environment: + PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES} + PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES} + PGPOOL_SR_CHECK_USER: postgres + PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + PGPOOL_POSTGRES_USERNAME: postgres + PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} + PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME} + PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD} + PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME} + PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD} + PGPOOL_ENABLE_LOAD_BALANCING: "no" + PGPOOL_AUTO_FAILBACK: "yes" + PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" + networks: + default: + +configs: + pgpool.conf: + name: pgpool_conf-${pgpool_conf_DIGEST:?err} + file: ./config/custom_pgpool.conf + labels: + name: hapi-fhir + pgpool_node_id0.conf: + name: pgpool_node_id0-${pgpool_node_id0_DIGEST:?err} + file: ./config/pgpool_node_id0 + labels: + name: hapi-fhir + pgpool_node_id1.conf: + name: pgpool_node_id1-${pgpool_node_id1_DIGEST:?err} + file: ./config/pgpool_node_id1 + labels: + name: hapi-fhir + pgpool_node_id2.conf: + name: pgpool_node_id2-${pgpool_node_id2_DIGEST:?err} + file: ./config/pgpool_node_id2 + labels: + name: hapi-fhir diff --git a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml index 9ccc245c..fa1913ba 100644 --- a/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml +++ b/fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml @@ -81,136 +81,6 @@ services: default: pg_backup_net: - pgpool-1: - image: bitnami/pgpool:4.4.3 - deploy: - placement: - constraints: - - "node.labels.name==node-1" - replicas: ${HF_PGPOOL_1_REPLICAS} - resources: - limits: - cpus: ${HF_PGPOOL_CPU_LIMIT} - memory: ${HF_PGPOOL_MEMORY_LIMIT} - reservations: - cpus: ${HF_PGPOOL_CPU_RESERVE} - memory: ${HF_PGPOOL_MEMORY_RESERVE} - configs: - - target: /config/custom_pgpool.conf - source: pgpool.conf - - target: /opt/bitnami/pgpool/conf/pgpool_node_id - source: pgpool_node_id0.conf - environment: - PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES} - PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES} - PGPOOL_SR_CHECK_USER: postgres - PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD} - PGPOOL_POSTGRES_USERNAME: postgres - PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} - PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME} - PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD} - PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME} - PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD} - PGPOOL_ENABLE_LOAD_BALANCING: "no" - PGPOOL_AUTO_FAILBACK: "yes" - PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" - networks: - default: - - pgpool-2: - image: bitnami/pgpool:4.4.3 - deploy: - placement: - constraints: - - "node.labels.name==node-2" - replicas: ${HF_PGPOOL_2_REPLICAS} - resources: - limits: - cpus: ${HF_PGPOOL_CPU_LIMIT} - memory: ${HF_PGPOOL_MEMORY_LIMIT} - reservations: - cpus: ${HF_PGPOOL_CPU_RESERVE} - memory: ${HF_PGPOOL_MEMORY_RESERVE} - configs: - - target: /config/custom_pgpool.conf - source: pgpool.conf - - target: /opt/bitnami/pgpool/conf/pgpool_node_id - source: pgpool_node_id1.conf - environment: - PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES} - PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES} - PGPOOL_SR_CHECK_USER: postgres - PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD} - PGPOOL_POSTGRES_USERNAME: postgres - PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} - PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME} - PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD} - PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME} - PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD} - PGPOOL_ENABLE_LOAD_BALANCING: "no" - PGPOOL_AUTO_FAILBACK: "yes" - PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" - networks: - default: - - pgpool-3: - image: bitnami/pgpool:4.4.3 - deploy: - placement: - constraints: - - "node.labels.name==node-3" - replicas: ${HF_PGPOOL_3_REPLICAS} - resources: - limits: - cpus: ${HF_PGPOOL_CPU_LIMIT} - memory: ${HF_PGPOOL_MEMORY_LIMIT} - reservations: - cpus: ${HF_PGPOOL_CPU_RESERVE} - memory: ${HF_PGPOOL_MEMORY_RESERVE} - configs: - - target: /config/custom_pgpool.conf - source: pgpool.conf - - target: /opt/bitnami/pgpool/conf/pgpool_node_id - source: pgpool_node_id2.conf - environment: - PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES} - PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES} - PGPOOL_SR_CHECK_USER: postgres - PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD} - PGPOOL_POSTGRES_USERNAME: postgres - PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD} - PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME} - PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD} - PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME} - PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD} - PGPOOL_ENABLE_LOAD_BALANCING: "no" - PGPOOL_AUTO_FAILBACK: "yes" - PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" - networks: - default: - -configs: - pgpool.conf: - name: pgpool_conf-${pgpool_conf_DIGEST:?err} - file: ./config/custom_pgpool.conf - labels: - name: hapi-fhir - pgpool_node_id0.conf: - name: pgpool_node_id0-${pgpool_node_id0_DIGEST:?err} - file: ./config/pgpool_node_id0 - labels: - name: hapi-fhir - pgpool_node_id1.conf: - name: pgpool_node_id1-${pgpool_node_id1_DIGEST:?err} - file: ./config/pgpool_node_id1 - labels: - name: hapi-fhir - pgpool_node_id2.conf: - name: pgpool_node_id2-${pgpool_node_id2_DIGEST:?err} - file: ./config/pgpool_node_id2 - labels: - name: hapi-fhir - volumes: hapi-postgres-2-data: hapi-postgres-3-data: diff --git a/fhir-datastore-hapi-fhir/package-metadata.json b/fhir-datastore-hapi-fhir/package-metadata.json index 224246c5..686c415f 100644 --- a/fhir-datastore-hapi-fhir/package-metadata.json +++ b/fhir-datastore-hapi-fhir/package-metadata.json @@ -35,9 +35,7 @@ "HF_JAVA_OPTS": "-Xmx2g", "HF_IMAGE_TAG": "v6.0.1-wget", "HF_MAX_POOL_SIZE": "80", - "HF_PGPOOL_1_REPLICAS": "1", - "HF_PGPOOL_2_REPLICAS": "1", - "HF_PGPOOL_3_REPLICAS": "1", + "HF_PGPOOL_ENABLED": "true", "HF_POSTGRES_FAILOVER": "automatic", "HF_POSTGRES_DEGRADED_MONITORING_TIMEOUT": "5" } diff --git a/fhir-datastore-hapi-fhir/swarm.sh b/fhir-datastore-hapi-fhir/swarm.sh index 23376542..2a5a6081 100644 --- a/fhir-datastore-hapi-fhir/swarm.sh +++ b/fhir-datastore-hapi-fhir/swarm.sh @@ -51,6 +51,10 @@ function initialize_package() { ( docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose-postgres.yml" "$postgres_cluster_compose_filename" "$postgres_dev_compose_filename" + if [ "${CLUSTERED_MODE}" == "true" && "${HF_PGPOOL_ENABLED}" == "true" ]; then + docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose-pgpool.cluster.yml" + fi + docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose.yml" "$hapi_fhir_dev_compose_filename" ) || { From 7688185456f2843108fe12ac004925a7414ac532 Mon Sep 17 00:00:00 2001 From: Arran Standish Date: Fri, 1 Sep 2023 12:00:58 +0200 Subject: [PATCH 10/10] Remove redundant network definition from pgpool & fix swarm.sh if check --- fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml | 6 ------ fhir-datastore-hapi-fhir/swarm.sh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml b/fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml index 9c1fd310..3c054910 100644 --- a/fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml +++ b/fhir-datastore-hapi-fhir/docker-compose-pgpool.cluster.yml @@ -34,8 +34,6 @@ services: PGPOOL_ENABLE_LOAD_BALANCING: "no" PGPOOL_AUTO_FAILBACK: "yes" PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" - networks: - default: pgpool-2: image: bitnami/pgpool:4.4.3 @@ -70,8 +68,6 @@ services: PGPOOL_ENABLE_LOAD_BALANCING: "no" PGPOOL_AUTO_FAILBACK: "yes" PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" - networks: - default: pgpool-3: image: bitnami/pgpool:4.4.3 @@ -106,8 +102,6 @@ services: PGPOOL_ENABLE_LOAD_BALANCING: "no" PGPOOL_AUTO_FAILBACK: "yes" PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf" - networks: - default: configs: pgpool.conf: diff --git a/fhir-datastore-hapi-fhir/swarm.sh b/fhir-datastore-hapi-fhir/swarm.sh index 2a5a6081..eeecad52 100644 --- a/fhir-datastore-hapi-fhir/swarm.sh +++ b/fhir-datastore-hapi-fhir/swarm.sh @@ -51,7 +51,7 @@ function initialize_package() { ( docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose-postgres.yml" "$postgres_cluster_compose_filename" "$postgres_dev_compose_filename" - if [ "${CLUSTERED_MODE}" == "true" && "${HF_PGPOOL_ENABLED}" == "true" ]; then + if [[ "${CLUSTERED_MODE}" == "true" && "${HF_PGPOOL_ENABLED}" == "true" ]]; then docker::deploy_service "$STACK" "${COMPOSE_FILE_PATH}" "docker-compose-pgpool.cluster.yml" fi