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

[UX] Friendly error message when mounting fails with non-empty mount path #1908

Merged
merged 25 commits into from
May 20, 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
31 changes: 22 additions & 9 deletions sky/backends/cloud_vm_ray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3634,15 +3634,28 @@ def _execute_storage_mounts(self, handle: CloudVmRayResourceHandle,
if storage_obj.source else storage_obj.name)
if isinstance(src_print, list):
src_print = ', '.join(src_print)
backend_utils.parallel_data_transfer_to_nodes(
runners,
source=src_print,
target=dst,
cmd=mount_cmd,
run_rsync=False,
action_message='Mounting',
log_path=log_path,
)
try:
backend_utils.parallel_data_transfer_to_nodes(
runners,
source=src_print,
target=dst,
cmd=mount_cmd,
run_rsync=False,
action_message='Mounting',
log_path=log_path,
)
except exceptions.CommandError as e:
if e.returncode == exceptions.MOUNT_PATH_NON_EMPTY_CODE:
mount_path = (f'{colorama.Fore.RED}'
f'{colorama.Style.BRIGHT}{dst}'
f'{colorama.Style.RESET_ALL}')
error_msg = (f'Mount path {mount_path} is non-empty.'
f' {mount_path} may be a standard unix '
f'path or may contain files from a previous'
f' task. To fix, change the mount path'
f' to an empty or non-existent path.')
raise RuntimeError(error_msg) from None

end = time.time()
logger.debug(f'Storage mount sync took {end - start} seconds.')

Expand Down
6 changes: 4 additions & 2 deletions sky/data/mounting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import textwrap
from typing import Optional

from sky import exceptions


def get_mounting_command(
mount_path: str,
Expand Down Expand Up @@ -59,8 +61,8 @@ def get_mounting_command(
else
# Check if mount path contains files
if [ "$(ls -A $MOUNT_PATH)" ]; then
echo "Mount path $MOUNT_PATH is not empty. Please make sure its empty."
exit 1
echo "Mount path $MOUNT_PATH is not empty. Please mount to another path or remove it first."
exit {exceptions.MOUNT_PATH_NON_EMPTY_CODE}
fi
fi
echo "Mounting $SOURCE_BUCKET to $MOUNT_PATH with $MOUNT_BINARY..."
Expand Down
2 changes: 2 additions & 0 deletions sky/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
KEYBOARD_INTERRUPT_CODE = 130
SIGTSTP_CODE = 146
RSYNC_FILE_NOT_FOUND_CODE = 23
# Arbitrarily chosen value. Used in SkyPilot's storage mounting scripts
MOUNT_PATH_NON_EMPTY_CODE = 42
landscapepainter marked this conversation as resolved.
Show resolved Hide resolved


class ResourcesUnavailableError(Exception):
Expand Down