Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion svc/pkg/cluster/worker/src/workers/server_dns_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ async fn inner(
})
.await?;

tracing::info!(record_id=%create_record_res.result.id, "created dns record");

// Save record id for deletion
sql_execute!(
[ctx, @tx tx]
Expand Down Expand Up @@ -135,12 +137,14 @@ async fn inner(
})
.await?;

tracing::info!(record_id=%create_secondary_record_res.result.id, "created secondary dns record");

// Save record id for deletion
sql_execute!(
[ctx, @tx tx]
"
UPDATE db_cluster.servers_cloudflare
SET dns_record_id = $2
SET secondary_dns_record_id = $2
WHERE
server_id = $1 AND
destroy_ts IS NULL
Expand Down
19 changes: 13 additions & 6 deletions svc/pkg/cluster/worker/src/workers/server_dns_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ async fn inner(
else {
// NOTE: It is safe to do nothing in this case because both this worker and
// `cluster-server-dns-create` use transactions
tracing::warn!("server has no dns record");
tracing::warn!("server has no dns records");
return Ok(());
};

let zone_id = unwrap!(util::env::cloudflare::zone::job::id(), "dns not configured");

// Delete main record
if let Some(dns_record_id) = dns_record_id {
if let Some(record_id) = dns_record_id {
let res = client
.request(&cf::dns::DeleteDnsRecord {
zone_identifier: zone_id,
identifier: &dns_record_id,
identifier: &record_id,
})
.await;

Expand All @@ -84,20 +84,27 @@ async fn inner(
_,
)) = res
{
tracing::warn!(%zone_id, %dns_record_id, "dns record not found");
tracing::warn!(%zone_id, %record_id, "dns record not found");
} else {
res?;
tracing::warn!(%record_id, "deleted dns record");
}
} else {
tracing::warn!("server has no primary dns record");
}

// Delete secondary record
if let Some(secondary_dns_record_id) = secondary_dns_record_id {
if let Some(record_id) = secondary_dns_record_id {
client
.request(&cf::dns::DeleteDnsRecord {
zone_identifier: zone_id,
identifier: &secondary_dns_record_id,
identifier: &record_id,
})
.await?;

tracing::warn!(%record_id, "deleted secondary dns record");
} else {
tracing::warn!("server has no secondary dns record");
}

// Update db record
Expand Down