Skip to content

Commit

Permalink
WIP: Add ability for worker to bind to local docker socket for testin…
Browse files Browse the repository at this point in the history
…g exports

I am 99% sure this works but it has a long testing cycle and I'm having key rotation issues.

Signed-off-by: Travis Elliott Davis <edavis@chef.io>
  • Loading branch information
Travis Elliott Davis committed Jan 26, 2018
1 parent cdaaaca commit 034c594
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .studiorc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export GITHUB_CLIENT_SECRET
export SSL_CERT_FILE
export GITHUB_APP_ID
export GITHUB_APP_URL
export DEV_MODE

no_install_deps() {
local file="/src/components/${1}/cleanup"
Expand Down Expand Up @@ -331,6 +332,9 @@ DOCS

install-packages

# Forces the worker to use a bound docker socket
DEV_MODE=true

ENV_CONFIG="/src/.secrets/habitat-env"

if [[ -f "${ENV_CONFIG}" ]]; then
Expand Down
1 change: 1 addition & 0 deletions components/builder-worker/habitat/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ bldr_url = "https://bldr.habitat.sh"
features_enabled = ""
airlock_enabled = true
recreate_ns_dir = false
dev_mode = false

[github]
url = "https://api.github.com"
Expand Down
5 changes: 4 additions & 1 deletion components/builder-worker/src/runner/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use hab_core::os::process::{self, Pid, Signal};

use error::{Error, Result};
use runner::log_pipe::LogPipe;
use runner::{NONINTERACTIVE_ENVVAR, RUNNER_DEBUG_ENVVAR};
use runner::{NONINTERACTIVE_ENVVAR, RUNNER_DEBUG_ENVVAR, DEV_MODE};
use runner::workspace::Workspace;

lazy_static! {
Expand Down Expand Up @@ -233,6 +233,9 @@ impl<'a> DockerExporter<'a> {
}

fn dockerd_sock(&self) -> String {
if let Some(_) = env::var_os(DEV_MODE) {
return "unix:///var/run/docker.sock".to_string()
}
format!(
"unix://{}",
self.dockerd_path().join("var/run/docker.sock").display()
Expand Down
2 changes: 2 additions & 0 deletions components/builder-worker/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const NONINTERACTIVE_ENVVAR: &'static str = "HAB_NONINTERACTIVE";

/// Environment variable to enable or disable debug output in runner's studio
const RUNNER_DEBUG_ENVVAR: &'static str = "BUILDER_RUNNER_DEBUG";
/// Environment variable to enable or disable dev mode.
const DEV_MODE: &'static str = "DEV_MODE";
/// In-memory zmq address of Job RunnerMgr
const INPROC_ADDR: &'static str = "inproc://runner";
/// Protocol message to indicate the Job Runner has received a work request
Expand Down
1 change: 0 additions & 1 deletion components/builder-worker/src/runner/studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl<'a> Studio<'a> {
}
}
cmd.stdout(Stdio::piped());
cmd.stderr(Stdio::piped());
cmd.arg("-k"); // Origin key
cmd.arg(self.workspace.job.origin());
cmd.arg("build");
Expand Down

0 comments on commit 034c594

Please sign in to comment.