Skip to content

Commit

Permalink
fix: remove cgroups from pb manager (#1385)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->
**MERGE AFTER https://app.graphite.dev/github/pr/rivet-gg/rivet/1384/fix-configure-systemd-priorities**
## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Nov 21, 2024
1 parent 93710fc commit 57d6d66
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 37 deletions.
3 changes: 0 additions & 3 deletions docker/dev-full/rivet-client/config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
client:
runner:
flavor: isolate
# Cgroups require privileged containers
use_cgroup: false
cluster:
# This is safe to hardcode
client_id: fc67e54e-5d6a-4726-ab23-77b0e54f068f
Expand All @@ -28,4 +26,3 @@ client:
redirect_logs: false
vector:
address: vector-server:6100

3 changes: 0 additions & 3 deletions docker/monolith/rivet-client/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ client:
data_dir: /data/rivet-client
runner:
flavor: isolate
# Cgroups require privileged containers
use_cgroup: false
cluster:
# This is safe to hardcode
client_id: fc67e54e-5d6a-4726-ab23-77b0e54f068f
Expand All @@ -29,4 +27,3 @@ client:
redirect_logs: false
vector:
address: vector-server:6100

9 changes: 0 additions & 9 deletions packages/infra/client/config/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ pub struct Runner {
/// WebSocket Port for runners on this machine to connect to.
pub port: Option<u16>,

/// If true, a cgroup will be created for the runners.
///
/// This should not be disabled if running the client with a daemon.
pub use_cgroup: Option<bool>,

pub container_runner_binary_path: Option<PathBuf>,
pub isolate_runner_binary_path: Option<PathBuf>,
}
Expand All @@ -105,10 +100,6 @@ impl Runner {
self.port.unwrap_or(7080)
}

pub fn use_cgroup(&self) -> bool {
self.use_cgroup.unwrap_or(true)
}

pub fn container_runner_binary_path(&self) -> PathBuf {
self.container_runner_binary_path
.clone()
Expand Down
1 change: 0 additions & 1 deletion packages/infra/client/manager/src/actor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ impl Actor {
&ctx.config().runner.container_runner_binary_path(),
ctx.actor_path(self.actor_id),
&runner_env,
ctx.config().runner.use_cgroup(),
)?
}
// Shared runner
Expand Down
1 change: 0 additions & 1 deletion packages/infra/client/manager/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ impl Ctx {
&self.config().runner.isolate_runner_binary_path(),
working_path,
&[],
self.config().runner.use_cgroup(),
)?;
let pid = runner.pid();

Expand Down
11 changes: 0 additions & 11 deletions packages/infra/client/manager/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ impl Handle {
runner_binary_path: &Path,
working_path: PathBuf,
env: &[(&str, String)],
use_cgroup: bool,
) -> Result<Self> {
// Prepare the arguments for the runner
let runner_args = vec![working_path.to_str().context("bad path")?];
Expand Down Expand Up @@ -189,16 +188,6 @@ impl Handle {
let orphan_pid_bytes = child.as_raw().to_le_bytes();
write(pipe_write, &orphan_pid_bytes)?;

if use_cgroup {
// Write orphan PID to the runners cgroup so that it is no longer part of the parent
// cgroup. This is important for allowing systemd to restart pegboard without
// restarting orphans.
let mut cgroup_procs = std::fs::File::options()
.append(true)
.open(Path::new(utils::CGROUP_PATH).join("cgroup.procs"))?;
cgroup_procs.write_all(format!("{}\n", child.as_raw()).as_bytes())?;
}

// Exit the intermediate child
std::process::exit(0);
}
Expand Down
9 changes: 0 additions & 9 deletions packages/infra/client/manager/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub mod sql;
const MAX_QUERY_RETRIES: usize = 16;
const QUERY_RETRY: Duration = Duration::from_millis(500);
const TXN_RETRY: Duration = Duration::from_millis(250);
pub const CGROUP_PATH: &str = "/sys/fs/cgroup/pegboard_runners";

pub async fn init_dir(config: &Config) -> Result<()> {
let data_dir = config.client.data_dir();
Expand Down Expand Up @@ -82,14 +81,6 @@ pub async fn init_dir(config: &Config) -> Result<()> {
x => x.context("failed to create /db dir in data dir")?,
}

if config.client.runner.use_cgroup() {
// Create cgroup folder for runners
match fs::create_dir(CGROUP_PATH).await {
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {}
x => x.context("failed to create cgroup dir for runners")?,
}
}

Ok(())
}

Expand Down

0 comments on commit 57d6d66

Please sign in to comment.