Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create container with environment variables #1499

Merged
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
2 changes: 2 additions & 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 Expand Up @@ -72,6 +73,7 @@ interface Conmon {
terminal @3 :Bool;
metadataOld @4 :Data; # deprecated
metadata @5 :Metadata; # Standard metadata to carry.
envVars @6 :TextTextMap;
}

struct ExecSyncContainerResponse {
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
14 changes: 12 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 @@ -212,11 +214,19 @@ impl conmon::Server for Server {

let command = pry!(req.get_command());
let args = pry_err!(self.generate_exec_sync_args(&id, &pidfile, &container_io, &command));
let env_vars = pry!(req.get_env_vars().and_then(capnp_util::into_map));

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,
env_vars,
)
.await
{
Ok((grandchild_pid, token)) => {
Expand Down
Loading
Loading