Merge lp:~jtv/maas/q-pkg-bug-1086239 into lp:~maas-maintainers/maas/packaging.quantal

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 150
Proposed branch: lp:~jtv/maas/q-pkg-bug-1086239
Merge into: lp:~maas-maintainers/maas/packaging.quantal
Diff against target: 125 lines (+69/-10)
3 files modified
debian/changelog (+7/-1)
debian/maas-cluster-controller.maas-pserv.upstart (+16/-2)
debian/maas-cluster-controller.postinst (+46/-7)
To merge this branch: bzr merge lp:~jtv/maas/q-pkg-bug-1086239
Reviewer Review Type Date Requested Status
Scott Moser (community) Needs Fixing
Raphaël Badin (community) Approve
Review via email: mp+139388@code.launchpad.net

Commit message

Backport packaging r156: Duplicate CLUSTER_UUID into maas_cluster.conf.

Description of the change

This backports the fix for bug 1086239 into the Quantal packaging branch. The only tricky bit, from a merging perspective, was updating the version number to match the 1.2 revision it required in debian/changelog.

That is also the one reason why I'm putting this up for review: final sanity check.

Jeroen

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Looks good.

review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

I think there is a functional bug here. You are storing a value of CLUSTER_UUID in /etc/maas/maas_local_celeryconfig_cluster.py (line 86) formated like:
CLUSTER_UUID = '<value>'

However, reading that value will fail because you have a inconsistency between the regex given to sed and grep. Instead of outputing <value>, extract_cluster_uuid will output
  CLUSTER_UUID = '<value>'

The easiest solution I think is to just ditch the use of grep entirely and use 'sed -n'.

extract_cfg_value() {
   # extract the value for a variable named $1 from a
   # simplistic formatted shell or python file ($2)
   sed -n -e "s/^$1 *= *[\"']\{0,1\}\([^\"']*\).*/\1/p" "$2"
}
extract_cluster_uuid() { extract_cfg_value CLUSTER_UUID "$1"; }

review: Needs Fixing
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Good point. The problem doesn't actually happen in practice, so it may not be worth a further precise/quantal change, but it would be nicer to unify the regexes. I tried to stay away from any sed cleverness I could avoid — portability habits! — but it makes sense here.

Revision history for this message
Scott Moser (smoser) wrote :

On Wed, 12 Dec 2012, Jeroen T. Vermeulen wrote:

> Good point. The problem doesn't actually happen in practice, so it may not be worth a further precise/quantal change, but it would be nicer to unify the regexes. I tried to stay away from any sed cleverness I could avoid — portability habits! — but it makes sense here.

'sed -n' is probably pretty portable.
http://pubs.opengroup.org/onlinepubs/009695399/utilities/sed.html

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Registered that as bug 1089508.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-12-04 16:16:39 +0000
3+++ debian/changelog 2012-12-12 07:00:27 +0000
4@@ -1,4 +1,4 @@
5-maas (0.1+bzr1325+dfsg-0ubuntu1) UNRELEASED; urgency=low
6+maas (0.1+bzr1335+dfsg-0ubuntu1) UNRELEASED; urgency=low
7
8 * New upstream bugfix release. Fixes:
9 - The DNS configuration is not created if maas-dns is installed after
10@@ -54,6 +54,12 @@
11 * debian/maas-cluster-controller.install: maas-import-squashfs and its
12 configuration file are no longer part of upstream.
13
14+ [ Jeroen Vermeulen ]
15+ * debian/maas-cluster-controller.maas-pserv.upstart: Source maas_cluster.conf
16+ before starting pserv (tftpd) process.
17+ * debian/maas-cluster-controller.postinst: Duplicate CLUSTER_UUID setting
18+ to maas_cluster.conf.
19+
20 -- Andres Rodriguez <andreserl@ubuntu.com> Tue, 13 Nov 2012 14:58:21 -0500
21
22 maas (0.1+bzr1269+dfsg-0ubuntu1) quantal-proposed; urgency=low
23
24=== modified file 'debian/maas-cluster-controller.maas-pserv.upstart'
25--- debian/maas-cluster-controller.maas-pserv.upstart 2012-09-25 08:02:30 +0000
26+++ debian/maas-cluster-controller.maas-pserv.upstart 2012-12-12 07:00:27 +0000
27@@ -10,5 +10,19 @@
28
29 respawn
30
31-# To add options to your daemon, edit the line below:
32-exec /usr/bin/twistd -n --uid=maas --gid=maas --pidfile=/run/maas-pserv.pid --logfile=/dev/null maas-pserv --config-file=/etc/maas/pserv.yaml
33+env CONFIG_FILE=/etc/maas/maas_cluster.conf
34+
35+pre-start script
36+ if [ ! -f $CONFIG_FILE ]; then
37+ echo "$CONFIG_FILE does not exist. Aborting."
38+ stop
39+ exit 0
40+ fi
41+end script
42+
43+script
44+ # Prepare settings.
45+ . $CONFIG_FILE
46+ # To add options to your daemon, edit the line below:
47+ exec /usr/bin/twistd -n --uid=maas --gid=maas --pidfile=/run/maas-pserv.pid --logfile=/dev/null maas-pserv --config-file=/etc/maas/pserv.yaml
48+end script
49
50=== modified file 'debian/maas-cluster-controller.postinst'
51--- debian/maas-cluster-controller.postinst 2012-11-29 02:28:40 +0000
52+++ debian/maas-cluster-controller.postinst 2012-12-12 07:00:27 +0000
53@@ -26,6 +26,48 @@
54 ln -sf /var/lib/maas/ephemeral/tgt.conf /etc/tgt/conf.d/maas.conf
55 }
56
57+extract_cluster_uuid(){
58+ # Extract ClUSTER_UUID setting from config file $1. This will work
59+ # both the cluster celery config (which is python) and the cluster
60+ # config (which is shell).
61+ local config_file="$1"
62+ grep "^CLUSTER_UUID *= *[\"'][^\"']*[\"']" $config_file |
63+ sed -e "s/^CLUSTER_UUID *= *\"\([^\"']*\)\".*/\1/"
64+}
65+
66+configure_cluster_uuid(){
67+ # The cluster uuid goes into maas_cluster.conf, but we also still
68+ # keep a copy in maas_local_celeryconfig_cluster.py (hopefully just
69+ # temporarily). If an old uuid is configured, we replicate that to
70+ # maas_cluster.conf; otherwise, we want to generate one.
71+ local uuid
72+
73+
74+ if [ -n "$(extract_cluster_uuid /etc/maas/maas_cluster.conf)" ]; then
75+ # UUID is already set up. Wonderful.
76+ return
77+ fi
78+
79+ # Look for a UUID stored in the old location.
80+ uuid="$(extract_cluster_uuid /etc/maas/maas_local_celeryconfig_cluster.py)"
81+
82+ if [ -z "$uuid" ]; then
83+ # No UUID at all yet. Generate one, and insert it into its
84+ # placeholder in the old config location.
85+ uuid="$(uuidgen)"
86+ sed -i "s|^CLUSTER_UUID = None$|CLUSTER_UUID = '$uuid'|" \
87+ /etc/maas/maas_local_celeryconfig_cluster.py
88+ fi
89+
90+ # Either way, at this point we have a uuid, and it is configured in
91+ # the old config location.
92+ #
93+ # Write it to maas_cluster.conf as well. There is no initial
94+ # placeholder in this file, so just append the setting.
95+ echo "CLUSTER_UUID=\"$uuid\"" >>/etc/maas/maas_cluster.conf
96+}
97+
98+
99 if [ "$1" = "configure" ] && [ -z "$2" ]; then
100 # logging
101 create_log_dir
102@@ -35,13 +77,6 @@
103 chown root:maas /etc/maas/maas_local_celeryconfig_cluster.py
104 chmod 0640 /etc/maas/maas_local_celeryconfig_cluster.py
105
106- # Generate cluster UUID.
107- if grep -qs "^CLUSTER_UUID\ \= None$" /etc/maas/maas_local_celeryconfig_cluster.py; then
108- uuid="$(uuidgen)"
109- sed -i "s|^CLUSTER_UUID\ \= None$|CLUSTER_UUID = '"$uuid"'|" \
110- /etc/maas/maas_local_celeryconfig_cluster.py
111- fi
112-
113 configure_maas_tgt
114 fi
115
116@@ -63,5 +98,9 @@
117 fi
118 fi
119
120+if [ "$1" = "configure" ]; then
121+ configure_cluster_uuid
122+fi
123+
124 #DEBHELPER#
125 exit 0

Subscribers

People subscribed via source and target branches