Fix google cloud dns api not actually creating any DNS records for DNS-01 challenge

This commit is contained in:
Luis Pabon 2024-01-04 12:51:40 +00:00
parent afacdfcb95
commit 390467f69f
No known key found for this signature in database

View File

@ -55,41 +55,41 @@ _dns_gcloud_start_tr() {
tr="$trd/tr.yaml" tr="$trd/tr.yaml"
_debug tr "$tr" _debug tr "$tr"
if ! gcloud dns record-sets transaction start \ _err "__SIGA_DEBUG tr: >$tr<"
_err "__SIGA_DEBUG zone: >$managedZone<"
gcloud dns record-sets transaction start \
--transaction-file="$tr" \ --transaction-file="$tr" \
--zone="$managedZone"; then --zone="$managedZone"
rm -r "$trd" rc=$?
_err "_dns_gcloud_start_tr: failed to execute transaction" _err "_dns_gcloud_start_tr: RC= $rc failed to execute transaction"
return 1 return 0
fi
} }
_dns_gcloud_execute_tr() { _dns_gcloud_execute_tr() {
if ! gcloud dns record-sets transaction execute \ _debug __SIGA_DEBUG _dns_gcloud_execute_tr
gcloud dns record-sets transaction execute \
--transaction-file="$tr" \ --transaction-file="$tr" \
--zone="$managedZone"; then --zone="$managedZone"
rc=$?
_debug tr "$(cat "$tr")" _debug tr "$(cat "$tr")"
rm -r "$trd" _err "_dns_gcloud_execute_tr: RC= $rc failed to execute transaction"
_err "_dns_gcloud_execute_tr: failed to execute transaction"
return 1
fi
rm -r "$trd"
for i in $(seq 1 120); do for i in $(seq 1 120); do
_err "__SIGA_DEBUG i: $i"
if gcloud dns record-sets changes list \ if gcloud dns record-sets changes list \
--zone="$managedZone" \ --zone="$managedZone" \
--filter='status != done' | --filter='status != done' \
grep -q '^.*'; then | grep -q '^.*'; then
_info "_dns_gcloud_execute_tr: waiting for transaction to be comitted ($i/120)..." _info "_dns_gcloud_execute_tr: waiting for transaction to be comitted ($i/120)..."
sleep 5 sleep 5
else else
return 0 return 0
fi fi
done done
_err "_dns_gcloud_execute_tr: transaction is still pending after 10 minutes"
rm -r "$trd"
return 1
} }
_dns_gcloud_remove_rrs() { _dns_gcloud_remove_rrs() {
@ -108,17 +108,16 @@ _dns_gcloud_remove_rrs() {
_dns_gcloud_add_rrs() { _dns_gcloud_add_rrs() {
ttl=60 ttl=60
if ! xargs -r gcloud dns record-sets transaction add \ xargs -r gcloud dns record-sets transaction add \
--name="$fulldomain." \ --name="$fulldomain." \
--ttl="$ttl" \ --ttl="$ttl" \
--type=TXT \ --type=TXT \
--zone="$managedZone" \ --zone="$managedZone" \
--transaction-file="$tr" --; then --transaction-file="$tr"
rc=$?
_debug tr "$(cat "$tr")" _debug tr "$(cat "$tr")"
rm -r "$trd" _err "_dns_gcloud_add_rrs: rc=$rc failed to add RRs"
_err "_dns_gcloud_add_rrs: failed to add RRs" return 0
return 1
fi
} }
_dns_gcloud_find_zone() { _dns_gcloud_find_zone() {