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
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2013-01-11 09:10:40 +0000
3+++ hooks/hooks.py 2013-03-05 22:19:22 +0000
4@@ -92,6 +92,10 @@
5 if ceph.is_bootstrapped():
6 ceph.rescan_osd_devices()
7
8+ env_vars = {
9+ 'OPENSTACK_SCRIPT_CEPH_STAT': '"ceph status | grep -q HEALTH_OK"',
10+ 'OPENSTACK_PORT_CEPH_MON': 6789}
11+ utils.save_script_rc(**env_vars)
12 utils.juju_log('INFO', 'End config-changed hook.')
13
14
15
16=== modified file 'hooks/utils.py'
17--- hooks/utils.py 2013-02-08 11:09:00 +0000
18+++ hooks/utils.py 2013-03-05 22:19:22 +0000
19@@ -218,3 +218,19 @@
20 answers = dns.resolver.query(hostname, 'A')
21 if answers:
22 return answers[0].address
23+
24+def save_script_rc(script_path="scripts/scriptrc", **env_vars):
25+ """
26+ Write an rc file in the charm-delivered directory containing
27+ exported environment variables provided by env_vars. Any charm scripts run
28+ outside the juju hook environment can source this scriptrc to obtain
29+ updated config information necessary to perform health checks or
30+ service changes.
31+ """
32+ unit_name = os.getenv('JUJU_UNIT_NAME').replace('/', '-')
33+ juju_rc_path="/var/lib/juju/units/%s/charm/%s" % (unit_name, script_path)
34+ with open(juju_rc_path, 'wb') as rc_script:
35+ rc_script.write(
36+ "#!/bin/bash\n")
37+ [rc_script.write('export %s=%s\n' % (u, p))
38+ for u, p in env_vars.iteritems() if u != "script_path"]
39
40=== modified file 'revision'
41--- revision 2012-12-17 10:22:51 +0000
42+++ revision 2013-03-05 22:19:22 +0000
43@@ -1,1 +1,1 @@
44-91
45+93
46
47=== added directory 'scripts'
48=== added directory 'scripts/health_checks.d'
49=== added file 'scripts/health_checks.d/script_checks'
50--- scripts/health_checks.d/script_checks 1970-01-01 00:00:00 +0000
51+++ scripts/health_checks.d/script_checks 2013-03-05 22:19:22 +0000
52@@ -0,0 +1,15 @@
53+#!/usr/bin/python
54+# Run any commands given as an OPENSTACK_SCRIPT environment variable
55+import os, sys, subprocess
56+
57+# Pull any environment variable definitions out of the charm's scriptrc
58+scriptrc= "%s/scriptrc" % os.path.dirname(os.path.dirname(sys.argv[0]))
59+
60+for line in open(scriptrc):
61+ if line.startswith("export OPENSTACK_SCRIPT"):
62+ # drop any bookend whitespace and double-quotes
63+ command = line.split("=")[1].strip().strip('"')
64+ p = subprocess.Popen('%s' % command, shell=True)
65+ exitcode = p.wait()
66+ if exitcode != 0:
67+ exit(exitcode)
68
69=== added file 'scripts/health_checks.d/service_ports_live'
70--- scripts/health_checks.d/service_ports_live 1970-01-01 00:00:00 +0000
71+++ scripts/health_checks.d/service_ports_live 2013-03-05 22:19:22 +0000
72@@ -0,0 +1,13 @@
73+#!/bin/bash
74+# Validate that service ports are active
75+HEALTH_DIR=`dirname $0`
76+SCRIPTS_DIR=`dirname $HEALTH_DIR`
77+. $SCRIPTS_DIR/scriptrc
78+set -e
79+
80+# Grab any OPENSTACK_PORT* environment variables
81+openstack_ports=`env| awk -F '=' '(/OPENSTACK_PORT/){print $2}'`
82+for port in $openstack_ports
83+do
84+ netstat -ln | grep -q ":$port "
85+done

Subscribers

People subscribed via source and target branches

to all changes: