-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved record deletion performance #20
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ def add_cname_record(dns_server, zone_name, cname, originating_record, ttl, key_ | |
return [{ "description" : "CNAME %s.%s points to %s" % (cname, zone_name, originating_record), | ||
"output" : output}] | ||
|
||
def delete_record(dns_server, rr_list, key_name): | ||
def delete_record(dns_server, zone_name, rr_list, key_name): | ||
"""Delete a list of DNS records passed as strings in rr_items.""" | ||
|
||
try: | ||
|
@@ -92,17 +92,16 @@ def delete_record(dns_server, rr_list, key_name): | |
keyring = transfer_key.create_keyring() | ||
algorithm = transfer_key.algorithm | ||
|
||
delete_response = [] | ||
for current_rr in rr_list: | ||
record_list = current_rr.split(".") | ||
record = record_list[0] | ||
domain = ".".join(record_list[1:]) | ||
dns_update = dns.update.Update(domain, keyring=keyring, keyalgorithm=algorithm) | ||
dns_update.delete(record) | ||
output = send_dns_update(dns_update, dns_server, key_name) | ||
|
||
delete_response.append({ "description" : "Delete Record: %s" % current_rr, | ||
"output" : output }) | ||
dns_update = dns.update.Update(zone_name, keyring=keyring, keyalgorithm=algorithm) | ||
records = [] | ||
for resource_record in rr_list: | ||
dns_update.delete(resource_record) | ||
records.append("%s.%s" % (resource_record, zone_name)) | ||
|
||
output = send_dns_update(dns_update, dns_server, key_name) | ||
delete_response = [{"description": "Deleted Records:<br/>%s" % | ||
'<br />'.join(records), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really fond of having output-formatting in the Python itself. Let the templates handle that. This way also loses the ability to see a record-by-record accounting of failures and successes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I completely agree on the output formatting. It's just been a quick solution working with the current implementation of error handling in binder in general. I believe the error handling will need a complete overhaul anyway to be more precise and flexible. I intend to address that in future with another pull request. Regarding the loss of the record-by-record accounting I'm not sure if that's worse than before, because all records which will be deleted belong to the same zone. So we know that if the key works for one of them, it works for the others too. And as the deletion of records even returns successfully if they are not existing, we don't loose information in such a case. |
||
"output": output}] | ||
|
||
return delete_response | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refuse to put any sort of formatting of the data in the Python itself. Leave the output formatting for the templates.