Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
romilbhardwaj committed Sep 15, 2023
1 parent f74c9df commit 657cd6f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
10 changes: 6 additions & 4 deletions sky/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,16 @@ def setup_kubernetes_authentication(config: Dict[str, Any]) -> Dict[str, Any]:
nodeport_mode = kubernetes_utils.KubernetesNetworkingMode.NODEPORT
port_forward_mode = kubernetes_utils.KubernetesNetworkingMode.PORTFORWARD
network_mode_str = skypilot_config.get_nested(('kubernetes', 'networking'),
port_forward_mode.value)
port_forward_mode.value)
try:
network_mode = kubernetes_utils.KubernetesNetworkingMode.from_str(network_mode_str)
network_mode = kubernetes_utils.KubernetesNetworkingMode.from_str(
network_mode_str)
except ValueError as e:
# Add message saying "Please check: ~/.sky/config.yaml" to the error
# message.
e.message += f'\nPlease check {skypilot_config.CONFIG_PATH}.'
raise
with ux_utils.print_exception_no_traceback():
raise ValueError(str(e) + ' Please check: ~/.sky/config.yaml.') \
from None
get_or_generate_keys()

# Run kubectl command to add the public key to the cluster.
Expand Down
4 changes: 2 additions & 2 deletions sky/clouds/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def make_deploy_resources_variables(
image_id = service_catalog.get_image_id_from_tag(image_id,
clouds='kubernetes')
# TODO(romilb): Create a lightweight image for SSH jump host
ssh_jump_image = service_catalog.get_image_id_from_tag(self.IMAGE_CPU,
clouds='kubernetes')
ssh_jump_image = service_catalog.get_image_id_from_tag(
self.IMAGE_CPU, clouds='kubernetes')

k8s_acc_label_key = None
k8s_acc_label_value = None
Expand Down
4 changes: 2 additions & 2 deletions sky/utils/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def ssh_options_list(
# process running ProxyCommand is kept running as long as the ssh session
# is running and the ControlMaster keeps the session, which results in
# 'ControlPersist' number of seconds delay per ssh commands ran.
if (ssh_control_name is not None and docker_ssh_proxy_command is None
and not disable_control_master):
if (ssh_control_name is not None and docker_ssh_proxy_command is None and
not disable_control_master):
arg_dict.update({
# Control path: important optimization as we do multiple ssh in one
# sky.launch().
Expand Down
19 changes: 10 additions & 9 deletions sky/utils/kubernetes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ def from_str(cls, mode: str) -> 'KubernetesNetworkingMode':
return cls.PORTFORWARD
else:
raise ValueError(f'Unsupported kubernetes networking mode: '
f'{mode}. The mode has to be either '
f'{mode}. The mode must be either '
f'\'{cls.PORTFORWARD.value}\' or '
f'\'{cls.NODEPORT.value}\'. ')



class KubernetesServiceType(enum.Enum):
"""Enum for the different types of services."""
NODEPORT = 'NodePort'
Expand Down Expand Up @@ -809,8 +808,8 @@ def setup_ssh_jump_pod(ssh_jump_name: str, ssh_jump_image: str,
"""
# Fill in template - service is created separately so service_type is not
# required, so we pass in empty str.
content = fill_ssh_jump_template(ssh_key_secret, ssh_jump_image, ssh_jump_name,
'')
content = fill_ssh_jump_template(ssh_key_secret, ssh_jump_image,
ssh_jump_name, '')
# ServiceAccount
try:
kubernetes.core_api().create_namespaced_service_account(
Expand Down Expand Up @@ -902,15 +901,17 @@ def find(l, predicate):
# and prevent a dangling ssh jump pod, lets remove it and
# the service. Otherwise main container is ready and its lifecycle
# management script takes care of the cleaning.
kubernetes.core_api().delete_namespaced_pod(ssh_jump_name, namespace)
kubernetes.core_api().delete_namespaced_pod(ssh_jump_name,
namespace)
kubernetes.core_api().delete_namespaced_service(
ssh_jump_name, namespace)
# only warn and proceed as usual
except kubernetes.api_exception() as e:
logger.warning(f'Tried to check ssh jump pod {ssh_jump_name},'
f' but got error {e}\n. Consider running `kubectl '
f'delete pod {ssh_jump_name} -n {namespace}` to manually '
'remove the pod if it has crashed.')
logger.warning(
f'Tried to check ssh jump pod {ssh_jump_name},'
f' but got error {e}\n. Consider running `kubectl '
f'delete pod {ssh_jump_name} -n {namespace}` to manually '
'remove the pod if it has crashed.')
# We encountered an issue while checking ssh jump pod. To be on
# the safe side, lets remove its service so the port is freed
try:
Expand Down

0 comments on commit 657cd6f

Please sign in to comment.