Merge lp:~tribaal/charms/trusty/nova-cloud-controller/enable-api-rate-limiting into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Chris Glass on 2015-10-02
Status: Merged
Merged at revision: 197
Proposed branch: lp:~tribaal/charms/trusty/nova-cloud-controller/enable-api-rate-limiting
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 127 lines (+55/-2)
6 files modified
config.yaml (+9/-0)
hooks/nova_cc_context.py (+9/-0)
hooks/nova_cc_utils.py (+2/-1)
templates/icehouse/etc_nova_api-paste.ini (+3/-0)
templates/kilo/etc_nova_api-paste.ini (+3/-0)
tests/basic_deployment.py (+29/-1)
To merge this branch: bzr merge lp:~tribaal/charms/trusty/nova-cloud-controller/enable-api-rate-limiting
Reviewer Review Type Date Requested Status
Liam Young 2015-10-02 Approve on 2015-10-05
Ryan Beisner Needs Fixing on 2015-10-03
Review via email: mp+273217@code.launchpad.net

Description of the change

This branch enables API rate-limiting in the nova-cloud-controller charm instead of the nova-compute one.

To post a comment you must log in.

charm_lint_check #11157 nova-cloud-controller-next for tribaal mp273217
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/12638435/
Build: http://10.245.162.77:8080/job/charm_lint_check/11157/

charm_unit_test #10362 nova-cloud-controller-next for tribaal mp273217
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10362/

198. By Chris Glass on 2015-10-02

Added extra blank line.

charm_lint_check #11161 nova-cloud-controller-next for tribaal mp273217
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11161/

charm_unit_test #10365 nova-cloud-controller-next for tribaal mp273217
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10365/

charm_amulet_test #6972 nova-cloud-controller-next for tribaal mp273217
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12638894/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6972/

199. By Chris Glass on 2015-10-02

Setting expectations right for the failing test.

charm_lint_check #11162 nova-cloud-controller-next for tribaal mp273217
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11162/

charm_amulet_test #6975 nova-cloud-controller-next for tribaal mp273217
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12639181/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6975/

charm_amulet_test #6981 nova-cloud-controller-next for tribaal mp273217
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 124
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12639295/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6981/

charm_amulet_test #6985 nova-cloud-controller-next for tribaal mp273217
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 124
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12639381/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6985/

200. By Chris Glass on 2015-10-02

An actual missing semicolon.

charm_lint_check #11168 nova-cloud-controller-next for tribaal mp273217
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11168/

charm_unit_test #10371 nova-cloud-controller-next for tribaal mp273217
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10371/

charm_amulet_test #6991 nova-cloud-controller-next for tribaal mp273217
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 124
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12640547/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6991/

charm_amulet_test #7001 nova-cloud-controller-next for tribaal mp273217
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12642142/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7001/

charm_amulet_test #7027 nova-cloud-controller-next for tribaal mp273217
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12644613/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7027/

Ryan Beisner (1chb1n) wrote :

Apologize for test noise while we are sorting through infra issues.

...

However, this is the real failure observed in the amulet tests. It looks like the test will need some adjusting.

00:07:49.623 2015-10-03 03:04:58 Invalid config charm nova-compute api-rate-limit-rules=( POST, '*', .*, 9999, MINUTE );

review: Needs Fixing
201. By Chris Glass on 2015-10-05

Don't assign the same dict to both nova-compute and nova-cloud-controller.

charm_lint_check #11324 nova-cloud-controller-next for tribaal mp273217
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11324/

charm_unit_test #10518 nova-cloud-controller-next for tribaal mp273217
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10518/

Liam Young (gnuoy) wrote :

Ran amulet manually: http://paste.ubuntu.com/12688874/ looks good!

juju-test INFO : Results: 9 passed, 0 failed, 0 errored

Liam Young (gnuoy) wrote :

Approved

review: Approve

charm_amulet_test #7109 nova-cloud-controller-next for tribaal mp273217
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7109/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-09-28 10:02:33 +0000
3+++ config.yaml 2015-10-05 06:51:47 +0000
4@@ -411,3 +411,12 @@
5 description: |
6 List of filter class names to use for filtering hosts when not specified in
7 the request.
8+ api-rate-limit-rules:
9+ type: string
10+ default:
11+ description: |
12+ The API rate-limit rules to use for the deployed nova API, if any.
13+ Contents of this config options will be inserted in the api-paste.ini file
14+ under the "filter:ratelimit" section as "limits". The syntax for these
15+ rules is documented at
16+ http://docs.openstack.org/kilo/config-reference/content/configuring-compute-API.html
17
18=== modified file 'hooks/nova_cc_context.py'
19--- hooks/nova_cc_context.py 2015-09-29 06:46:46 +0000
20+++ hooks/nova_cc_context.py 2015-10-05 06:51:47 +0000
21@@ -409,3 +409,12 @@
22 ctxt['html5proxy_base_url'] = url
23
24 return ctxt
25+
26+
27+class APIRateLimitingContext(context.OSContextGenerator):
28+ def __call__(self):
29+ ctxt = {}
30+ rate_rules = config('api-rate-limit-rules')
31+ if rate_rules:
32+ ctxt['api_rate_limit_rules'] = rate_rules
33+ return ctxt
34
35=== modified file 'hooks/nova_cc_utils.py'
36--- hooks/nova_cc_utils.py 2015-09-25 17:20:51 +0000
37+++ hooks/nova_cc_utils.py 2015-10-05 06:51:47 +0000
38@@ -199,7 +199,8 @@
39 }),
40 (NOVA_API_PASTE, {
41 'services': [s for s in BASE_SERVICES if 'api' in s],
42- 'contexts': [nova_cc_context.IdentityServiceContext()],
43+ 'contexts': [nova_cc_context.IdentityServiceContext(),
44+ nova_cc_context.APIRateLimitingContext()],
45 }),
46 (QUANTUM_CONF, {
47 'services': ['quantum-server'],
48
49=== modified file 'templates/icehouse/etc_nova_api-paste.ini'
50--- templates/icehouse/etc_nova_api-paste.ini 2014-04-12 21:47:13 +0000
51+++ templates/icehouse/etc_nova_api-paste.ini 2015-10-05 06:51:47 +0000
52@@ -85,6 +85,9 @@
53
54 [filter:ratelimit]
55 paste.filter_factory = nova.api.openstack.compute.limits:RateLimitingMiddleware.factory
56+{% if api_rate_limit_rules -%}
57+limits = {{ api_rate_limit_rules }}
58+{% endif -%}
59
60 [filter:sizelimit]
61 paste.filter_factory = nova.api.sizelimit:RequestBodySizeLimiter.factory
62
63=== modified file 'templates/kilo/etc_nova_api-paste.ini'
64--- templates/kilo/etc_nova_api-paste.ini 2015-03-24 17:42:42 +0000
65+++ templates/kilo/etc_nova_api-paste.ini 2015-10-05 06:51:47 +0000
66@@ -104,6 +104,9 @@
67
68 [filter:ratelimit]
69 paste.filter_factory = nova.api.openstack.compute.limits:RateLimitingMiddleware.factory
70+{% if api_rate_limit_rules -%}
71+limits = {{ api_rate_limit_rules }}
72+{% endif -%}
73
74 [filter:sizelimit]
75 paste.filter_factory = oslo.middleware:RequestBodySizeLimiter.factory
76
77=== modified file 'tests/basic_deployment.py'
78--- tests/basic_deployment.py 2015-07-23 03:02:42 +0000
79+++ tests/basic_deployment.py 2015-10-05 06:51:47 +0000
80@@ -66,7 +66,9 @@
81
82 def _configure_services(self):
83 """Configure all of the services."""
84- nova_cc_config = nova_config = {}
85+ nova_cc_config = {}
86+ nova_config = {}
87+
88 if self.git:
89 amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY')
90
91@@ -98,6 +100,10 @@
92 }
93 nova_cc_config['openstack-origin-git'] = yaml.dump(openstack_origin_git)
94 nova_config['openstack-origin-git'] = yaml.dump(openstack_origin_git)
95+
96+ # Add some rate-limiting options to the charm. These will noop before
97+ # icehouse.
98+ nova_cc_config['api-rate-limit-rules'] = "( POST, '*', .*, 9999, MINUTE );"
99 keystone_config = {'admin-password': 'openstack',
100 'admin-token': 'ubuntutesting'}
101 configs = {'nova-cloud-controller': nova_cc_config,
102@@ -647,3 +653,25 @@
103
104 u.delete_image(self.glance, image)
105 u.delete_instance(self.nova_demo, instance)
106+
107+ def test_api_rate_limiting_is_enabled_for_icehouse_or_more(self):
108+ """
109+ The API rate limiting is enabled for icehouse or more. Otherwise the
110+ api-paste.ini file is left untouched.
111+ """
112+ unit = self.nova_cc_sentry
113+ conf = '/etc/nova/api-paste.ini'
114+ section = "filter:ratelimit"
115+ factory = ("nova.api.openstack.compute.limits:RateLimitingMiddleware"
116+ ".factory")
117+
118+ if self._get_openstack_release() >= self.precise_icehouse:
119+ expected = {"paste.filter_factory": factory,
120+ "limits": "( POST, '*', .*, 9999, MINUTE );"}
121+ else:
122+ expected = {"paste.filter_factory": factory}
123+
124+ ret = u.validate_config_data(unit, conf, section, expected)
125+ if ret:
126+ message = "api paste config error: {}".format(ret)
127+ amulet.raise_status(amulet.FAIL, msg=message)

Subscribers

People subscribed via source and target branches