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
1 change: 1 addition & 0 deletions svc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions svc/pkg/cluster/worker/src/workers/server_destroy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ async fn inner(
)
.await?;
if server.provider_server_id.is_none() && !ctx.force {
// Check for stale message
if ctx.req_dt() > util::duration::hours(1) {
tracing::warn!("discarding stale message");
return Ok(());
}

bail!("server is not completely provisioned yet, retrying");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use chirp_worker::prelude::*;

use super::TUNNEL_API_INTERNAL_PORT;

pub fn create_hook(initialize_immediately: bool) -> GlobalResult<String> {
let mut script = include_str!("../files/rivet_create_hook.sh").to_string();
pub fn create_hook(tunnel_name: &str, initialize_immediately: bool) -> GlobalResult<String> {
let mut script =
include_str!("../files/rivet_create_hook.sh").replace("__TUNNEL_NAME__", tunnel_name);

if initialize_immediately {
script.push_str("systemctl start rivet_hook\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn instance(config: Instance) -> String {
script
}

pub fn tunnel() -> GlobalResult<String> {
pub fn tunnel(name: &str) -> GlobalResult<String> {
// Build transports for each service
let mut tcp_server_transports = HashMap::new();
for TunnelService { name, .. } in TUNNEL_SERVICES {
Expand All @@ -165,7 +165,7 @@ pub fn tunnel() -> GlobalResult<String> {
}

Ok(instance(Instance {
name: "tunnel".into(),
name: name.to_string(),
static_config: tunnel_static_config(),
dynamic_config: tunnel_dynamic_config(&util::env::var("K8S_TRAEFIK_TUNNEL_EXTERNAL_IP")?),
tcp_server_transports,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
cat << 'EOF' > /etc/systemd/system/rivet_hook.service
[Unit]
Description=Rivet Hook
Requires=network-online.target
After=network-online.target
Requires=network-online.target __TUNNEL_NAME__.service
After=network-online.target __TUNNEL_NAME__.service
ConditionPathExists=!/var/tmp/rivet_hook.completed

[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ pub async fn gen_install(
pool_type: backend::cluster::PoolType,
initialize_immediately: bool,
) -> GlobalResult<String> {
let tunnel_name = "tunnel";

// MARK: Common (pre)
let mut script = vec![
components::common(),
components::node_exporter::install(),
components::sysctl::install(),
components::traefik::install(),
components::traefik::tunnel()?,
components::traefik::tunnel(tunnel_name)?,
components::vector::install(),
];

Expand All @@ -40,7 +42,10 @@ pub async fn gen_install(
}

// MARK: Common (post)
script.push(components::rivet::create_hook(initialize_immediately)?);
script.push(components::rivet::create_hook(
tunnel_name,
initialize_immediately,
)?);

let joined = script.join("\n\necho \"======\"\n\n");
Ok(format!("#!/usr/bin/env bash\nset -eu\n\n{joined}"))
Expand Down