Merge lp:~jacekn/charms/precise/haproxy/haproxy-stats-socket into lp:charms/haproxy

Proposed by Jacek Nykis
Status: Work in progress
Proposed branch: lp:~jacekn/charms/precise/haproxy/haproxy-stats-socket
Merge into: lp:charms/haproxy
Diff against target: 132 lines (+39/-3)
4 files modified
README.md (+1/-1)
config.yaml (+18/-0)
hooks/hooks.py (+12/-2)
hooks/tests/test_helpers.py (+8/-0)
To merge this branch: bzr merge lp:~jacekn/charms/precise/haproxy/haproxy-stats-socket
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Needs Fixing
Review via email: mp+207263@code.launchpad.net

Description of the change

* add support for stats socket including specifying access level
* add new "install_hatop" config option

This MP includes changes from here:
https://code.launchpad.net/~aglenyoung/charms/precise/haproxy/haproxy-stats-socket/+merge/201980

To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

The unit tests fail for me:

$ make test

http://paste.ubuntu.com/7033134/

Lint fails with the following:

Checking for Python syntax...
/tmp/precise/haproxy/hooks/hooks.py:638:62: E901 SyntaxError: invalid token
/tmp/precise/haproxy/hooks/tests/utils_for_tests.py:13:32: F821 undefined name 'file'
make: *** [lint] Error 1

Once these have been addressed and you're ready for another review make sure to "Request another review" from "charmers" to have it placed back in the queue. Thanks!

review: Needs Fixing
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

I've moved this to work in progress. If it's still valid feel free to move it to Needs Review after updates, if you need to remove this please move the merge to either Rejected or antoher similar status.

Unmerged revisions

81. By Jacek Nykis

Fixed small bug when using global_stats_socket_level

80. By Jacek Nykis

Added install_hatop config option

79. By Jacek Nykis

Added global_stats_socket_level option to allow restricted socket creation

78. By Jacek Nykis

Merged Andrew's haproxy stats socket changes

77. By Jacek Nykis

Merged Andres changes to fix test linting errors and update README with additional required packages to run the test suite.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2014-01-07 19:03:41 +0000
3+++ README.md 2014-02-19 17:52:19 +0000
4@@ -97,7 +97,7 @@
5 sudo apt-get install python-software-properties
6 sudo add-apt-repository ppa:cjohnston/flake8
7 sudo apt-get update
8- sudo apt-get install python-mock python-flake8 python-nose python-nosexcover
9+ sudo apt-get install python-mock python-flake8 python-nose python-nosexcover python-testtools charm-tools
10
11 To run the tests:
12
13
14=== modified file 'config.yaml'
15--- config.yaml 2014-01-07 18:44:15 +0000
16+++ config.yaml 2014-02-19 17:52:19 +0000
17@@ -34,6 +34,17 @@
18 the same physical server. With the help of this parameter, it becomes
19 possible to add some randomness in the check interval between 0 and
20 +/- 50%. A value between 2 and 5 seems to show good results.
21+ global_stats_socket:
22+ default: False
23+ type: boolean
24+ description: |
25+ Whether to enable the stats UNIX socket.
26+ global_stats_socket_level:
27+ default: "user"
28+ type: string
29+ description: |
30+ Privilege level for the stats socket. Only used if global_stats_socket
31+ is set to True. Accepted values are: "user", "operator" and "admin".
32 default_log:
33 default: "global"
34 type: string
35@@ -90,6 +101,13 @@
36 default: 3
37 type: int
38 description: Monitoring interface refresh interval (in seconds)
39+ install_hatop:
40+ default: False
41+ type: boolean
42+ description: |
43+ If set to True hatop package will be installed. The package requires
44+ stats socket, see global_stats_socket and global_stats_socket_level
45+ options for details
46 package_status:
47 default: "install"
48 type: "string"
49
50=== modified file 'hooks/hooks.py'
51--- hooks/hooks.py 2014-01-21 15:46:29 +0000
52+++ hooks/hooks.py 2014-02-19 17:52:19 +0000
53@@ -25,7 +25,7 @@
54 close_port,
55 unit_get,
56 )
57-from charmhelpers.fetch import apt_install
58+from charmhelpers.fetch import apt_install, apt_purge
59 from charmhelpers.contrib.charmsupport import nrpe
60
61
62@@ -125,6 +125,13 @@
63 haproxy_globals.append(" quiet")
64 haproxy_globals.append(" spread-checks %d" %
65 config_data['global_spread_checks'])
66+ if config_data['global_stats_socket'] is True:
67+ sock_path = "/var/run/haproxy/haproxy.sock"
68+ socket_level = config_data['global_stats_socket_level']
69+ if socket_level not in ["user", "operator", "admin"]:
70+ socket_level = "user"
71+ haproxy_globals.append(" stats socket %s mode 0600 level %s" % (
72+ sock_path, socket_level))
73 return '\n'.join(haproxy_globals)
74
75
76@@ -765,7 +772,10 @@
77 haproxy_defaults,
78 haproxy_monitoring,
79 haproxy_services)
80-
81+ if config_data['install_hatop'] is True:
82+ apt_install('hatop', fatal=True)
83+ else:
84+ apt_purge('hatop', fatal=True)
85 if service_haproxy("check"):
86 update_service_ports(old_service_ports, get_service_ports())
87 service_haproxy("reload")
88
89=== modified file 'hooks/tests/test_helpers.py'
90--- hooks/tests/test_helpers.py 2013-12-17 16:00:29 +0000
91+++ hooks/tests/test_helpers.py 2014-02-19 17:52:19 +0000
92@@ -23,9 +23,12 @@
93 'global_spread_checks': 234,
94 'global_debug': False,
95 'global_quiet': False,
96+ 'global_stats_socket': True,
97+ 'global_stats_socket_level': "invalid-user",
98 }
99 result = hooks.create_haproxy_globals()
100
101+ sock_path = "/var/run/haproxy/haproxy.sock"
102 expected = '\n'.join([
103 'global',
104 ' log foo-log',
105@@ -34,6 +37,7 @@
106 ' user foo-user',
107 ' group foo-group',
108 ' spread-checks 234',
109+ ' stats socket %s mode 0600 level user' % sock_path,
110 ])
111 self.assertEqual(result, expected)
112
113@@ -47,9 +51,12 @@
114 'global_spread_checks': 234,
115 'global_debug': True,
116 'global_quiet': True,
117+ 'global_stats_socket': True,
118+ 'global_stats_socket_level': "operator",
119 }
120 result = hooks.create_haproxy_globals()
121
122+ sock_path = "/var/run/haproxy/haproxy.sock"
123 expected = '\n'.join([
124 'global',
125 ' log foo-log',
126@@ -60,6 +67,7 @@
127 ' debug',
128 ' quiet',
129 ' spread-checks 234',
130+ ' stats socket %s mode 0600 level operator' % sock_path,
131 ])
132 self.assertEqual(result, expected)
133

Subscribers

People subscribed via source and target branches