add more logging

This commit is contained in:
Matthew Spence 2025-02-07 11:02:35 -06:00
parent d4a5e3e400
commit 826adc5753
No known key found for this signature in database

View file

@ -1048,21 +1048,23 @@ class Domain(TimeStampedModel, DomainHelper):
code=ErrorCode.OBJECT_ASSOCIATION_PROHIBITS_OPERATION, code=ErrorCode.OBJECT_ASSOCIATION_PROHIBITS_OPERATION,
note=f"Host {host.name} is in use by {host.domain}", note=f"Host {host.name} is in use by {host.domain}",
) )
try:
# set hosts to empty list so nameservers are deleted # set hosts to empty list so nameservers are deleted
( (
deleted_values, deleted_values,
updated_values, updated_values,
new_values, new_values,
oldNameservers, oldNameservers,
) = self.getNameserverChanges(hosts=[]) ) = self.getNameserverChanges(hosts=[])
# update the hosts # update the hosts
_ = self._update_host_values(updated_values, oldNameservers) # returns nothing, just need to be run and errors _ = self._update_host_values(updated_values, oldNameservers) # returns nothing, just need to be run and errors
addToDomainList, _ = self.createNewHostList(new_values) addToDomainList, _ = self.createNewHostList(new_values)
deleteHostList, _ = self.createDeleteHostList(deleted_values) deleteHostList, _ = self.createDeleteHostList(deleted_values)
responseCode = self.addAndRemoveHostsFromDomain(hostsToAdd=addToDomainList, hostsToDelete=deleteHostList) responseCode = self.addAndRemoveHostsFromDomain(hostsToAdd=addToDomainList, hostsToDelete=deleteHostList)
except RegistryError as e:
logger.error(f"Error trying to delete hosts from domain {self}: {e}")
raise e
# if unable to update domain raise error and stop # if unable to update domain raise error and stop
if responseCode != ErrorCode.COMMAND_COMPLETED_SUCCESSFULLY: if responseCode != ErrorCode.COMMAND_COMPLETED_SUCCESSFULLY:
raise NameserverError(code=nsErrorCodes.BAD_DATA) raise NameserverError(code=nsErrorCodes.BAD_DATA)
@ -1070,6 +1072,7 @@ class Domain(TimeStampedModel, DomainHelper):
# addAndRemoveHostsFromDomain removes the hosts from the domain object, # addAndRemoveHostsFromDomain removes the hosts from the domain object,
# but we still need to delete the object themselves # but we still need to delete the object themselves
self._delete_hosts_if_not_used(hostsToDelete=deleted_values) self._delete_hosts_if_not_used(hostsToDelete=deleted_values)
logger.info("Finished _delete_host_if_not_used inside _delete_domain()")
# delete the non-registrant contacts # delete the non-registrant contacts
logger.debug("Deleting non-registrant contacts for %s", self.name) logger.debug("Deleting non-registrant contacts for %s", self.name)
@ -1083,6 +1086,8 @@ class Domain(TimeStampedModel, DomainHelper):
registry.send(request, cleaned=True) registry.send(request, cleaned=True)
except RegistryError as e: except RegistryError as e:
logger.error(f"Error deleting contact: {contact}, {e}", exec_info=True) logger.error(f"Error deleting contact: {contact}, {e}", exec_info=True)
logger.info("Finished deleting contacts")
# delete ds data if it exists # delete ds data if it exists
if self.dnssecdata: if self.dnssecdata:
@ -1097,9 +1102,13 @@ class Domain(TimeStampedModel, DomainHelper):
e.note = "Error deleting ds data for %s" % self.name e.note = "Error deleting ds data for %s" % self.name
raise e raise e
logger.info("Deleting domain %s", self.name) try:
request = commands.DeleteDomain(name=self.name) logger.info("Deleting domain %s", self.name)
registry.send(request, cleaned=True) request = commands.DeleteDomain(name=self.name)
registry.send(request, cleaned=True)
except RegistryError as e:
logger.error(f"Error deleting domain {self}: {e}")
raise e
def __str__(self) -> str: def __str__(self) -> str:
return self.name return self.name