浏览代码

fix(api): adding RRsets conflicting with CNAMES marked for deletion

This fixes #220, where the API was unable to add an RRset that was
in conflict with an existing CNAME RRset, which was required to be
deleted with the same request.

The fix is somewhat magically, as it depends on
- the order in which updates are send to pdns,
- the changetype that is used to delete RRset in pdns (i.e., "DELETE"
  or "REPLACE" with records=[].

For further discussion, see #220.
Nils Wisiol 6 年之前
父节点
当前提交
2aff65be62
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9 8
      api/desecapi/pdns_change_tracker.py

+ 9 - 8
api/desecapi/pdns_change_tracker.py

@@ -128,6 +128,15 @@ class PDNSChangeTracker:
             data = {
                 'rrsets':
                     [
+                        {
+                            'name': RRset.construct_name(subname, self._domain_name),
+                            'type': type_,
+                            'ttl': 1,  # some meaningless integer required by pdns's syntax
+                            'changetype': 'REPLACE',  # don't use "DELETE" due to desec-stack#220, PowerDNS/pdns#7501
+                            'records': []
+                        }
+                        for type_, subname in self._deletions
+                    ] + [
                         {
                             'name': RRset.construct_name(subname, self._domain_name),
                             'type': type_,
@@ -143,14 +152,6 @@ class PDNSChangeTracker:
                             ]
                         }
                         for type_, subname in (self._additions | self._modifications) - self._deletions
-                    ] + [
-                        {
-                            'name': RRset.construct_name(subname, self._domain_name),
-                            'type': type_,
-                            'changetype': 'DELETE',
-                            'records': []
-                        }
-                        for type_, subname in self._deletions
                     ]
             }