Add config for disabling creation of PING type HMs
PING is a trap. There is no real-world scenario where PING is the option that makes the most sense, but people are familiar with it, and it seems "simple", so they pick it. This needs to stop. Empower operators to disable this! Change-Id: Ifa80b7a5973361c13f2e6611789aa9798325ece0
This commit is contained in:
parent
90c2f6d9f7
commit
d28d311db1
@ -40,6 +40,9 @@
|
||||
# Enable/disable ability for users to create TLS Terminated listeners
|
||||
# allow_tls_terminated_listeners = True
|
||||
|
||||
# Enable/disable ability for users to create PING type Health Monitors
|
||||
# allow_ping_health_monitors = True
|
||||
|
||||
[database]
|
||||
# This line MUST be changed to actually run the plugin.
|
||||
# Example:
|
||||
|
@ -151,6 +151,12 @@ class HealthMonitorController(base.BaseController):
|
||||
"""Creates a health monitor on a pool."""
|
||||
context = pecan.request.context.get('octavia_context')
|
||||
health_monitor = health_monitor_.healthmonitor
|
||||
|
||||
if (not CONF.api_settings.allow_ping_health_monitors and
|
||||
health_monitor.type == constants.HEALTH_MONITOR_PING):
|
||||
raise exceptions.DisabledOption(
|
||||
option='type', value=constants.HEALTH_MONITOR_PING)
|
||||
|
||||
pool = self._get_db_pool(context.session, health_monitor.pool_id)
|
||||
health_monitor.project_id = pool.project_id
|
||||
|
||||
|
@ -100,6 +100,8 @@ api_opts = [
|
||||
help=_("Expose the v2 API?")),
|
||||
cfg.BoolOpt('allow_tls_terminated_listeners', default=True,
|
||||
help=_("Allow users to create TLS Terminated listeners?")),
|
||||
cfg.BoolOpt('allow_ping_health_monitors', default=True,
|
||||
help=_("Allow users to create PING type Health Monitors?")),
|
||||
]
|
||||
|
||||
# Options only used by the amphora agent
|
||||
|
@ -740,6 +740,21 @@ class TestHealthMonitor(base.BaseAPITest):
|
||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||
pool_id=self.pool_id)
|
||||
|
||||
def test_create_ping_when_ping_disabled(self):
|
||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||
self.conf.config(group='api_settings',
|
||||
allow_ping_health_monitors=False)
|
||||
req_dict = {'pool_id': self.pool_id,
|
||||
'type': constants.HEALTH_MONITOR_PING,
|
||||
'delay': 1,
|
||||
'timeout': 1,
|
||||
'max_retries_down': 1,
|
||||
'max_retries': 1}
|
||||
self.post(self.HMS_PATH, self._build_body(req_dict), status=400)
|
||||
self.assert_correct_status(
|
||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||
pool_id=self.pool_id)
|
||||
|
||||
def test_create_with_bad_handler(self):
|
||||
self.handler_mock().health_monitor.create.side_effect = Exception()
|
||||
api_hm = self.create_health_monitor(
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Cloud deployers can set `api_settings.allow_ping_health_monitors = False`
|
||||
in `octavia.conf` to disable the ability to create PING health monitors.
|
Loading…
Reference in New Issue
Block a user