Clean up orphaned DNS recordsets

Problem / Opportunity Statement

Normally, each instance has a pair of Designate recordsets created automatically when the floating IP is attached:

  • Forward recordset (A record) which resolves the instance's hostname to its floating IP address
  • Reverse recordset (PTR record) which resolves the instances's floating IP address (in backwards format) to its hostname

Sometimes, we end up with "orphaned" recordsets, for (1) instances that no longer exist, or (2) instances that have been renamed. Examples of forward (type-A) recordsets right now in the staff allocation (TRA160003):

terraform-ubuntu20-manila 
suddenly-adequate-weevil  
geos-plaything            
slowly-inviting-squirrel  
nominally-amazed-gator-gui
heartily-optimum-walrus   
utterly-fleet-bluejay     
r8-hostname               
u20-hostname              
alma-gui                  
rocky-gui                 
ubuntu-20-gui             
correctly-romantic-oarfish
roughly-capital-snapper   
routinely-polished-zebra  
js2-report-metrics        

We do not want to keep these around. We want to notice and delete them.

Resolution

A script that runs frequently and does:

  • Looks at extant combinations of instances and floating IP addresses
  • Looks at extant Designate recordsets
  • Looks for:
    • Type-A (forward) recordsets where:
      • The name no longer matches the sanitized hostname of an active instance
      • The value no longer matches the instance's floating IP address
    • Type-PTR (reverse) recordsets where:
      • The value no longer matches the sanitized name of an active instance
      • The name no longer matches the instance's sanitized hostname
  • Corrects Designate recordsets to match reality. A bit more design work to scope this:
    • Do we delete orphaned recordsets or modify them to match the current instances?
Edited by Chris Martin