Skip to content

Commit

Permalink
ignore check failed when test with dryrun
Browse files Browse the repository at this point in the history
if there is no kube config in env, ignore ValueError when launch
with dryrun. For now, we don't support check schema offline.
  • Loading branch information
chesterli29 committed Dec 13, 2024
1 parent a0f29e5 commit 47e724d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,8 @@ def write_cluster_config(
tmp_yaml_path,
cluster_config_overrides=to_provision.cluster_config_overrides)
kubernetes_utils.combine_metadata_fields(tmp_yaml_path)
valid, message = kubernetes_utils.check_pod_config(tmp_yaml_path)
valid, message = kubernetes_utils.check_pod_config(
tmp_yaml_path, dryrun)
if not valid:
raise exceptions.InvalidCloudConfigs(
f'There are invalid config in pod_config, deatil: {message}')
Expand Down
8 changes: 7 additions & 1 deletion sky/provision/kubernetes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,8 @@ def check_credentials(context: Optional[str],
return True, None


def check_pod_config(cluster_yaml_path: str) -> Tuple[bool, Optional[str]]:
def check_pod_config(cluster_yaml_path: str, dryrun: bool) \
-> Tuple[bool, Optional[str]]:
"""Check if the pod_config is a valid pod config
Using create_namespaced_pod api with dry_run to check the pod_config
Expand Down Expand Up @@ -926,6 +927,11 @@ def check_pod_config(cluster_yaml_path: str) -> Tuple[bool, Optional[str]]:
error_msg = str(e)
return False, error_msg
except ValueError as e:
if dryrun:
logger.debug('ignore ValueError as there is no kube config '
'in the enviroment with dry_run. '
'For now we don\'t support check pod_config offline.')
return True, None
return False, common_utils.format_exception(e)
except Exception as e: # pylint: disable=broad-except
return False, ('An error occurred: '
Expand Down

0 comments on commit 47e724d

Please sign in to comment.