Merge lp:~thedac/charms/precise/errors/fix-multiple-app-server-races into lp:~daisy-pluckers/charms/precise/errors/trunk

Proposed by David Ames
Status: Merged
Merged at revision: 37
Proposed branch: lp:~thedac/charms/precise/errors/fix-multiple-app-server-races
Merge into: lp:~daisy-pluckers/charms/precise/errors/trunk
Diff against target: 44 lines (+16/-2)
2 files modified
config.yaml (+5/-0)
hooks/postgres (+11/-2)
To merge this branch: bzr merge lp:~thedac/charms/precise/errors/fix-multiple-app-server-races
Reviewer Review Type Date Requested Status
Daisy Pluckers Pending
Review via email: mp+213350@code.launchpad.net

Description of the change

Fix problems with multiple appservers.
Use role account for db ownership.
Wait for allowed-hosts to be set on the relation before proceeding

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2014-03-19 17:16:45 +0000
3+++ config.yaml 2014-03-28 23:33:54 +0000
4@@ -58,6 +58,11 @@
5 default: 'credentials_cache'
6 description: |
7 The name of the database to store OpenID credential information in.
8+ credentials-database-role:
9+ type: string
10+ default: 'credentials_cache'
11+ description: |
12+ The role name that will own the database.
13 repository:
14 type: string
15 default: 'ppa:daisy-pluckers/daisy-seeds'
16
17=== modified file 'hooks/postgres'
18--- hooks/postgres 2014-03-12 18:57:37 +0000
19+++ hooks/postgres 2014-03-28 23:33:54 +0000
20@@ -6,13 +6,22 @@
21 DATABASE="$(relation-get database)"
22 HOST="$(relation-get host)"
23 PASSWORD="$(relation-get password)"
24+ALLOWED_UNITS="$(relation-get allowed-units)"
25
26 if [ -z "$DATABASE" ]; then
27- relation-set database="$(config-get credentials-database-name)"
28+ relation-set database="$(config-get credentials-database-name)" role="$(config-get credentials-database-role)"
29 exit 0
30 fi
31
32-[ -n "$USER" ] || exit 0
33+if [[ -z "$ALLOWED_UNITS" ]]; then
34+ echo "ALLOWED_UNITS not yet set"
35+ exit 0
36+fi
37+if [[ "$ALLOWED_UNITS" != *${JUJU_UNIT_NAME}* ]]; then
38+ echo "$JUJU_UNIT_NAME not in $ALLOWED_UNITS"
39+ exit 0
40+fi
41+
42
43 if [ ! -e "$POSTGRES_CONFIG_PATH" ]; then
44 cat > "$POSTGRES_CONFIG_PATH" << EOF

Subscribers

People subscribed via source and target branches

to all changes: