Skip to content

Commit

Permalink
Move tailscale_auth_key to env and set it on controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
Conless committed Sep 29, 2024
1 parent 779eba7 commit c137e1f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions sky/serve/service_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ def from_yaml_config(config: Dict[str, Any]) -> 'SkyServiceSpec':
vpn_section: Dict[str, Any] = config.get('vpn', None)
if vpn_section is not None:
# Get the tailscale auth key from the environment.
tailscale_auth_key = vpn_section.get('tailscale_auth_key', None)
if tailscale_auth_key is not None:
service_config['tailscale_auth_key'] = tailscale_auth_key
if vpn_section.get('tailscale'):
service_config['tailscale_auth_key'] = os.getenv(
'TAILSCALE_AUTH_KEY')

return SkyServiceSpec(**service_config)

Expand Down
3 changes: 3 additions & 0 deletions sky/skylet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,6 @@
ROLE_ASSIGNMENT_FAILURE_ERROR_MSG = (
'Failed to assign Storage Blob Data Owner role to the '
'storage account {storage_account_name}.')

# Constants for Tailscale VPN
TAILSCALE_AUTH_KEY_ENV_VAR = 'TAILSCALE_AUTH_KEY'
6 changes: 6 additions & 0 deletions sky/utils/controller_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ def shared_controller_vars_to_fill(
# Only set the SKYPILOT_CONFIG env var if the user has a config file.
env_vars[
skypilot_config.ENV_VAR_SKYPILOT_CONFIG] = remote_user_config_path
# Check if VPN auth key should be set.
if task_config:
vpn_config = task_config.get('service', {}).get('vpn', {})
if vpn_config.get('tailscale'):
env_vars[constants.TAILSCALE_AUTH_KEY_ENV_VAR] = task_config[
'tailscale_auth_key']
vars_to_fill['controller_envs'] = env_vars
return vars_to_fill

Expand Down
4 changes: 2 additions & 2 deletions sky/utils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ def get_service_schema():
'type': 'object',
'additionalProperties': False,
'properties': {
'tailscale_auth_key': {
'type': 'string',
'tailscale': {
'type': 'boolean',
},
}
},
Expand Down

0 comments on commit c137e1f

Please sign in to comment.