diff --git a/sky/provision/docker_utils.py b/sky/provision/docker_utils.py index 303032128e3..b5394cd560c 100644 --- a/sky/provision/docker_utils.py +++ b/sky/provision/docker_utils.py @@ -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', ] @@ -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. diff --git a/tests/test_smoke.py b/tests/test_smoke.py index 8c85356a4e8..340de5cf842 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -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' ] @@ -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()