Merge lp:~chad.smith/charms/precise/ceph/ceph-with-health into lp:~charmers/charms/precise/ceph/trunk

Proposed by Chad Smith
Status: Rejected
Rejected by: James Page
Proposed branch: lp:~chad.smith/charms/precise/ceph/ceph-with-health
Merge into: lp:~charmers/charms/precise/ceph/trunk
Diff against target: 85 lines (+49/-1)
5 files modified
hooks/hooks.py (+4/-0)
hooks/utils.py (+16/-0)
revision (+1/-1)
scripts/health_checks.d/script_checks (+15/-0)
scripts/health_checks.d/service_ports_live (+13/-0)
To merge this branch: bzr merge lp:~chad.smith/charms/precise/ceph/ceph-with-health
Reviewer Review Type Date Requested Status
Adam Gandelman (community) Approve
James Page Pending
Review via email: mp+151338@code.launchpad.net

Description of the change

In the same line as all other openstack services, this branch delivers health_script.d for that will allow landscape-client to validate the local openstack service health during an openstack rolling upgrade.

 Other charms are delivering run-parts health scripts at /var/lib/juju/units/<charm_name>/charm/scripts/health_check.d so landscape client can validate charm service health outside of the juju hooks environment. To support this effort the charm will need to write a /var/lib/juju/units/<charm_name>/charm/scripts/scriptrc file which can establish script environment variables which provide necessary ports, service names or commands for the health_checks.d scripts to run.

ceph service will only be delivering health_checks.d and not add_to_cluster and remove_from_cluster scripts because ceph service is inherently HA and doesn't use corosync services like some of the other charms. If we need to disable a ceph node from within the cluster, or stop rings from rebuilding/rebalancing during a unit reboot, we may have to introduce remove_from_cluster add_to_cluster scripts as entry points for those actions.

To post a comment you must log in.
Revision history for this message
Chad Smith (chad.smith) wrote :

a question I have on ceph is that I see a number of other ports for ceph-mon and ceph-osd on our ceph units, but I don't see where those ports are configured for ceph. I'd like to monitor the other active ceph ports, but not sure if we should hardcode those port numbers.

root@inst-012:~# netstat -lnp | grep ceph
tcp 0 0 0.0.0.0:6802 0.0.0.0:* LISTEN 4708/ceph-osd
tcp 0 0 192.168.64.154:6789 0.0.0.0:* LISTEN 4473/ceph-mon
tcp 0 0 0.0.0.0:6800 0.0.0.0:* LISTEN 4708/ceph-osd
tcp 0 0 0.0.0.0:6801 0.0.0.0:* LISTEN 4708/ceph-osd

Revision history for this message
Adam Gandelman (gandelman-a) wrote :

Retargetted and merged against lp:~openstack-charmers/charms/precise/swift-storage/ha-support which contains the most recent common code and will let us track this against the other WIP charms focusing on these features.

review: Approve
Revision history for this message
Chad Smith (chad.smith) wrote :

Adam's comment above was accidentally made on the ceph branch but it really applies to the swift-storage-with-health branch... copying comment to lp:~chad.smith/charms/precise/swift-storage/swift-storage-with-health and "Merging" that branch. Reopening this branch as it is not in the ceph upstream code yet.

Revision history for this message
James Page (james-page) wrote :

Chad

TBH monitoring OSD health would be better done using ceph itself: ceph osd tree give you a hierarchical view of the ODS healty.

Unmerged revisions

64. By Chad Smith

more strict netstat port matching

63. By Chad Smith

update revision

62. By Chad Smith

missing comma

61. By Chad Smith

charm health scripts for landscape-client on ceph

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2013-01-11 09:10:40 +0000
+++ hooks/hooks.py 2013-03-05 22:19:22 +0000
@@ -92,6 +92,10 @@
92 if ceph.is_bootstrapped():92 if ceph.is_bootstrapped():
93 ceph.rescan_osd_devices()93 ceph.rescan_osd_devices()
9494
95 env_vars = {
96 'OPENSTACK_SCRIPT_CEPH_STAT': '"ceph status | grep -q HEALTH_OK"',
97 'OPENSTACK_PORT_CEPH_MON': 6789}
98 utils.save_script_rc(**env_vars)
95 utils.juju_log('INFO', 'End config-changed hook.')99 utils.juju_log('INFO', 'End config-changed hook.')
96100
97101
98102
=== modified file 'hooks/utils.py'
--- hooks/utils.py 2013-02-08 11:09:00 +0000
+++ hooks/utils.py 2013-03-05 22:19:22 +0000
@@ -218,3 +218,19 @@
218 answers = dns.resolver.query(hostname, 'A')218 answers = dns.resolver.query(hostname, 'A')
219 if answers:219 if answers:
220 return answers[0].address220 return answers[0].address
221
222def save_script_rc(script_path="scripts/scriptrc", **env_vars):
223 """
224 Write an rc file in the charm-delivered directory containing
225 exported environment variables provided by env_vars. Any charm scripts run
226 outside the juju hook environment can source this scriptrc to obtain
227 updated config information necessary to perform health checks or
228 service changes.
229 """
230 unit_name = os.getenv('JUJU_UNIT_NAME').replace('/', '-')
231 juju_rc_path="/var/lib/juju/units/%s/charm/%s" % (unit_name, script_path)
232 with open(juju_rc_path, 'wb') as rc_script:
233 rc_script.write(
234 "#!/bin/bash\n")
235 [rc_script.write('export %s=%s\n' % (u, p))
236 for u, p in env_vars.iteritems() if u != "script_path"]
221237
=== modified file 'revision'
--- revision 2012-12-17 10:22:51 +0000
+++ revision 2013-03-05 22:19:22 +0000
@@ -1,1 +1,1 @@
191193
22
=== added directory 'scripts'
=== added directory 'scripts/health_checks.d'
=== added file 'scripts/health_checks.d/script_checks'
--- scripts/health_checks.d/script_checks 1970-01-01 00:00:00 +0000
+++ scripts/health_checks.d/script_checks 2013-03-05 22:19:22 +0000
@@ -0,0 +1,15 @@
1#!/usr/bin/python
2# Run any commands given as an OPENSTACK_SCRIPT environment variable
3import os, sys, subprocess
4
5# Pull any environment variable definitions out of the charm's scriptrc
6scriptrc= "%s/scriptrc" % os.path.dirname(os.path.dirname(sys.argv[0]))
7
8for line in open(scriptrc):
9 if line.startswith("export OPENSTACK_SCRIPT"):
10 # drop any bookend whitespace and double-quotes
11 command = line.split("=")[1].strip().strip('"')
12 p = subprocess.Popen('%s' % command, shell=True)
13 exitcode = p.wait()
14 if exitcode != 0:
15 exit(exitcode)
016
=== 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-05 22:19:22 +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

Subscribers

People subscribed via source and target branches

to all changes: