Merge lp:~gnuoy/charms/precise/daisy-retracer/add-upgrade-charm into lp:~daisy-pluckers/charms/precise/daisy-retracer/trunk

Proposed by Liam Young
Status: Merged
Merged at revision: 29
Proposed branch: lp:~gnuoy/charms/precise/daisy-retracer/add-upgrade-charm
Merge into: lp:~daisy-pluckers/charms/precise/daisy-retracer/trunk
Diff against target: 138 lines (+62/-13)
5 files modified
config.yaml (+10/-0)
hooks/common (+35/-0)
hooks/config-changed (+1/-0)
hooks/install (+2/-8)
hooks/upgrade-charm (+14/-5)
To merge this branch: bzr merge lp:~gnuoy/charms/precise/daisy-retracer/add-upgrade-charm
Reviewer Review Type Date Requested Status
Evan (community) Approve
Review via email: mp+162329@code.launchpad.net
To post a comment you must log in.
30. By Liam Young

Variables used by templates need to be exported

Revision history for this message
Evan (ev) wrote :

This looks good. I'm just going to change upgrade-charm to cd in a subshell, in case we add code later that has expectations about $(pwd).

review: Approve
Revision history for this message
Evan (ev) wrote :

Landed as r29, fixed up as r30.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2013-05-03 00:27:01 +0000
+++ config.yaml 2013-05-03 14:12:24 +0000
@@ -86,6 +86,16 @@
86 type: string86 type: string
87 default: 'i386 amd64 armhf'87 default: 'i386 amd64 armhf'
88 description: Space separated list of architectures for which to process reports.88 description: Space separated list of architectures for which to process reports.
89 daisy_code_dirs:
90 type: int
91 default: 3
92 description: |
93 How many old copies of daisy code to retain (candidates for backouts)
94 apport_code_dirs:
95 type: int
96 default: 3
97 description: |
98 How many old copies of apport code to retain (candidates for backouts)
89 repository:99 repository:
90 type: string100 type: string
91 default: 'ppa:daisy-pluckers/daisy-seeds'101 default: 'ppa:daisy-pluckers/daisy-seeds'
92102
=== modified file 'hooks/common'
--- hooks/common 2013-05-03 00:27:01 +0000
+++ hooks/common 2013-05-03 14:12:24 +0000
@@ -16,6 +16,8 @@
16APPORT_LOCATION="$DEPLOY_ROOT/apport"16APPORT_LOCATION="$DEPLOY_ROOT/apport"
17CACHE_DIR="$DEPLOY_ROOT/cache"17CACHE_DIR="$DEPLOY_ROOT/cache"
18VAR_DIR="$DEPLOY_ROOT/var"18VAR_DIR="$DEPLOY_ROOT/var"
19DAISY_CODE_DIRS="$(config-get daisy_code_dirs)"
20APPORT_CODE_DIRS="$(config-get apport_code_dirs)"
1921
20save_setting () {22save_setting () {
21 key="$1"23 key="$1"
@@ -62,3 +64,36 @@
6264
63 done65 done
64}66}
67
68deploy_code () {
69 local tarball="$1"
70 local codedir="$2"
71 local codedir_count="$3"
72 local codename=$(basename "$codedir")
73 local coderoot=$(dirname "$codedir")
74 local tmpdir=$(mktemp -d --tmpdir="${coderoot}")
75 tar -C ${tmpdir} -xf ${tarball}
76 local coderevno=$(bzr revno ${tmpdir})
77 if [[ -d "${coderoot}/${codename}-${coderevno}" ]]; then
78 juju-log "${coderevno} of ${codename} already deployed"
79 rm -rf ${tmpdir}
80 else
81 juju-log "Deploying ${coderevno} of ${codename}"
82 chown -R $USER_CODE_OWNER:$USER_CODE_RUNNER "${tmpdir}"
83 mv "${tmpdir}" "${coderoot}/${codename}-${coderevno}"
84 [ -d "${coderoot}/${codename}" ] && rm -rf "${coderoot}/${codename}"
85 ln -s "${coderoot}/${codename}-${coderevno}" "${coderoot}/${codename}"
86 remove_old_codedirs $codedir_count "${coderoot}/${codename}-*"
87 fi
88}
89
90remove_old_codedirs () {
91 local codedir_count="$1"
92 local codedir_regex="$2"
93 local current_code_dirs=$(ls -d ${codedir_regex} | wc -l)
94 if [[ $current_code_dirs -gt $codedir_count ]]; then
95 juju-log "More than $codedir_count found, deleting:"
96 juju-log "$(ls -td ${codedir_regex} | tail -n +$(($codedir_count+1)))"
97 ls -1rd ${codedir_regex} | tail -n +$(($codedir_count+1)) | xargs rm -rf
98 fi
99}
65100
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2013-05-03 00:39:11 +0000
+++ hooks/config-changed 2013-05-03 14:12:24 +0000
@@ -35,6 +35,7 @@
35 #sed -i "s|cassandra_hosts =.*|cassandra_hosts = []|" $LOCAL_CONFIG_PATH35 #sed -i "s|cassandra_hosts =.*|cassandra_hosts = []|" $LOCAL_CONFIG_PATH
3636
37for x in templates/*.cron.tmpl; do37for x in templates/*.cron.tmpl; do
38 export CODE_LOCATION DEPLOY_ROOT DUPLICATE_DB LOCAL_CONFIG_LOCATION USER_CODE_RUNNER VAR_DIR
38 n="$(echo "$(basename $x)" | sed 's/.cron.tmpl//')"39 n="$(echo "$(basename $x)" | sed 's/.cron.tmpl//')"
39 cheetah fill --env -p $x >/etc/cron.d/$n40 cheetah fill --env -p $x >/etc/cron.d/$n
40done41done
4142
=== modified file 'hooks/install'
--- hooks/install 2013-05-03 00:27:01 +0000
+++ hooks/install 2013-05-03 14:12:24 +0000
@@ -33,11 +33,7 @@
3333
34# Unpack tarred Daisy code34# Unpack tarred Daisy code
35charm_dir="$(pwd)"35charm_dir="$(pwd)"
36tarball="$charm_dir/files/daisy.tgz"36deploy_code "$charm_dir/files/daisy.tgz" $CODE_LOCATION $DAISY_CODE_DIRS
37
38if [ -f "$tarball" ]; then
39 tar -C "$CODE_LOCATION" -xvf "$tarball"
40fi
4137
42if [ ! -e "$LOCAL_CONFIG_PATH" ]; then38if [ ! -e "$LOCAL_CONFIG_PATH" ]; then
43 cp "$CODE_LOCATION/daisy/configuration.py" "$LOCAL_CONFIG_PATH"39 cp "$CODE_LOCATION/daisy/configuration.py" "$LOCAL_CONFIG_PATH"
@@ -45,10 +41,8 @@
4541
46# Unpack tarred Apport snapshot42# Unpack tarred Apport snapshot
47apport="$charm_dir/files/apport.tgz"43apport="$charm_dir/files/apport.tgz"
48
49if [ -f "$apport" ]; then44if [ -f "$apport" ]; then
50 tar -C "$APPORT_LOCATION" -xvf "$apport"45 deploy_code "$apport" $APPORT_LOCATION $APPORT_CODE_DIRS
51
52 # set up the apt/dpkg Apport packaging backend; setup.py build would need more46 # set up the apt/dpkg Apport packaging backend; setup.py build would need more
53 # dependencies47 # dependencies
54 cd "$APPORT_LOCATION"48 cd "$APPORT_LOCATION"
5549
=== modified file 'hooks/upgrade-charm'
--- hooks/upgrade-charm 2013-03-22 02:15:05 +0000
+++ hooks/upgrade-charm 2013-05-03 14:12:24 +0000
@@ -1,8 +1,17 @@
1#!/bin/bash1#!/bin/bash
2set -e2set -eux
3
4home=$(dirname $0)3home=$(dirname $0)
5juju-log "Upgrading charm by running install hook again."4
6$home/install5. hooks/common
7juju-log "Finishing charm upgrade by reconfiguring."6charm_dir="$(pwd)"
7deploy_code "$charm_dir/files/daisy.tgz" $CODE_LOCATION $DAISY_CODE_DIRS
8
9apport="$charm_dir/files/apport.tgz"
10if [ -f "$apport" ]; then
11 deploy_code "$apport" $APPORT_LOCATION $APPORT_CODE_DIRS
12 cd "$APPORT_LOCATION"
13 rm -f apport/packaging_impl.py
14 ln -s ../backends/packaging-apt-dpkg.py apport/packaging_impl.py
15fi
8$home/config-changed16$home/config-changed
17retracer_restart

Subscribers

People subscribed via source and target branches

to all changes: