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

better nc error message on mac #3374

Merged
merged 28 commits into from
Apr 15, 2024
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7dfcba1
initial commit
Feb 17, 2024
212df29
Merge branch 'skypilot-org:master' into master
shethhriday29 Feb 17, 2024
a08c034
newline
Feb 17, 2024
b85cbf9
comments
Feb 17, 2024
4fbfe17
run linter
Feb 17, 2024
6fc77e1
reminder for down
Feb 18, 2024
d6cb993
tentatively done with example
Feb 18, 2024
2d5aceb
formatting
Feb 18, 2024
4e1954a
yapf
Feb 19, 2024
eb22f62
Merge branch 'skypilot-org:master' into master
shethhriday29 Feb 22, 2024
27a8905
[Storage] Storage mounting tool permissions fix (#3215)
romilbhardwaj Feb 22, 2024
41a63df
[LLM] Example for Serving Gemma (#3207)
Michaelvll Feb 23, 2024
2b17e91
[LLM] Add logo for Gemma (#3220)
Michaelvll Feb 23, 2024
b326d12
Minor fixes for release 0.5.0 (#3212)
Michaelvll Feb 23, 2024
6d77872
[Docker] Add retry for docker pull due to daemon not ready (#3218)
Michaelvll Feb 24, 2024
cb695d5
added comments
Feb 26, 2024
94221eb
Merge branch 'skypilot-org:master' into master
shethhriday29 Feb 26, 2024
888f1a8
quick fix
Feb 27, 2024
4877669
finished pip issues
Feb 29, 2024
7a208dd
fix
Feb 29, 2024
152e36a
fix storage error message, add example link to docs
romilbhardwaj Feb 29, 2024
cf556ed
Merge branch 'master' of https://github.com/skypilot-org/skypilot int…
romilbhardwaj Feb 29, 2024
8213f02
Merge branch 'skypilot-org:master' into master
shethhriday29 Mar 3, 2024
60a530d
Merge branch 'skypilot-org:master' into master
shethhriday29 Mar 22, 2024
3d12439
changed error message if default nc installed on mac
Mar 27, 2024
c6af144
Merge branch 'skypilot-org:master' into nc-error
shethhriday29 Mar 27, 2024
0746b45
refactored check_port_forward_mode_dependencies function
Mar 28, 2024
e42d5b3
update comment
romilbhardwaj Apr 15, 2024
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
78 changes: 57 additions & 21 deletions sky/provision/kubernetes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,28 +1025,64 @@ def fill_ssh_jump_template(ssh_key_secret: str, ssh_jump_image: str,


def check_port_forward_mode_dependencies() -> None:
"""Checks if 'socat' is installed"""
# We store the dependency list as a list of lists. Each inner list
# contains the name of the dependency, the command to check if it is
# installed, and the package name to install it.
dependency_list = [['socat', ['socat', '-V'], 'socat'],
['nc', ['nc', '-h'], 'netcat']]
for name, check_cmd, install_cmd in dependency_list:
try:
subprocess.run(check_cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True)
except (FileNotFoundError, subprocess.CalledProcessError):
"""Checks if 'socat' and 'nc' are installed"""

# Construct runtime errors
socat_default_error = RuntimeError(
f'`socat` is required to setup Kubernetes cloud with '
f'`{kubernetes_enums.KubernetesNetworkingMode.PORTFORWARD.value}` ' # pylint: disable=line-too-long
'default networking mode and it is not installed. '
'On Debian/Ubuntu, install it with:\n'
f' $ sudo apt install socat\n'
f'On MacOS, install it with: \n'
f' $ brew install socat')
netcat_default_error = RuntimeError(
f'`nc` is required to setup Kubernetes cloud with '
f'`{kubernetes_enums.KubernetesNetworkingMode.PORTFORWARD.value}` ' # pylint: disable=line-too-long
'default networking mode and it is not installed. '
'On Debian/Ubuntu, install it with:\n'
f' $ sudo apt install netcat\n'
f'On MacOS, install it with: \n'
f' $ brew install netcat')
mac_installed_error = RuntimeError(
f'The default MacOS `nc` is installed. However, for '
f'`{kubernetes_enums.KubernetesNetworkingMode.PORTFORWARD.value}` ' # pylint: disable=line-too-long
'default networking mode, GNU netcat is required. '
f'On MacOS, install it with: \n'
f' $ brew install netcat')

# Ensure socat is installed
try:
subprocess.run(['socat', '-V'],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True)
except (FileNotFoundError, subprocess.CalledProcessError):
with ux_utils.print_exception_no_traceback():
raise socat_default_error from None

# Ensure netcat is installed
#
# In some cases, the user may have the default MacOS nc installed, which
# does not support the -z flag. To use the -z flag for port scanning,
# they need GNU nc installed. We check for this case and raise an error.
try:
netcat_output = subprocess.run(['nc', '-h'],
capture_output=True,
check=False)
nc_mac_installed = netcat_output.returncode == 1 and 'apple' in str(
netcat_output.stderr)

if nc_mac_installed:
with ux_utils.print_exception_no_traceback():
raise mac_installed_error from None
elif netcat_output.returncode != 0:
with ux_utils.print_exception_no_traceback():
raise RuntimeError(
f'`{name}` is required to setup Kubernetes cloud with '
f'`{kubernetes_enums.KubernetesNetworkingMode.PORTFORWARD.value}` ' # pylint: disable=line-too-long
'default networking mode and it is not installed. '
'On Debian/Ubuntu, install it with:\n'
f' $ sudo apt install {install_cmd}\n'
f'On MacOS, install it with: \n'
f' $ brew install {install_cmd}') from None
raise netcat_default_error from None

except FileNotFoundError:
with ux_utils.print_exception_no_traceback():
raise netcat_default_error from None


def get_endpoint_debug_message() -> str:
Expand Down
Loading