Skip to content

Commit

Permalink
Add environment variables to create container
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Michaelis <code@mgjm.de>
  • Loading branch information
mgjm committed Jul 11, 2023
1 parent 3605b28 commit b4e18e1
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 196 deletions.
1 change: 1 addition & 0 deletions conmon-rs/common/proto/conmon.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface Conmon {
commandArgs @9 :List(Text);
metadataOld @10 :Data; # deprecated
metadata @11 :Metadata; # Standard metadata to carry.
envVars @12 :TextTextMap;
}

struct LogDriver {
Expand Down
2 changes: 2 additions & 0 deletions conmon-rs/server/src/child_reaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl ChildReaper {
stdin: bool,
container_io: &mut ContainerIO,
pidfile: &Path,
env_vars: Vec<(String, String)>,
) -> Result<(u32, CancellationToken)>
where
P: AsRef<OsStr>,
Expand All @@ -79,6 +80,7 @@ impl ChildReaper {
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.envs(env_vars)
.spawn()
.context("spawn child process: {}")?;

Expand Down
6 changes: 4 additions & 2 deletions conmon-rs/server/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
capnp_util,
child::Child,
container_io::{ContainerIO, SharedContainerIO},
container_log::ContainerLog,
Expand Down Expand Up @@ -134,13 +135,14 @@ impl conmon::Server for Server {
let runtime = self.config().runtime().clone();
let exit_paths = capnp_vec_path!(req.get_exit_paths());
let oom_exit_paths = capnp_vec_path!(req.get_oom_exit_paths());
let env_vars = pry!(req.get_env_vars().and_then(capnp_util::into_map));

Promise::from_future(
async move {
capnp_err!(container_log.write().await.init().await)?;

let (grandchild_pid, token) = capnp_err!(match child_reaper
.create_child(runtime, args, stdin, &mut container_io, &pidfile)
.create_child(runtime, args, stdin, &mut container_io, &pidfile, env_vars)
.await
{
Err(e) => {
Expand Down Expand Up @@ -216,7 +218,7 @@ impl conmon::Server for Server {
Promise::from_future(
async move {
match child_reaper
.create_child(&runtime, &args, false, &mut container_io, &pidfile)
.create_child(&runtime, &args, false, &mut container_io, &pidfile, vec![])
.await
{
Ok((grandchild_pid, token)) => {
Expand Down
Loading

0 comments on commit b4e18e1

Please sign in to comment.