Skip to content

Commit

Permalink
[docker] Add /dev/fuse for mounting containers in docker (#3343)
Browse files Browse the repository at this point in the history
* add /dev/fuse

* add smoke tests and fuse installation
  • Loading branch information
romilbhardwaj authored Mar 22, 2024
1 parent 230b858 commit acb49ee
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
12 changes: 10 additions & 2 deletions sky/provision/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def docker_start_cmds(
env_flags,
user_options_str,
'--net=host',
# SkyPilot: Add following options to enable fuse.
'--cap-add=SYS_ADMIN',
'--device=/dev/fuse',
'--security-opt=apparmor:unconfined',
image,
'bash',
]
Expand Down Expand Up @@ -246,8 +250,12 @@ def initialize(self) -> str:
run_env='docker')
# Install dependencies.
self._run(
'sudo apt-get update; sudo apt-get install -y rsync curl wget '
'patch openssh-server python3-pip;',
'sudo apt-get update; '
# Our mount script will install gcsfuse without fuse package.
# We need to install fuse package first to enable storage mount.
# The dpkg option is to suppress the prompt for fuse installation.
'sudo apt-get -o DPkg::Options::="--force-confnew" install -y '
'rsync curl wget patch openssh-server python3-pip fuse;',
run_env='docker')

# Copy local authorized_keys to docker container.
Expand Down
39 changes: 38 additions & 1 deletion tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
'touch ~/tmpfile', 'mkdir -p ~/tmp-workdir',
'touch ~/tmp-workdir/tmp\ file', 'touch ~/tmp-workdir/tmp\ file2',
'touch ~/tmp-workdir/foo',
'ln -f -s ~/tmp-workdir/ ~/tmp-workdir/circle-link',
'[ ! -e ~/tmp-workdir/circle-link ] && ln -s ~/tmp-workdir/ ~/tmp-workdir/circle-link || true',
'touch ~/.ssh/id_rsa.pub'
]

Expand Down Expand Up @@ -970,6 +970,43 @@ def test_kubernetes_storage_mounts():
run_one_test(test)


@pytest.mark.parametrize(
"image_id",
[
"docker:nvidia/cuda:11.8.0-devel-ubuntu18.04",
"docker:ubuntu:18.04",
# Test image with python 3.11 installed by default.
"docker:continuumio/miniconda3",
])
def test_docker_storage_mounts(generic_cloud: str, image_id: str):
# Tests bucket mounting on docker container
name = _get_cluster_name()
timestamp = str(time.time()).replace('.', '')
storage_name = f'sky-test-{timestamp}'
template_str = pathlib.Path(
'tests/test_yamls/test_storage_mounting.yaml.j2').read_text()
template = jinja2.Template(template_str)
content = template.render(storage_name=storage_name)
with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as f:
f.write(content)
f.flush()
file_path = f.name
test_commands = [
*storage_setup_commands,
f'sky launch -y -c {name} --cloud {generic_cloud} --image-id {image_id} {file_path}',
f'sky logs {name} 1 --status', # Ensure job succeeded.
f'aws s3 ls {storage_name}/hello.txt || '
f'gsutil ls gs://{storage_name}/hello.txt',
]
test = Test(
'docker_storage_mounts',
test_commands,
f'sky down -y {name}; sky storage delete -y {storage_name}',
timeout=20 * 60, # 20 mins
)
run_one_test(test)


@pytest.mark.cloudflare
def test_cloudflare_storage_mounts(generic_cloud: str):
name = _get_cluster_name()
Expand Down

0 comments on commit acb49ee

Please sign in to comment.