Skip to content

Commit

Permalink
Change 'detach' container option when pty is given
Browse files Browse the repository at this point in the history
fixes #850
  • Loading branch information
ivotron committed Jun 7, 2020
1 parent e490b54 commit 3b03df8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/popper/runner_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def _get_container_kwargs(self, step, img, name):
"working_dir": "/workspace",
"environment": self._prepare_environment(step),
"entrypoint": step.runs if step.runs else None,
"detach": True,
"detach": not self._config.pty,
"tty": self._config.pty,
"stdin_open": self._config.pty,
}
Expand Down
32 changes: 31 additions & 1 deletion cli/test/test_runner_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def test_get_container_kwargs(self):
"environment": {"FOO": "bar"},
},
},
"resource_manager": {"name": "slurm"},
}

config = ConfigLoader.load(
Expand Down Expand Up @@ -189,6 +188,37 @@ def test_get_container_kwargs(self):
},
)

# check container kwargs when pty is enabled
config = ConfigLoader.load(
config_file=config_dict, workspace_dir="/path/to/workdir", pty=True
)

with DockerRunner(init_docker_client=False, config=config) as dr:
args = dr._get_container_kwargs(step, "alpine:3.9", "container_a")

self.assertEqual(
args,
{
"image": "alpine:3.9",
"command": ["ls"],
"name": "container_a",
"volumes": [
"/path/to/workdir:/workspace",
"/var/run/docker.sock:/var/run/docker.sock",
"/path/in/host:/path/in/container",
],
"working_dir": "/workspace",
"environment": {"FOO": "bar"},
"entrypoint": None,
"detach": False,
"stdin_open": True,
"tty": True,
"privileged": True,
"hostname": "popper.local",
"domainname": "www.example.org",
},
)

@unittest.skipIf(os.environ.get("ENGINE", "docker") != "docker", "ENGINE != docker")
def test_get_build_info(self):
step = Box(
Expand Down

0 comments on commit 3b03df8

Please sign in to comment.