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
=== modified file 'README.md'
--- README.md 2014-01-07 19:03:41 +0000
+++ README.md 2014-02-19 17:52:19 +0000
@@ -97,7 +97,7 @@
97 sudo apt-get install python-software-properties97 sudo apt-get install python-software-properties
98 sudo add-apt-repository ppa:cjohnston/flake898 sudo add-apt-repository ppa:cjohnston/flake8
99 sudo apt-get update99 sudo apt-get update
100 sudo apt-get install python-mock python-flake8 python-nose python-nosexcover100 sudo apt-get install python-mock python-flake8 python-nose python-nosexcover python-testtools charm-tools
101101
102To run the tests:102To run the tests:
103103
104104
=== modified file 'config.yaml'
--- config.yaml 2014-01-07 18:44:15 +0000
+++ config.yaml 2014-02-19 17:52:19 +0000
@@ -34,6 +34,17 @@
34 the same physical server. With the help of this parameter, it becomes 34 the same physical server. With the help of this parameter, it becomes
35 possible to add some randomness in the check interval between 0 and 35 possible to add some randomness in the check interval between 0 and
36 +/- 50%. A value between 2 and 5 seems to show good results.36 +/- 50%. A value between 2 and 5 seems to show good results.
37 global_stats_socket:
38 default: False
39 type: boolean
40 description: |
41 Whether to enable the stats UNIX socket.
42 global_stats_socket_level:
43 default: "user"
44 type: string
45 description: |
46 Privilege level for the stats socket. Only used if global_stats_socket
47 is set to True. Accepted values are: "user", "operator" and "admin".
37 default_log:48 default_log:
38 default: "global"49 default: "global"
39 type: string50 type: string
@@ -90,6 +101,13 @@
90 default: 3101 default: 3
91 type: int102 type: int
92 description: Monitoring interface refresh interval (in seconds)103 description: Monitoring interface refresh interval (in seconds)
104 install_hatop:
105 default: False
106 type: boolean
107 description: |
108 If set to True hatop package will be installed. The package requires
109 stats socket, see global_stats_socket and global_stats_socket_level
110 options for details
93 package_status:111 package_status:
94 default: "install"112 default: "install"
95 type: "string"113 type: "string"
96114
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2014-01-21 15:46:29 +0000
+++ hooks/hooks.py 2014-02-19 17:52:19 +0000
@@ -25,7 +25,7 @@
25 close_port,25 close_port,
26 unit_get,26 unit_get,
27 )27 )
28from charmhelpers.fetch import apt_install28from charmhelpers.fetch import apt_install, apt_purge
29from charmhelpers.contrib.charmsupport import nrpe29from charmhelpers.contrib.charmsupport import nrpe
3030
3131
@@ -125,6 +125,13 @@
125 haproxy_globals.append(" quiet")125 haproxy_globals.append(" quiet")
126 haproxy_globals.append(" spread-checks %d" %126 haproxy_globals.append(" spread-checks %d" %
127 config_data['global_spread_checks'])127 config_data['global_spread_checks'])
128 if config_data['global_stats_socket'] is True:
129 sock_path = "/var/run/haproxy/haproxy.sock"
130 socket_level = config_data['global_stats_socket_level']
131 if socket_level not in ["user", "operator", "admin"]:
132 socket_level = "user"
133 haproxy_globals.append(" stats socket %s mode 0600 level %s" % (
134 sock_path, socket_level))
128 return '\n'.join(haproxy_globals)135 return '\n'.join(haproxy_globals)
129136
130137
@@ -765,7 +772,10 @@
765 haproxy_defaults,772 haproxy_defaults,
766 haproxy_monitoring,773 haproxy_monitoring,
767 haproxy_services)774 haproxy_services)
768775 if config_data['install_hatop'] is True:
776 apt_install('hatop', fatal=True)
777 else:
778 apt_purge('hatop', fatal=True)
769 if service_haproxy("check"):779 if service_haproxy("check"):
770 update_service_ports(old_service_ports, get_service_ports())780 update_service_ports(old_service_ports, get_service_ports())
771 service_haproxy("reload")781 service_haproxy("reload")
772782
=== modified file 'hooks/tests/test_helpers.py'
--- hooks/tests/test_helpers.py 2013-12-17 16:00:29 +0000
+++ hooks/tests/test_helpers.py 2014-02-19 17:52:19 +0000
@@ -23,9 +23,12 @@
23 'global_spread_checks': 234,23 'global_spread_checks': 234,
24 'global_debug': False,24 'global_debug': False,
25 'global_quiet': False,25 'global_quiet': False,
26 'global_stats_socket': True,
27 'global_stats_socket_level': "invalid-user",
26 }28 }
27 result = hooks.create_haproxy_globals()29 result = hooks.create_haproxy_globals()
2830
31 sock_path = "/var/run/haproxy/haproxy.sock"
29 expected = '\n'.join([32 expected = '\n'.join([
30 'global',33 'global',
31 ' log foo-log',34 ' log foo-log',
@@ -34,6 +37,7 @@
34 ' user foo-user',37 ' user foo-user',
35 ' group foo-group',38 ' group foo-group',
36 ' spread-checks 234',39 ' spread-checks 234',
40 ' stats socket %s mode 0600 level user' % sock_path,
37 ])41 ])
38 self.assertEqual(result, expected)42 self.assertEqual(result, expected)
3943
@@ -47,9 +51,12 @@
47 'global_spread_checks': 234,51 'global_spread_checks': 234,
48 'global_debug': True,52 'global_debug': True,
49 'global_quiet': True,53 'global_quiet': True,
54 'global_stats_socket': True,
55 'global_stats_socket_level': "operator",
50 }56 }
51 result = hooks.create_haproxy_globals()57 result = hooks.create_haproxy_globals()
5258
59 sock_path = "/var/run/haproxy/haproxy.sock"
53 expected = '\n'.join([60 expected = '\n'.join([
54 'global',61 'global',
55 ' log foo-log',62 ' log foo-log',
@@ -60,6 +67,7 @@
60 ' debug',67 ' debug',
61 ' quiet',68 ' quiet',
62 ' spread-checks 234',69 ' spread-checks 234',
70 ' stats socket %s mode 0600 level operator' % sock_path,
63 ])71 ])
64 self.assertEqual(result, expected)72 self.assertEqual(result, expected)
6573

Subscribers

People subscribed via source and target branches