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 22 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 @@ -3558,15 +3558,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 exceptions.StorageMountPathError(error_msg) from None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to catch exceptions.MOUNT_PATH_NON_EMPTY_CODE since that's a common case.

What happens if e.returncode != exceptions.MOUNT_PATH_NON_EMPTY_CODE. We should perhaps add a || echo like mentioned here, so the error is surfaced nicely instead of the entire heredoc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current implementation, when e.returncode != exceptions.MOUNT_PATH_NON_EMPTY_CODE (manually setting the exit code of the heredoc to be 99 and MOUNT_PATH_NON_EMPTY_CODE to be 42) and attempting to mount to a non-empty directory, it does surface the error message from the heredoc without displaying the entire heredoc : E 05-05 03:11:59 subprocess_utils.py:70] Mount path /tmp is not empty. Please make sure its empty.

Does it still need the || echo implementation in mounting_utils.py? If so, what error should it be catching? The only error with an exit code in the heredoc from mounting_utils.py is when the $MOUNT_PATH is non-empty, and in this case, it is hard coded that it exits with 42 and echos a error message as well: E 05-05 03:11:59 subprocess_utils.py:70] Mount path /tmp is not empty. Please make sure its empty.

Or perhaps, I misunderstood what you meant. Would you mind elaborating a bit more if this is the case?


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

Expand Down
2 changes: 1 addition & 1 deletion sky/data/mounting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_mounting_command(
# 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."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Mount path $MOUNT_PATH is not empty. Please make sure its empty."
echo "Mount path $MOUNT_PATH is not empty. Please mount to another path or remove it first."

(Suggest a fix for common scenarios first; e.g., if people accidentally mount to /tmp, the first fix should be use another path)


NOTE: I find it confusing that we allow mounting to a /empty-dir without files. The convention in other tools seems to be if the path exists, regardless of whether files exist, then back off.

Copy link
Collaborator Author

@landscapepainter landscapepainter May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the echo message.

What kind of potential issues can be arised by allowing to mount on existing directories?

exit 1
exit 42
landscapepainter marked this conversation as resolved.
Show resolved Hide resolved
fi
fi
echo "Mounting $SOURCE_BUCKET to $MOUNT_PATH with $MOUNT_BINARY..."
Expand Down
7 changes: 7 additions & 0 deletions sky/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
KEYBOARD_INTERRUPT_CODE = 130
SIGTSTP_CODE = 146
RSYNC_FILE_NOT_FOUND_CODE = 23
MOUNT_PATH_NON_EMPTY_CODE = 42
landscapepainter marked this conversation as resolved.
Show resolved Hide resolved


class ResourcesUnavailableError(Exception):
Expand Down Expand Up @@ -164,6 +165,12 @@ class StorageModeError(StorageSpecError):
pass


class StorageMountPathError(StorageSpecError):
# Error raised when bucket is successfully initialized, but mounting fails
# due to non-empty mount path
pass
landscapepainter marked this conversation as resolved.
Show resolved Hide resolved


class FetchIPError(Exception):
"""Raised when fetching the IP fails."""

Expand Down