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
=== modified file 'config.yaml'
--- config.yaml 2013-02-25 05:22:47 +0000
+++ config.yaml 2013-08-16 11:02:37 +0000
@@ -149,6 +149,12 @@
149 type: string149 type: string
150 description: |150 description: |
151 What service this component forms part of. Used by nrpe.151 What service this component forms part of. Used by nrpe.
152 package_status:
153 default: "install"
154 type: string
155 description: |
156 The status of service-affecting packages will be set to this value in the dpkg database.
157 Useful valid values are "install" and "hold".
152 wait_warn:158 wait_warn:
153 default: 5159 default: 5
154 type: int160 type: int
155161
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2012-10-02 08:57:36 +0000
+++ hooks/config-changed 2013-08-16 11:02:37 +0000
@@ -11,5 +11,7 @@
11juju-log "Generating new pgbouncer configuration and init script"11juju-log "Generating new pgbouncer configuration and init script"
12update_config12update_config
1313
14ensure_package_status "${SERVICE_AFFECTING_PACKAGES}" $(config-get package_status)
15
14juju-log "Reloading pgbouncer"16juju-log "Reloading pgbouncer"
15/usr/sbin/service pgbouncer reload17/usr/sbin/service pgbouncer reload
1618
=== modified file 'hooks/db-proxy-relation-changed'
--- hooks/db-proxy-relation-changed 2013-03-22 14:30:59 +0000
+++ hooks/db-proxy-relation-changed 2013-08-16 11:02:37 +0000
@@ -113,8 +113,8 @@
113if [ "$JUJU_RELATION" != "db-proxy" ]; then113if [ "$JUJU_RELATION" != "db-proxy" ]; then
114 # If called out of context114 # If called out of context
115 juju-log "Out of db-proxy relation context, manually setting JUJU vars for db-proxy relation"115 juju-log "Out of db-proxy relation context, manually setting JUJU vars for db-proxy relation"
116 JUJU_RELATION="db-proxy"116 export JUJU_RELATION="db-proxy"
117 export JUJU_RELATION_IDS=$(relation-ids db-proxy)117 JUJU_RELATION_IDS=$(relation-ids db-proxy)
118 UPDATED="False" 118 UPDATED="False"
119 for JUJU_RELATION_ID in $(echo ${JUJU_RELATION_ID}); do119 for JUJU_RELATION_ID in $(echo ${JUJU_RELATION_ID}); do
120 export JUJU_REMOTE_UNIT=$(relation-list -r $JUJU_RELATION_ID)120 export JUJU_REMOTE_UNIT=$(relation-list -r $JUJU_RELATION_ID)
121121
=== modified file 'hooks/install'
--- hooks/install 2013-01-03 18:15:45 +0000
+++ hooks/install 2013-08-16 11:02:37 +0000
@@ -22,6 +22,8 @@
22juju-log "Installing packages via apt-get"22juju-log "Installing packages via apt-get"
23apt-get -y install -- pgbouncer python-cheetah postgresql-client pwgen python-psycopg223apt-get -y install -- pgbouncer python-cheetah postgresql-client pwgen python-psycopg2
2424
25ensure_package_status "${SERVICE_AFFECTING_PACKAGES}" $(config-get package_status)
26
25# Make sure pgbouncer is enabled and set max open files27# Make sure pgbouncer is enabled and set max open files
26max_open_files=$(config-get max_open_files)28max_open_files=$(config-get max_open_files)
27cat >/etc/default/pgbouncer << EOF29cat >/etc/default/pgbouncer << EOF
2830
=== modified file 'scripts/common'
--- scripts/common 2013-02-27 03:43:44 +0000
+++ scripts/common 2013-08-16 11:02:37 +0000
@@ -7,6 +7,8 @@
77
8set -eux # -x for verbose logging to juju debug-log8set -eux # -x for verbose logging to juju debug-log
99
10SERVICE_AFFECTING_PACKAGES="pgbouncer"
11
10update_config()12update_config()
11{13{
12 pgbouncer_userlist=/etc/pgbouncer/userlist.txt14 pgbouncer_userlist=/etc/pgbouncer/userlist.txt
@@ -50,3 +52,19 @@
50 juju-log "reloading pgbouncer"52 juju-log "reloading pgbouncer"
51 service pgbouncer reload || exit 153 service pgbouncer reload || exit 1
52}54}
55
56ensure_package_status()
57{
58 packages="$1" ; shift
59 status="$1" ; shift
60
61 case $status in
62 install|hold)
63 for package in ${packages}; do
64 echo ${package} ${status}
65 done | dpkg --set-selections
66 ;;
67 *)
68 ;;
69 esac
70}

Subscribers

People subscribed via source and target branches

to all changes: