Merge lp:~chad.smith/charms/precise/openstack-dashboard/ha-support-with-health into lp:~openstack-charmers/charms/precise/openstack-dashboard/ha-support

Proposed by Chad Smith
Status: Merged
Merged at revision: 26
Proposed branch: lp:~chad.smith/charms/precise/openstack-dashboard/ha-support-with-health
Merge into: lp:~openstack-charmers/charms/precise/openstack-dashboard/ha-support
Diff against target: 149 lines (+95/-0) (has conflicts)
8 files modified
hooks/horizon-relations (+8/-0)
hooks/lib/openstack-common (+37/-0)
revision (+4/-0)
scripts/add_to_cluster (+2/-0)
scripts/health_checks.d/service_ports_live (+13/-0)
scripts/health_checks.d/service_running (+13/-0)
scripts/health_checks.d/service_url_checks (+16/-0)
scripts/remove_from_cluster (+2/-0)
Text conflict in revision
To merge this branch: bzr merge lp:~chad.smith/charms/precise/openstack-dashboard/ha-support-with-health
Reviewer Review Type Date Requested Status
James Page Pending
Review via email: mp+150845@code.launchpad.net

Description of the change

 This branch adds add_to_cluster, remove_from_cluster and health_scripts.d to the openstack-dashboard charm. Since this charms uses a bash openstack-common lib of functions, implementation is slightly different from the python-based openstack_common.py changes. This change set is in the same vein as the keystone-ha python-based changs to openstack_common.py https://code.launchpad.net/~chad.smith/charms/precise/keystone/ha-support/+merge/150137.

Charms can provide as many custom run-parts health scripts (returning success/fail exit codes) as they desire and those scripts can be provided any necessary environment variables from a config_changed hook. In this example, I placed the standard service_running and service_ports_live plus a silly additional script to check that a wget against horizon's $web_root returns something viable.

Hopefully this gives us a minimum acceptable template for openstack HA-related charms. Landscape-client will depend on these script locations to successfully perform openstack rolling upgrades.

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

more strict netstat port matching

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/horizon-relations'
2--- hooks/horizon-relations 2013-02-14 15:19:04 +0000
3+++ hooks/horizon-relations 2013-03-05 22:17:20 +0000
4@@ -79,6 +79,14 @@
5 set_or_update LOGIN_URL "$web_root/auth/login"
6 set_or_update LOGIN_REDIRECT_URL "$web_root"
7
8+ # Save our scriptrc env variables for health checks
9+ declare -a env_vars=(
10+ 'OPENSTACK_URL_HORIZON="http://localhost'$web_root'|Login+-+OpenStack"'
11+ 'OPENSTACK_SERVICE_HORIZON=apache2'
12+ 'OPENSTACK_PORT_HORIZON=80')
13+ save_script_rc ${env_vars[@]}
14+
15+
16 # Set default role and trigger a identity-service relation event to
17 # ensure role is created in keystone.
18 set_or_update OPENSTACK_KEYSTONE_DEFAULT_ROLE "$(config-get default-role)"
19
20=== modified file 'hooks/lib/openstack-common'
21--- hooks/lib/openstack-common 2013-03-05 17:25:32 +0000
22+++ hooks/lib/openstack-common 2013-03-05 22:17:20 +0000
23@@ -319,6 +319,43 @@
24 return 0
25 }
26
27+##########################################################################
28+# Description: Creates an rc file exporting environment variables to a
29+# script_path local to the charm's installed directory.
30+# Any charm scripts run outside the juju hook environment can source this
31+# scriptrc to obtain updated config information necessary to perform health
32+# checks or service changes
33+#
34+# Parameters:
35+# An array of '=' delimited ENV_VAR:value combinations to export.
36+# If optional script_path key is not provided in the array, script_path
37+# defaults to scripts/scriptrc
38+##########################################################################
39+function save_script_rc {
40+ if [ ! -n "$JUJU_UNIT_NAME" ]; then
41+ echo "Error: Missing JUJU_UNIT_NAME environment variable"
42+ exit 1
43+ fi
44+ # our default unit_path
45+ unit_path="/var/lib/juju/units/${JUJU_UNIT_NAME/\//-}/charm/scripts/scriptrc"
46+ echo $unit_path
47+ tmp_rc="/tmp/${JUJU_UNIT_NAME/\//-}rc"
48+
49+ echo "#!/bin/bash" > $tmp_rc
50+ for env_var in "${@}"
51+ do
52+ if `echo $env_var | grep -q script_path`; then
53+ # well then we need to reset the new unit-local script path
54+ unit_path="/var/lib/juju/units/${JUJU_UNIT_NAME/\//-}/charm/${env_var/script_path=/}"
55+ else
56+ echo "export $env_var" >> $tmp_rc
57+ fi
58+ done
59+ chmod 755 $tmp_rc
60+ mv $tmp_rc $unit_path
61+}
62+
63+
64 HAPROXY_CFG=/etc/haproxy/haproxy.cfg
65 HAPROXY_DEFAULT=/etc/default/haproxy
66
67
68=== modified file 'revision'
69--- revision 2013-03-05 17:25:32 +0000
70+++ revision 2013-03-05 22:17:20 +0000
71@@ -1,1 +1,5 @@
72+<<<<<<< TREE
73 24
74+=======
75+23
76+>>>>>>> MERGE-SOURCE
77
78=== added directory 'scripts'
79=== added file 'scripts/add_to_cluster'
80--- scripts/add_to_cluster 1970-01-01 00:00:00 +0000
81+++ scripts/add_to_cluster 2013-03-05 22:17:20 +0000
82@@ -0,0 +1,2 @@
83+#!/bin/bash
84+crm node online
85
86=== added directory 'scripts/health_checks.d'
87=== added file 'scripts/health_checks.d/service_ports_live'
88--- scripts/health_checks.d/service_ports_live 1970-01-01 00:00:00 +0000
89+++ scripts/health_checks.d/service_ports_live 2013-03-05 22:17:20 +0000
90@@ -0,0 +1,13 @@
91+#!/bin/bash
92+# Validate that service ports are active
93+HEALTH_DIR=`dirname $0`
94+SCRIPTS_DIR=`dirname $HEALTH_DIR`
95+. $SCRIPTS_DIR/scriptrc
96+set -e
97+
98+# Grab any OPENSTACK_PORT* environment variables
99+openstack_ports=`env| awk -F '=' '(/OPENSTACK_PORT/){print $2}'`
100+for port in $openstack_ports
101+do
102+ netstat -ln | grep -q ":$port "
103+done
104
105=== added file 'scripts/health_checks.d/service_running'
106--- scripts/health_checks.d/service_running 1970-01-01 00:00:00 +0000
107+++ scripts/health_checks.d/service_running 2013-03-05 22:17:20 +0000
108@@ -0,0 +1,13 @@
109+#!/bin/bash
110+# Validate that service is running
111+HEALTH_DIR=`dirname $0`
112+SCRIPTS_DIR=`dirname $HEALTH_DIR`
113+. $SCRIPTS_DIR/scriptrc
114+set -e
115+
116+# Grab any OPENSTACK_SERVICE* environment variables
117+openstack_service_names=`env| awk -F '=' '(/OPENSTACK_SERVICE/){print $2}'`
118+for service_name in $openstack_service_names
119+do
120+ service $service_name status 2>/dev/null | grep -q running
121+done
122
123=== added file 'scripts/health_checks.d/service_url_checks'
124--- scripts/health_checks.d/service_url_checks 1970-01-01 00:00:00 +0000
125+++ scripts/health_checks.d/service_url_checks 2013-03-05 22:17:20 +0000
126@@ -0,0 +1,16 @@
127+#!/bin/bash
128+# Validate that service urls return expected content
129+HEALTH_DIR=`dirname $0`
130+SCRIPTS_DIR=`dirname $HEALTH_DIR`
131+. $SCRIPTS_DIR/scriptrc
132+set -e
133+
134+# Grab any OPENSTACK_URL* environment variables and validate content response
135+openstack_urls=`env| awk -F '=' '(/OPENSTACK_URL/){print $2 }'`
136+for url_check in $openstack_urls
137+do
138+ url=`echo $url_check| awk -F '|' '{print $1}'`
139+ expected_content=`echo $url_check| awk -F '|' '{print $2}'`
140+ wget -q -O - $url | grep -q "${expected_content//+/ }"
141+done
142+
143
144=== added file 'scripts/remove_from_cluster'
145--- scripts/remove_from_cluster 1970-01-01 00:00:00 +0000
146+++ scripts/remove_from_cluster 2013-03-05 22:17:20 +0000
147@@ -0,0 +1,2 @@
148+#!/bin/bash
149+crm node standby

Subscribers

People subscribed via source and target branches