Skip to content

Commit

Permalink
fix: start dns creation after installation (#829)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Jun 1, 2024
1 parent 94cc2ae commit e4e7e21
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
19 changes: 19 additions & 0 deletions svc/pkg/cluster/worker/src/workers/server_install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,25 @@ async fn worker(ctx: &OperationContext<cluster::msg::server_install::Message>) -
})
.await?;

// Create DNS record
if let backend::cluster::PoolType::Gg = pool_type {
// Source of truth record
sql_execute!(
[ctx]
"
INSERT INTO db_cluster.servers_cloudflare (server_id)
VALUES ($1)
",
server_id.as_uuid(),
)
.await?;

msg!([ctx] cluster::msg::server_dns_create(server_id) {
server_id: Some(server_id),
})
.await?;
}

insert_metrics(
ctx,
&pool_type,
Expand Down
43 changes: 22 additions & 21 deletions svc/pkg/cluster/worker/src/workers/server_provision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,28 @@ async fn inner(
)
.await?;

// Install components
if !provision_res.already_installed {
if provision_res.already_installed {
// Create DNS record because the server is already installed
if let backend::cluster::PoolType::Gg = pool_type {
// Source of truth record
sql_execute!(
[ctx]
"
INSERT INTO db_cluster.servers_cloudflare (server_id)
VALUES ($1)
",
server_id,
)
.await?;

msg!([ctx] cluster::msg::server_dns_create(server_id) {
server_id: ctx.server_id,
})
.await?;
}
}
// Install components on server
else {
let request_id = Uuid::new_v4();

msg!([ctx] cluster::msg::server_install(request_id) {
Expand All @@ -183,25 +203,6 @@ async fn inner(
.await?;
}

// Create DNS record
if let backend::cluster::PoolType::Gg = pool_type {
// Source of truth record
sql_execute!(
[ctx]
"
INSERT INTO db_cluster.servers_cloudflare (server_id)
VALUES ($1)
",
server_id,
)
.await?;

msg!([ctx] cluster::msg::server_dns_create(server_id) {
server_id: ctx.server_id,
})
.await?;
}

insert_metrics(datacenter, &pool_type, provision_complete_ts, create_ts).await?;
} else {
tracing::error!(?server_id, hardware_options=?pool.hardware.len(), "failed all attempts to provision server");
Expand Down

0 comments on commit e4e7e21

Please sign in to comment.