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

[GCP Storage] Upgrade GCSFuse version #1829

Merged
merged 10 commits into from
Apr 11, 2023
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
5 changes: 3 additions & 2 deletions sky/clouds/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
]

_GCLOUD_INSTALLATION_LOG = '~/.sky/logs/gcloud_installation.log'
_GCLOUD_VERSION = '424.0.0'
# Need to be run with /bin/bash
# We factor out the installation logic to keep it align in both spot
# controller and cloud stores.
GCLOUD_INSTALLATION_COMMAND = f'pushd /tmp &>/dev/null && \
gcloud --help > /dev/null 2>&1 || \
{{ mkdir -p {os.path.dirname(_GCLOUD_INSTALLATION_LOG)} && \
wget --quiet https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-382.0.0-linux-x86_64.tar.gz > {_GCLOUD_INSTALLATION_LOG} && \
tar xzf google-cloud-sdk-382.0.0-linux-x86_64.tar.gz >> {_GCLOUD_INSTALLATION_LOG} && \
wget --quiet https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-{_GCLOUD_VERSION}-linux-x86_64.tar.gz > {_GCLOUD_INSTALLATION_LOG} && \
tar xzf google-cloud-sdk-{_GCLOUD_VERSION}-linux-x86_64.tar.gz >> {_GCLOUD_INSTALLATION_LOG} && \
rm -rf ~/google-cloud-sdk >> {_GCLOUD_INSTALLATION_LOG} && \
mv google-cloud-sdk ~/ && \
~/google-cloud-sdk/install.sh -q >> {_GCLOUD_INSTALLATION_LOG} 2>&1 && \
Expand Down
11 changes: 8 additions & 3 deletions sky/data/mounting_utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Helper functions for object store mounting in Sky Storage"""
import random
import textwrap
from typing import Optional


def get_mounting_command(
mount_path: str,
install_cmd: str,
mount_cmd: str,
version_check_cmd: Optional[str] = None,
) -> str:
"""
Generates the mounting command for a given bucket. Generated script first
Expand All @@ -24,6 +26,9 @@ def get_mounting_command(
str: Mounting command with the mounting script as a heredoc.
"""
mount_binary = mount_cmd.split()[0]
installed_check = f'[ -x "$(command -v {mount_binary})" ]'
if version_check_cmd is not None:
installed_check += f' && {version_check_cmd}'
script = textwrap.dedent(f"""
#!/usr/bin/env bash
set -e
Expand All @@ -39,11 +44,11 @@ def get_mounting_command(
fi

# Install MOUNT_BINARY if not already installed
if ! [ -x "$(command -v $MOUNT_BINARY)" ]; then
if {installed_check}; then
echo "$MOUNT_BINARY already installed. Proceeding..."
else
echo "Installing $MOUNT_BINARY..."
{install_cmd}
else
echo "$MOUNT_BINARY already installed. Proceeding..."
fi

# Check if mount path exists
Expand Down
8 changes: 6 additions & 2 deletions sky/data/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ class GcsStore(AbstractStore):
"""

ACCESS_DENIED_MESSAGE = 'AccessDeniedException'
GCSFUSE_VERSION = '0.42.3'

def __init__(self,
name: str,
Expand Down Expand Up @@ -1352,7 +1353,8 @@ def mount_command(self, mount_path: str) -> str:
mount_path: str; Path to mount the bucket to.
"""
install_cmd = ('wget -nc https://github.com/GoogleCloudPlatform/gcsfuse'
'/releases/download/v0.41.10/gcsfuse_0.41.10_amd64.deb '
f'/releases/download/v{self.GCSFUSE_VERSION}/'
f'gcsfuse_{self.GCSFUSE_VERSION}_amd64.deb '
'-O /tmp/gcsfuse.deb && '
'sudo dpkg --install /tmp/gcsfuse.deb')
mount_cmd = ('gcsfuse -o allow_other '
Expand All @@ -1362,8 +1364,10 @@ def mount_command(self, mount_path: str) -> str:
f'--type-cache-ttl {self._TYPE_CACHE_TTL} '
f'--rename-dir-limit {self._RENAME_DIR_LIMIT} '
f'{self.bucket.name} {mount_path}')
version_check_cmd = (
f'gcsfuse --version | grep -q {self.GCSFUSE_VERSION}')
return mounting_utils.get_mounting_command(mount_path, install_cmd,
mount_cmd)
mount_cmd, version_check_cmd)

def _download_file(self, remote_path: str, local_path: str) -> None:
"""Downloads file from remote to local on GS bucket
Expand Down