Merge lp:~chad.smith/charms/precise/swift-proxy/swift-proxy-ha-with-health into lp:~james-page/charms/precise/swift-proxy/ha-support

Proposed by Chad Smith
Status: Superseded
Proposed branch: lp:~chad.smith/charms/precise/swift-proxy/swift-proxy-ha-with-health
Merge into: lp:~james-page/charms/precise/swift-proxy/ha-support
Diff against target: 121 lines (+75/-1)
7 files modified
hooks/lib/openstack_common.py (+37/-0)
hooks/swift_utils.py (+5/-0)
revision (+1/-1)
scripts/add_to_cluster (+2/-0)
scripts/health_checks.d/service_ports_live (+13/-0)
scripts/health_checks.d/service_swift_running (+15/-0)
scripts/remove_from_cluster (+2/-0)
To merge this branch: bzr merge lp:~chad.smith/charms/precise/swift-proxy/swift-proxy-ha-with-health
Reviewer Review Type Date Requested Status
Adam Gandelman Pending
James Page Pending
Review via email: mp+151335@code.launchpad.net

This proposal has been superseded by a proposal from 2013-03-06.

Description of the change

This is a merge proposal to establish a potential template for health_script.d, add_to_cluster and remove_from_cluster delivery within the ha-supported openstack charms. The *cluster* simple scripts will be common on each charm that uses corosync configs. The health_scripts.d dir will contain some common scripts and some additional scripts that are appropriate health checks for the specific service.

The basic architecture we are hoping for is an extendable set of run-parts scripts in health_checks.d that can be seeded with juju config environment variables written into a /var/lib/juju/units/<charm_name>/charm/scripts/scriptrc file. Landscape client will do the work of calling these scripts and validating charm service health during openstack service upgrades. Both Jerry and I are tackling the initial push to add health/cluster scripts to the charms. Hopefully the model works and we can iterate on extending health or cluster scripts as service HA configuration gets more complex.

much thanks for the review.

To post a comment you must log in.
42. By Chad Smith

more strict netstat port matching

43. By Chad Smith

merge lp:~openstack-charmers/charms/precise/swift-proxy/ha-support resolve conflict

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/lib/openstack_common.py'
--- hooks/lib/openstack_common.py 2013-03-01 23:20:05 +0000
+++ hooks/lib/openstack_common.py 2013-03-06 22:26:24 +0000
@@ -224,3 +224,40 @@
224 f.write(src)224 f.write(src)
225 else:225 else:
226 error_out("Invalid openstack-release specified: %s" % rel)226 error_out("Invalid openstack-release specified: %s" % rel)
227
228HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
229HAPROXY_DEFAULT = '/etc/default/haproxy'
230
231def configure_haproxy(units, service_ports, template_dir=None):
232 template_dir = template_dir or 'templates'
233 import jinja2
234 context = {
235 'units': units,
236 'service_ports': service_ports
237 }
238 templates = jinja2.Environment(
239 loader=jinja2.FileSystemLoader(template_dir)
240 )
241 template = templates.get_template(
242 os.path.basename(HAPROXY_CONF)
243 )
244 with open(HAPROXY_CONF, 'w') as f:
245 f.write(template.render(context))
246 with open(HAPROXY_DEFAULT, 'w') as f:
247 f.write('ENABLED=1')
248
249def save_script_rc(script_path="scripts/scriptrc", **env_vars):
250 """
251 Write an rc file in the charm-delivered directory containing
252 exported environment variables provided by env_vars. Any charm scripts run
253 outside the juju hook environment can source this scriptrc to obtain
254 updated config information necessary to perform health checks or
255 service changes.
256 """
257 unit_name = os.getenv('JUJU_UNIT_NAME').replace('/', '-')
258 juju_rc_path="/var/lib/juju/units/%s/charm/%s" % (unit_name, script_path)
259 with open(juju_rc_path, 'wb') as rc_script:
260 rc_script.write(
261 "#!/bin/bash\n")
262 [rc_script.write('export %s=%s\n' % (u, p))
263 for u, p in env_vars.iteritems() if u != "script_path"]
227264
=== modified file 'hooks/swift_utils.py'
--- hooks/swift_utils.py 2013-03-04 14:43:54 +0000
+++ hooks/swift_utils.py 2013-03-06 22:26:24 +0000
@@ -171,6 +171,11 @@
171 import multiprocessing171 import multiprocessing
172 workers = multiprocessing.cpu_count()172 workers = multiprocessing.cpu_count()
173173
174 env_vars = {'OPENSTACK_SERVICE_SWIFT': 'proxy-server',
175 'OPENSTACK_PORT_API': bind_port,
176 'OPENSTACK_PORT_MEMCACHED': 11211}
177 openstack.save_script_rc(**env_vars)
178
174 ctxt = {179 ctxt = {
175 'proxy_ip': utils.get_host_ip(),180 'proxy_ip': utils.get_host_ip(),
176 'bind_port': utils.determine_api_port(bind_port),181 'bind_port': utils.determine_api_port(bind_port),
177182
=== modified file 'revision'
--- revision 2013-01-29 00:41:52 +0000
+++ revision 2013-03-06 22:26:24 +0000
@@ -1,1 +1,1 @@
11091110
22
=== added directory 'scripts'
=== added file 'scripts/add_to_cluster'
--- scripts/add_to_cluster 1970-01-01 00:00:00 +0000
+++ scripts/add_to_cluster 2013-03-06 22:26:24 +0000
@@ -0,0 +1,2 @@
1#!/bin/bash
2crm node online
03
=== added directory 'scripts/health_checks.d'
=== added file 'scripts/health_checks.d/service_ports_live'
--- scripts/health_checks.d/service_ports_live 1970-01-01 00:00:00 +0000
+++ scripts/health_checks.d/service_ports_live 2013-03-06 22:26:24 +0000
@@ -0,0 +1,13 @@
1#!/bin/bash
2# Validate that service ports are active
3HEALTH_DIR=`dirname $0`
4SCRIPTS_DIR=`dirname $HEALTH_DIR`
5. $SCRIPTS_DIR/scriptrc
6set -e
7
8# Grab any OPENSTACK_PORT* environment variables
9openstack_ports=`env| awk -F '=' '(/OPENSTACK_PORT/){print $2}'`
10for port in $openstack_ports
11do
12 netstat -ln | grep -q ":$port "
13done
014
=== added file 'scripts/health_checks.d/service_swift_running'
--- scripts/health_checks.d/service_swift_running 1970-01-01 00:00:00 +0000
+++ scripts/health_checks.d/service_swift_running 2013-03-06 22:26:24 +0000
@@ -0,0 +1,15 @@
1#!/bin/bash
2# Validate that service is running
3HEALTH_DIR=`dirname $0`
4SCRIPTS_DIR=`dirname $HEALTH_DIR`
5. $SCRIPTS_DIR/scriptrc
6set -e
7
8# Grab any OPENSTACK_SWIFT_SERVICE* environment variables
9openstack_service_names=`env| awk -F '=' '(/OPENSTACK_SWIFT_SERVICE/){print $2}'`
10for service_name in $openstack_service_names
11do
12 # Double-negative: we want to ensure swift-init does not return
13 # 'No <service_name> running'
14 swift-init $service_name status 2>/dev/null | grep -vq "No $service_name running"
15done
016
=== added file 'scripts/remove_from_cluster'
--- scripts/remove_from_cluster 1970-01-01 00:00:00 +0000
+++ scripts/remove_from_cluster 2013-03-06 22:26:24 +0000
@@ -0,0 +1,2 @@
1#!/bin/bash
2crm node standby

Subscribers

People subscribed via source and target branches

to all changes: