Merge lp:~mthaddon/charms/precise/pgbouncer/package-holds into lp:charms/pgbouncer

Proposed by Tom Haddon
Status: Merged
Merged at revision: 58
Proposed branch: lp:~mthaddon/charms/precise/pgbouncer/package-holds
Merge into: lp:charms/pgbouncer
Diff against target: 89 lines (+30/-2)
5 files modified
config.yaml (+6/-0)
hooks/config-changed (+2/-0)
hooks/db-proxy-relation-changed (+2/-2)
hooks/install (+2/-0)
scripts/common (+18/-0)
To merge this branch: bzr merge lp:~mthaddon/charms/precise/pgbouncer/package-holds
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Review via email: mp+180533@code.launchpad.net

Description of the change

Allow the pgbouncer package to be held with a config option. This allows us to stop the service from being automatically restarted if we're doing automated package updates in a production environment so we can co-ordinate any service restarts outside of automated updates

To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM +1

review: Approve

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 2013-02-25 05:22:47 +0000
3+++ config.yaml 2013-08-16 11:02:37 +0000
4@@ -149,6 +149,12 @@
5 type: string
6 description: |
7 What service this component forms part of. Used by nrpe.
8+ package_status:
9+ default: "install"
10+ type: string
11+ description: |
12+ The status of service-affecting packages will be set to this value in the dpkg database.
13+ Useful valid values are "install" and "hold".
14 wait_warn:
15 default: 5
16 type: int
17
18=== modified file 'hooks/config-changed'
19--- hooks/config-changed 2012-10-02 08:57:36 +0000
20+++ hooks/config-changed 2013-08-16 11:02:37 +0000
21@@ -11,5 +11,7 @@
22 juju-log "Generating new pgbouncer configuration and init script"
23 update_config
24
25+ensure_package_status "${SERVICE_AFFECTING_PACKAGES}" $(config-get package_status)
26+
27 juju-log "Reloading pgbouncer"
28 /usr/sbin/service pgbouncer reload
29
30=== modified file 'hooks/db-proxy-relation-changed'
31--- hooks/db-proxy-relation-changed 2013-03-22 14:30:59 +0000
32+++ hooks/db-proxy-relation-changed 2013-08-16 11:02:37 +0000
33@@ -113,8 +113,8 @@
34 if [ "$JUJU_RELATION" != "db-proxy" ]; then
35 # If called out of context
36 juju-log "Out of db-proxy relation context, manually setting JUJU vars for db-proxy relation"
37- JUJU_RELATION="db-proxy"
38- export JUJU_RELATION_IDS=$(relation-ids db-proxy)
39+ export JUJU_RELATION="db-proxy"
40+ JUJU_RELATION_IDS=$(relation-ids db-proxy)
41 UPDATED="False"
42 for JUJU_RELATION_ID in $(echo ${JUJU_RELATION_ID}); do
43 export JUJU_REMOTE_UNIT=$(relation-list -r $JUJU_RELATION_ID)
44
45=== modified file 'hooks/install'
46--- hooks/install 2013-01-03 18:15:45 +0000
47+++ hooks/install 2013-08-16 11:02:37 +0000
48@@ -22,6 +22,8 @@
49 juju-log "Installing packages via apt-get"
50 apt-get -y install -- pgbouncer python-cheetah postgresql-client pwgen python-psycopg2
51
52+ensure_package_status "${SERVICE_AFFECTING_PACKAGES}" $(config-get package_status)
53+
54 # Make sure pgbouncer is enabled and set max open files
55 max_open_files=$(config-get max_open_files)
56 cat >/etc/default/pgbouncer << EOF
57
58=== modified file 'scripts/common'
59--- scripts/common 2013-02-27 03:43:44 +0000
60+++ scripts/common 2013-08-16 11:02:37 +0000
61@@ -7,6 +7,8 @@
62
63 set -eux # -x for verbose logging to juju debug-log
64
65+SERVICE_AFFECTING_PACKAGES="pgbouncer"
66+
67 update_config()
68 {
69 pgbouncer_userlist=/etc/pgbouncer/userlist.txt
70@@ -50,3 +52,19 @@
71 juju-log "reloading pgbouncer"
72 service pgbouncer reload || exit 1
73 }
74+
75+ensure_package_status()
76+{
77+ packages="$1" ; shift
78+ status="$1" ; shift
79+
80+ case $status in
81+ install|hold)
82+ for package in ${packages}; do
83+ echo ${package} ${status}
84+ done | dpkg --set-selections
85+ ;;
86+ *)
87+ ;;
88+ esac
89+}

Subscribers

People subscribed via source and target branches

to all changes: