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

[Provisioner] Generate valid cluster names when username has invalid characters #1526

Merged
merged 6 commits into from
Dec 19, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,13 @@ def check_local_gpus() -> bool:
def generate_cluster_name():
# TODO: change this ID formatting to something more pleasant.
# User name is helpful in non-isolated accounts, e.g., GCP, Azure.
return f'sky-{uuid.uuid4().hex[:4]}-{getpass.getuser()}'
# We clean up the username by making it all lowercase, removing any
# non-alphanumeric characters (including hyphens) and removing any numbers
# at the start of the username. e.g. 1SkY-PiLot2 becomes skypilot2.
cleaned_username = re.sub(
r'^\d+', '', re.sub('[^a-z0-9]', '',
getpass.getuser().lower()))
return f'sky-{uuid.uuid4().hex[:4]}-{cleaned_username}'


def query_head_ip_with_retries(cluster_yaml: str, max_attempts: int = 1) -> str:
Expand Down