Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AWS] Disable unattended-upgrade with cloud-init #1949

Merged
merged 12 commits into from
May 11, 2023
2 changes: 0 additions & 2 deletions sky/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ def setup_aws_authentication(config: Dict[str, Any]) -> Dict[str, Any]:
# Use cloud init in UserData to set up the authorized_keys to get
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
# around the number of keys limit and permission issues with
# ec2.describe_key_pairs.
# Note that sudo and shell need to be specified to ensure setup works.
# Reference: https://cloudinit.readthedocs.io/en/latest/reference/modules.html#users-and-groups # pylint: disable=line-too-long
config = _replace_ssh_info_in_config(config, public_key)
return config

Expand Down
5 changes: 5 additions & 0 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,13 @@
# it's possible to failover to 1b, which leaves a leaked instance in 1a. Here,
# we use the new yaml's zone field, which is guaranteed to be the existing zone
# '1a'.
# - UserData: The UserData field of the old yaml may be outdated, and we want to
# use the new yaml's UserData field, which contains the authorized key setup as
# well as the disabling of the auto-update with apt-get.
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
_RAY_YAML_KEYS_TO_RESTORE_EXCEPTIONS = [
('provider', 'availability_zone'),
('available_node_types', 'ray.head.default', 'node_config', 'UserData'),
('available_node_types', 'ray.worker.default', 'node_config', 'UserData'),
]


Expand Down
12 changes: 10 additions & 2 deletions sky/templates/aws-ray.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@ available_node_types:
# SpotOptions:
# MaxPrice: MAX_HOURLY_PRICE
{% endif %}
# Use cloud init in UserData to set up the authorized_keys to get
# around the number of keys limit and permission issues with
# ec2.describe_key_pairs.
# Note that sudo and shell need to be specified to ensure setup works.
# Reference: https://cloudinit.readthedocs.io/en/latest/reference/modules.html#users-and-groups
# The bootcmd is to disable automatic APT updates, to avoid the lock
# when user call `apt install` on the node.
# Reference: https://unix.stackexchange.com/a/471192
UserData: |
#cloud-config
users:
- name: skypilot:ssh_user
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
ssh-authorized-keys:
ssh_authorized_keys:
- skypilot:ssh_public_key_content
bootcmd:
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
- echo 'APT::Periodic::Enable "0";' > /etc/apt/apt.conf.d/10cloudinit-disable
Expand Down Expand Up @@ -106,7 +114,7 @@ available_node_types:
- name: skypilot:ssh_user
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
ssh-authorized-keys:
ssh_authorized_keys:
- skypilot:ssh_public_key_content
bootcmd:
- echo 'APT::Periodic::Enable "0";' > /etc/apt/apt.conf.d/10cloudinit-disable
Expand Down