From c93cc9a73ea0208b9cd5860ea36581710f86504d Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Fri, 31 May 2024 00:41:46 +0000 Subject: [PATCH] fix(job-run): correctly clean up leaked proxied ports --- svc/pkg/job-run/worker/src/workers/stop.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/svc/pkg/job-run/worker/src/workers/stop.rs b/svc/pkg/job-run/worker/src/workers/stop.rs index 5a261b57b..49241bf0e 100644 --- a/svc/pkg/job-run/worker/src/workers/stop.rs +++ b/svc/pkg/job-run/worker/src/workers/stop.rs @@ -1,5 +1,6 @@ use chirp_worker::prelude::*; use proto::backend::pkg::*; +use redis::AsyncCommands; use tokio::task; #[derive(Debug, sqlx::FromRow)] @@ -52,6 +53,16 @@ async fn worker(ctx: &OperationContext) -> GlobalRe } }; + // HACK: Remove from proxied ports early. This also gets removed in job-run-cleanup, but that + // may not run correclty if the dispatched job id is not set correctly. + ctx.redis_job() + .await? + .hdel( + util_job::key::proxied_ports(run_row.region_id), + run_id.to_string(), + ) + .await?; + // Get the region let region_res = op!([ctx] region_get { region_ids: vec![run_row.region_id.into()],