Skip to content

Commit

Permalink
[Config] Fix ssh proxy command to be null (#2756)
Browse files Browse the repository at this point in the history
* Fix the case where the ssh proxy command is null

* Add test

* format

* format

* fix test
  • Loading branch information
Michaelvll authored Nov 5, 2023
1 parent 53ba415 commit 2d59e3a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sky/utils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,14 @@ def get_config_schema():
'type': 'object',
'required': [],
'additionalProperties': {
'type': 'string',
'anyOf': [
{
'type': 'string'
},
{
'type': 'null'
},
]
}
}]
},
Expand Down
25 changes: 25 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ def test_empty_config(monkeypatch, tmp_path) -> None:
_check_empty_config()


def test_valid_null_proxy_config(monkeypatch, tmp_path) -> None:
"""Test that the config is not loaded if the config file is empty."""
with open(tmp_path / 'valid.yaml', 'w') as f:
f.write(f"""\
aws:
instance_tags:
mytag: myvalue
ssh_proxy_command:
eu-west-1: null
us-east-1: null
use_internal_ips: true
vpc_name: abc
spot:
controller:
resources:
disk_size: 256
""")
monkeypatch.setattr(skypilot_config, 'CONFIG_PATH', tmp_path / 'valid.yaml')
_reload_config()
proxy_config = skypilot_config.get_nested(
('aws', 'ssh_proxy_command', 'eu-west-1'), 'default')
assert proxy_config is None, proxy_config


def test_invalid_field_config(monkeypatch, tmp_path) -> None:
"""Test that the config is not loaded if the config file contains unknown field."""
config_path = tmp_path / 'invalid.yaml'
Expand Down

0 comments on commit 2d59e3a

Please sign in to comment.