Skip to content

Commit

Permalink
fix: delegate more funcionality to dc-scale
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Apr 17, 2024
1 parent e39f29a commit 5062f8b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions svc/pkg/cluster/worker/src/workers/datacenter_scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ async fn inner(
datacenter_id = $1 AND
-- Filters out servers that are being destroyed/already destroyed
cloud_destroy_ts IS NULL
FOR UPDATE
",
datacenter_id,
)
Expand Down
1 change: 1 addition & 0 deletions svc/pkg/linode/standalone/gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ async fn get_prebake_servers(
ssh_key_id, linode_id, firewall_id
FROM db_cluster.server_images_linode
WHERE image_id = ANY($1)
FOR UPDATE
",
image_ids,
)
Expand Down
3 changes: 2 additions & 1 deletion svc/pkg/mm-config/ops/version-prepare/src/prewarm_ats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ pub async fn prewarm_ats_cache(
[ctx, VlanIp]
"
SELECT
datacenter_id, vlan_ip
datacenter_id, vlan_ip
FROM db_cluster.servers
WHERE
datacenter_id = ANY($1) AND
pool_type = $2 AND
vlan_ip IS NOT NULL AND
drain_ts IS NULL AND
cloud_destroy_ts IS NULL
",
// NOTE: region_id is just the old name for datacenter_id
Expand Down
6 changes: 5 additions & 1 deletion svc/pkg/mm/worker/src/workers/lobby_create/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,12 +857,15 @@ async fn resolve_image_artifact_url(

let region_id = unwrap_ref!(region.region_id).as_uuid();

// Hash build id
// Hash build so that the ATS server that we download the build from is always the same one. This
// improves cache hit rates and reduces download times.
let build_id = unwrap_ref!(build.build_id).as_uuid();
let mut hasher = DefaultHasher::new();
hasher.write(build_id.as_bytes());
let hash = hasher.finish() as i64;

// NOTE: The algorithm for choosing the vlan_ip from the hash should match the one in
// prewarm_ats.rs @ prewarm_ats_cache
// Get vlan ip from build id hash for consistent routing
let (ats_vlan_ip,) = sql_fetch_one!(
[ctx, (String,)]
Expand All @@ -876,6 +879,7 @@ async fn resolve_image_artifact_url(
datacenter_id = $1 AND
pool_type = $2 AND
vlan_ip IS NOT NULL AND
drain_ts IS NULL AND
cloud_destroy_ts IS NULL
)
SELECT vlan_ip
Expand Down

0 comments on commit 5062f8b

Please sign in to comment.