Skip to content
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
7 changes: 4 additions & 3 deletions jobs/pgpool/spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ templates:
config/pcppass: config/.pcppass
config/passwd: config/passwd

consumes:
- name: db
type: postgresql

properties:
pgpool.debug:
description: Enable extra debugging wherever possible. Intended for BOSH release maintainers.
Expand All @@ -26,9 +30,6 @@ properties:
description: "A list of {username: ..., password: ...} objects for defining pgpool users"
default: []

pgpool.backend.hosts:
description: A list of backend host / IPs to pool connections to.
default: []
pgpool.backend.port:
description: The port that the PostgreSQL backends are listening on
default: 6432
Expand Down
6 changes: 3 additions & 3 deletions jobs/pgpool/templates/config/pgpool.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
config['pcp_port'] ||= 9898
# FIXME: support for SSL key?

backends = p('pgpool.backend.hosts', [])
backends = link("db").instances
if backends.empty? then
raise "pgpool.backend.hosts property must define at least one postgres backend host!"
end
Expand All @@ -32,8 +32,8 @@ connection_cache = on
reset_query_list = 'ABORT; DISCARD ALL'
pool_passwd = 'passwd'

<% backends.each_with_index do |backend, i| %>
backend_host<%= i %> = <%= val(backend) %>
<% link("db").instances.each_with_index do |instance, i| %>
backend_host<%= i %> = <%= val(instance.address) %>
backend_port<%= i %> = <%= val(p('pgpool.backend.port')) %>
<% end %>

Expand Down
18 changes: 12 additions & 6 deletions jobs/postgres/spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ templates:

sql/setup-replication.sql: sql/setup-replication.sql

provides:
- name: db
type: postgresql
properties:
- postgres.config.port
- pgpool.users

consumes:
- name: db
type: postgresql


properties:
postgres.config:
description: A map of postgresql.conf configuration directives, keyed by name.
Expand Down Expand Up @@ -79,12 +91,6 @@ properties:
postgres.replication.master:
description: IP address of the preferred master node (should be the 0th postgres node's IP)
default: ~
postgres.replication.pool:
description: List of all IP address of nodes in the replication pool (including the master)
default: []
postgres.pgpool.pool:
description: List of all IP address of PGPoolII nodes that front this Postgres node
default: []

pgpool.users:
description: "A list of {username: ..., password: ...} objects for defining pgpool users"
Expand Down
2 changes: 1 addition & 1 deletion jobs/postgres/templates/bin/ctl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
<%

masterip = p('postgres.replication.master', '')
masterip = link("db").instances.first.address
replication = p('postgres.replication.enabled', false) && masterip != ''
master = replication && spec.index == 0
port = p('postgres.config.port')
Expand Down
4 changes: 2 additions & 2 deletions jobs/postgres/templates/config/hba.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ local all all md5
<% end %>

# replication hosts
<% p("postgres.replication.pool", []).each do |ip|
%>host replication replication <%= ip %>/32 trust
<% link("db").instances.each do |instance|
%>host replication replication <%= instance.address %>/32 trust
<% end %>

# user-configured acls
Expand Down
4 changes: 2 additions & 2 deletions jobs/postgres/templates/config/postgresql.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# postgres main configuration
<%
masterip = p('postgres.replication.master', '')
replication = p('postgres.replication.enabled', false) && masterip != ''
pgs = link("db").instances
replication = p('postgres.replication.enabled', false) && pgs.size() > 1
master = replication && spec.index == 0

config = p('postgres.config', {})
Expand Down
13 changes: 5 additions & 8 deletions jobs/smoke-tests/spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ name: smoke-tests
packages:
- postgres
- pgrt

consumes:
- name: db
type: postgresql

templates:
bin/run: bin/run
helpers/ctl_setup.sh: helpers/ctl_setup.sh
helpers/ctl_utils.sh: helpers/ctl_utils.sh
sql/pgbench_cleanup.sql: sql/pgbench_cleanup.sql

properties:
postgres.smoke-tests.target.address:
description: Hostname or IP address to run pgbench against, for generating load.
postgres.smoke-tests.target.port:
description: Port to run pgbench against, for generating load.
default: 5432
Expand All @@ -28,12 +31,6 @@ properties:
description: Port that PostgreSQL itself (not PGPoolII) is listening on, for replication health checking.
default: 6432

postgres.smoke-tests.cluster.master:
description: IP address of the write master in a replicated Postgres cluster.
postgres.smoke-tests.cluster.slaves:
description: List of IP addresses of the read slaves in a replicated Postgres cluster.
default: []

postgres.smoke-tests.thresholds.replication-lag:
description: Maximum allowable replication lag for any single read slave from master (in kb).
default: 64
14 changes: 7 additions & 7 deletions jobs/smoke-tests/templates/bin/run
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
<%
master = p('postgres.smoke-tests.cluster.master')
master = link("db").instances.first.address
slaves = []
p('postgres.smoke-tests.cluster.slaves', []).each do |slave|
if slave != master
slaves.push(slave)
link("db").instances.each do |instance|
if instance.address != master
slaves.push(instance.address)
end
end
%>
Expand Down Expand Up @@ -35,7 +35,7 @@ echo "*:*:*:<%= p('postgres.smoke-tests.target.username') %>:<%= p('postgres.smo
chmod 0600 ~/.pgpass

echo "INITIALIZING PGBENCH DATABASE"
pgbench -h <%= p('postgres.smoke-tests.target.address') %> \
pgbench -h <%= master %> \
-p <%= p('postgres.smoke-tests.target.port') %> \
-U <%= p('postgres.smoke-tests.target.username') %> \
-i 2>&1
Expand All @@ -45,7 +45,7 @@ CPUS=$(grep -c ^processor /proc/cpuinfo)
CLIENTS=<%= p('postgres.smoke-tests.target.clients') %>
CLIENTS=$(( CLIENTS - (CLIENTS % CPUS) + CPUS ))
time \
pgbench -h <%= p('postgres.smoke-tests.target.address') %> \
pgbench -h <%= master %> \
-p <%= p('postgres.smoke-tests.target.port') %> \
-U <%= p('postgres.smoke-tests.target.username') %> \
-c ${CLIENTS} -j ${CPUS} -T 125 -C 2>&1 &
Expand All @@ -66,7 +66,7 @@ echo "pgbench exited $?"
echo


psql -h <%= p('postgres.smoke-tests.target.address') %> \
psql -h <%= master %> \
-p <%= p('postgres.smoke-tests.target.port') %> \
-U <%= p('postgres.smoke-tests.target.username') %> \
--file "/var/vcap/jobs/smoke-tests/sql/pgbench_cleanup.sql"
Expand Down
10 changes: 0 additions & 10 deletions templates/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ jobs:
port: 6432
replication:
enabled: true
master: (( grab jobs.postgres.networks.postgres1.static_ips[0] ))
pool: (( grab jobs.postgres.networks.postgres1.static_ips ))
pgpool:
pool: (( grab jobs.postgres.networks.postgres1.static_ips ))
hba:
- host all all 0.0.0.0/0 md5
- host all all ::/0 md5
Expand All @@ -46,7 +42,6 @@ jobs:
- username: smoke-tests
password: if-ya-got-em
backend:
hosts: (( grab jobs.postgres.networks.postgres1.static_ips ))
port: 6432
config:
port: 5432
Expand All @@ -68,17 +63,12 @@ jobs:
postgres:
smoke-tests:
target:
address: (( grab jobs.postgres.properties.postgres.replication.master ))
port: 5432
username: smoke-tests
password: if-ya-got-em
backend:
port: 6432

cluster:
master: (( grab jobs.postgres.properties.postgres.replication.master ))
slaves: (( grab jobs.postgres.properties.postgres.replication.pool ))



networks: (( param "please set networks" ))
Expand Down