Skip to content

Commit

Permalink
feat: refactor format of sg names
Browse files Browse the repository at this point in the history
  • Loading branch information
JGSweets committed May 7, 2024
1 parent ac86ed7 commit 9c8fa30
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
13 changes: 5 additions & 8 deletions sky/clouds/aws.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Amazon Web Services."""
import enum
import fnmatch
import functools
import json
import os
Expand Down Expand Up @@ -400,15 +401,11 @@ def make_deploy_resources_variables(self,

user_security_group = skypilot_config.get_nested(
('aws', 'security_group_name'), None)
if user_security_group is not None and not isinstance(
user_security_group, str):
for sg_name in user_security_group:
if cluster_name_on_cloud.startswith(
sg_name) and sg_name != 'default':
user_security_group = user_security_group[sg_name]
if user_security_group is not None and not isinstance(user_security_group, str):
for profile in user_security_group:
if fnmatch.fnmatchcase(cluster_name_on_cloud, list(profile.keys())[0]):
user_security_group = list(profile.values())[0]
break
elif sg_name == 'default':
user_security_group = user_security_group[sg_name]
security_group = user_security_group
if user_security_group is None and resources.ports is not None:
# Already checked in Resources._try_validate_ports
Expand Down
33 changes: 20 additions & 13 deletions sky/utils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,21 +592,28 @@ def get_config_schema():
'additionalProperties': False,
'properties': {
'security_group_name': {
'oneOf': [{
'type': 'string'
}, {
'type': 'object',
'additionalProperties': False,
'required': ['default'],
'properties': {
'sky-serve-controller': {
'type': 'string',
'oneOf': [
{
'type': 'string'
},
{
# A list of single-element dict to pretain the order.
# Example:
# security_group_name:
# - my-cluster1-*: my-security-group-1
# - my-cluster2-*: my-security-group-2
# - "*"": my-security-group-3
'type': 'array',
'items': {
'type': 'object',
'additionalProperties': {
'type': 'string'
},
'maxProperties': 1,
'minProperties': 1,
},
'default': {
'type': 'string'
}
}
}]
]
},
**_LABELS_SCHEMA,
**_NETWORK_CONFIG_SCHEMA,
Expand Down

0 comments on commit 9c8fa30

Please sign in to comment.