From ad57ae053fba8e7c8112aa1c18ec93052fcae383 Mon Sep 17 00:00:00 2001 From: Jake Spain Date: Tue, 7 Feb 2023 06:40:57 -0500 Subject: [PATCH] Add delete record --- lib/vmpooler/dns/gcp/clouddns.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/vmpooler/dns/gcp/clouddns.rb b/lib/vmpooler/dns/gcp/clouddns.rb index d3f6c31..97377ba 100644 --- a/lib/vmpooler/dns/gcp/clouddns.rb +++ b/lib/vmpooler/dns/gcp/clouddns.rb @@ -49,6 +49,16 @@ module Vmpooler connection.zone('vmpooler-example-com').add(hostname, 'A', 60, ip) end + def delete_record(hostname) + retries = 0 + connection.zone('vmpooler-example-com').remove(hostname, 'A') + rescue Google::Cloud::FailedPreconditionError => e + # this error was experienced intermittently, will retry to see if it can complete successfully + # the error is Google::Cloud::FailedPreconditionError: conditionNotMet: Precondition not met for 'entity.change.deletions[1]' + sleep 5 + retry if (retries += 1) < 30 + end + def connection @connection_pool.with_metrics do |pool_object| return ensured_gcp_connection(pool_object)