mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge pull request #746 from meghashyamps/skip-creating-duplicate-monitors
check for identical monitor and skip creating one if found
This commit is contained in:
@@ -1208,15 +1208,21 @@ class Ns1Provider(BaseProvider):
|
||||
|
||||
# Build a list of primary values for each pool, including their
|
||||
# feed_id (monitor)
|
||||
value_feed = dict()
|
||||
pool_answers = defaultdict(list)
|
||||
for pool_name, pool in sorted(pools.items()):
|
||||
for value in pool.data['values']:
|
||||
weight = value['weight']
|
||||
value = value['value']
|
||||
existing = existing_monitors.get(value)
|
||||
monitor_id, feed_id = self._monitor_sync(record, value,
|
||||
existing)
|
||||
active_monitors.add(monitor_id)
|
||||
feed_id = value_feed.get(value)
|
||||
# check for identical monitor and skip creating one if found
|
||||
if not feed_id:
|
||||
existing = existing_monitors.get(value)
|
||||
monitor_id, feed_id = self._monitor_sync(record, value,
|
||||
existing)
|
||||
value_feed[value] = feed_id
|
||||
active_monitors.add(monitor_id)
|
||||
|
||||
pool_answers[pool_name].append({
|
||||
'answer': [value],
|
||||
'weight': weight,
|
||||
|
||||
@@ -1459,6 +1459,10 @@ class TestNs1ProviderDynamic(TestCase):
|
||||
# This indirectly calls into _params_for_dynamic and tests the
|
||||
# handling to get there
|
||||
record = self.record()
|
||||
# copy an existing answer from a different pool to 'lhr' so
|
||||
# in order to test answer repetition across pools (monitor reuse)
|
||||
record.dynamic._data()['pools']['lhr']['values'].append(
|
||||
record.dynamic._data()['pools']['iad']['values'][0])
|
||||
ret, _ = provider._params_for_A(record)
|
||||
|
||||
# Given that record has both country and region in the rules,
|
||||
|
||||
Reference in New Issue
Block a user