Skip to content

Commit 36252ec

Browse files
committed
fix(pegboard): fix netns path bug (#2431)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 9cd808a commit 36252ec

File tree

4 files changed

+50
-32
lines changed

4 files changed

+50
-32
lines changed

packages/common/chirp-workflow/core/src/ctx/workflow.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,9 @@ impl WorkflowCtx {
517517

518518
let duration = (u64::try_from(wake_deadline_ts)?)
519519
.saturating_sub(u64::try_from(rivet_util::timestamp::now())?);
520-
tokio::time::sleep(Duration::from_millis(duration)).await;
520+
tokio::time::sleep(Duration::from_millis(duration))
521+
.instrument(tracing::info_span!("backoff_sleep"))
522+
.await;
521523
}
522524

523525
match self

packages/edge/infra/client/manager/src/actor/setup.rs

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ impl Actor {
522522
let cmd_out = Command::new("ip")
523523
.arg("netns")
524524
.arg("add")
525-
.arg(self.actor_id.to_string())
525+
.arg(netns_path.file_name().context("bad netns path")?)
526526
.output()
527527
.await?;
528528
ensure!(
@@ -750,7 +750,7 @@ impl Actor {
750750
match Command::new("cnitool")
751751
.arg("del")
752752
.arg(&ctx.config().cni.network_name())
753-
.arg(netns_path)
753+
.arg(&netns_path)
754754
.env("CNI_PATH", &ctx.config().cni.bin_path())
755755
.env("NETCONFPATH", &ctx.config().cni.config_path())
756756
.env("CNI_IFNAME", &ctx.config().cni.network_interface)
@@ -789,33 +789,42 @@ impl Actor {
789789
}
790790
}
791791

792-
// Clean up network
793-
match Command::new("ip")
794-
.arg("netns")
795-
.arg("del")
796-
.arg(self.actor_id.to_string())
797-
.output()
798-
.await
799-
{
800-
Result::Ok(cmd_out) => {
801-
if !cmd_out.status.success() {
792+
if let Some(netns_name) = netns_path.file_name() {
793+
// Clean up network
794+
match Command::new("ip")
795+
.arg("netns")
796+
.arg("del")
797+
.arg(netns_name)
798+
.output()
799+
.await
800+
{
801+
Result::Ok(cmd_out) => {
802+
if !cmd_out.status.success() {
803+
tracing::error!(
804+
actor_id=?self.actor_id,
805+
generation=?self.generation,
806+
stdout=%std::str::from_utf8(&cmd_out.stdout).unwrap_or("<failed to parse stdout>"),
807+
stderr=%std::str::from_utf8(&cmd_out.stderr).unwrap_or("<failed to parse stderr>"),
808+
"failed `ip netns` command",
809+
);
810+
}
811+
}
812+
Err(err) => {
802813
tracing::error!(
803814
actor_id=?self.actor_id,
804815
generation=?self.generation,
805-
stdout=%std::str::from_utf8(&cmd_out.stdout).unwrap_or("<failed to parse stdout>"),
806-
stderr=%std::str::from_utf8(&cmd_out.stderr).unwrap_or("<failed to parse stderr>"),
807-
"failed `ip netns` command",
816+
?err,
817+
"failed to run `ip` command",
808818
);
809819
}
810820
}
811-
Err(err) => {
812-
tracing::error!(
813-
actor_id=?self.actor_id,
814-
generation=?self.generation,
815-
?err,
816-
"failed to run `ip` command",
817-
);
818-
}
821+
} else {
822+
tracing::error!(
823+
actor_id=?self.actor_id,
824+
generation=?self.generation,
825+
?netns_path,
826+
"invalid netns path",
827+
);
819828
}
820829
}
821830
}

packages/edge/infra/guard/core/src/proxy_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl ProxyState {
276276
}
277277
}
278278

279-
#[tracing::instrument(skip_all)]
279+
#[tracing::instrument(skip(self))]
280280
async fn resolve_route(
281281
&self,
282282
hostname: &str,

packages/edge/infra/guard/core/src/server.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,15 @@ pub async fn run_server(
125125
let conn = server.serve_connection_with_upgrades(io, service);
126126
let conn = graceful.watch(conn.into_owned());
127127

128-
tokio::spawn(async move {
129-
if let Err(err) = conn.await {
130-
error!("{} connection error: {}", port_type_str, err);
128+
tokio::spawn(
129+
async move {
130+
if let Err(err) = conn.await {
131+
error!("{} connection error: {}", port_type_str, err);
132+
}
133+
info!("{} connection dropped: {}", port_type_str, remote_addr);
131134
}
132-
info!("{} connection dropped: {}", port_type_str, remote_addr);
133-
}.instrument(tracing::info_span!("process_connection_task")));
135+
.instrument(tracing::info_span!(parent: None, "process_connection_task")),
136+
);
134137
}
135138

136139
// Accept connections until we receive a shutdown signal
@@ -176,7 +179,11 @@ pub async fn run_server(
176179

177180
// Accept TLS connection in a separate task to avoid ownership issues
178181
tokio::spawn(async move {
179-
match acceptor_clone.accept(tcp_stream).await {
182+
match acceptor_clone
183+
.accept(tcp_stream)
184+
.instrument(tracing::info_span!("accept"))
185+
.await
186+
{
180187
Ok(tls_stream) => {
181188
info!("TLS handshake successful for {}", remote_addr);
182189

@@ -206,7 +213,7 @@ pub async fn run_server(
206213
error!("TLS handshake failed for {}: {}", remote_addr, e);
207214
}
208215
}
209-
}.instrument(tracing::info_span!("process_tls_connection_task")));
216+
}.instrument(tracing::info_span!(parent: None, "process_tls_connection_task")));
210217
} else {
211218
// Fallback to non-TLS handling (useful for testing)
212219
// In production, this would not secure the connection

0 commit comments

Comments
 (0)