Removed deprecated managed option in notification handler

The managed option has been deprecated for 3 years now, and is
risky in general as it can cause custom sink handlers to delete
all records in a zone by mistake.

This also allows us to clean the code path up a bit.

Related-Bug: #1387662
Change-Id: Id6174eb7df0c7bc9d138e74f72b6931a025ec818
This commit is contained in:
Erik Olof Gunnar Andersson 2018-07-21 23:17:09 -07:00
parent 66109b2ae2
commit 116b202d18
2 changed files with 26 additions and 35 deletions

View File

@ -125,8 +125,8 @@ class BaseAddressHandler(NotificationHandler):
self.default_formatv6 self.default_formatv6
) )
def _create(self, addresses, extra, zone_id, managed=True, def _create(self, addresses, extra, zone_id, resource_type=None,
resource_type=None, resource_id=None): resource_id=None):
""" """
Create a record from addresses Create a record from addresses
@ -134,15 +134,9 @@ class BaseAddressHandler(NotificationHandler):
{'version': 4, 'ip': '10.0.0.1'} {'version': 4, 'ip': '10.0.0.1'}
:param extra: Extra data to use when formatting the record :param extra: Extra data to use when formatting the record
:param zone_id: The ID of the designate zone. :param zone_id: The ID of the designate zone.
:param managed: Is it a managed resource
:param resource_type: The managed resource type :param resource_type: The managed resource type
:param resource_id: The managed resource ID :param resource_id: The managed resource ID
""" """
if not managed:
LOG.warning(
'Deprecation notice: Unmanaged designate-sink records are '
'being deprecated please update the call '
'to remove managed=False')
LOG.debug('Using Zone ID: %s', zone_id) LOG.debug('Using Zone ID: %s', zone_id)
zone = self.get_zone(zone_id) zone = self.get_zone(zone_id)
LOG.debug('Domain: %r', zone) LOG.debug('Domain: %r', zone)
@ -174,15 +168,13 @@ class BaseAddressHandler(NotificationHandler):
context, **recordset_values) context, **recordset_values)
record_values = { record_values = {
'data': addr['address']} 'data': addr['address'],
'managed': True,
if managed: 'managed_plugin_name': self.get_plugin_name(),
record_values.update({ 'managed_plugin_type': self.get_plugin_type(),
'managed': managed, 'managed_resource_type': resource_type,
'managed_plugin_name': self.get_plugin_name(), 'managed_resource_id': resource_id
'managed_plugin_type': self.get_plugin_type(), }
'managed_resource_type': resource_type,
'managed_resource_id': resource_id})
LOG.debug('Creating record in %s / %s with values %r', LOG.debug('Creating record in %s / %s with values %r',
zone['id'], recordset['id'], record_values) zone['id'], recordset['id'], record_values)
@ -191,38 +183,30 @@ class BaseAddressHandler(NotificationHandler):
recordset['id'], recordset['id'],
Record(**record_values)) Record(**record_values))
def _delete(self, zone_id, managed=True, resource_id=None, def _delete(self, zone_id, resource_id=None, resource_type='instance',
resource_type='instance', criterion=None): criterion=None):
""" """
Handle a generic delete of a fixed ip within a zone Handle a generic delete of a fixed ip within a zone
:param zone_id: The ID of the designate zone. :param zone_id: The ID of the designate zone.
:param managed: Is it a managed resource
:param resource_id: The managed resource ID :param resource_id: The managed resource ID
:param resource_type: The managed resource type :param resource_type: The managed resource type
:param criterion: Criterion to search and destroy records :param criterion: Criterion to search and destroy records
""" """
if not managed:
LOG.warning(
'Deprecation notice: Unmanaged designate-sink records are '
'being deprecated please update the call '
'to remove managed=False')
criterion = criterion or {} criterion = criterion or {}
context = DesignateContext().elevated() context = DesignateContext().elevated()
context.all_tenants = True context.all_tenants = True
context.edit_managed_records = True context.edit_managed_records = True
criterion.update({'zone_id': zone_id}) criterion.update({
'zone_id': zone_id,
if managed: 'managed': True,
criterion.update({ 'managed_plugin_name': self.get_plugin_name(),
'managed': managed, 'managed_plugin_type': self.get_plugin_type(),
'managed_plugin_name': self.get_plugin_name(), 'managed_resource_id': resource_id,
'managed_plugin_type': self.get_plugin_type(), 'managed_resource_type': resource_type
'managed_resource_id': resource_id, })
'managed_resource_type': resource_type
})
records = self.central_api.find_records(context, criterion) records = self.central_api.find_records(context, criterion)

View File

@ -0,0 +1,7 @@
---
upgrade:
- |
Custom notification handlers that created unmanaged records will need to be updated,
as we no longer support the creation of unmanaged records using the sink.
See `designate/notification_handler/base.py` for more details.