Skip to content

Commit

Permalink
Fix: Hostnames should not be cropped
Browse files Browse the repository at this point in the history
  • Loading branch information
hoh committed May 12, 2023
1 parent 69c945a commit 3d489b9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions runtimes/aleph-alpine-3.13-python/init1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python3 -OO

import base64
import logging

logging.basicConfig(
Expand Down Expand Up @@ -451,8 +451,11 @@ def receive_config(client) -> ConfigurationPayload:


def setup_system(config: ConfigurationPayload):
# hostname labels are limited to 63 characters
setup_hostname(config.vm_hash[0:63])
# Linux host names are limited to 63 characters. We therefore use the base32 representation
# of the item_hash instead of its common base16 representation.
item_hash_binary: bytes = base64.b16decode(config.vm_hash.encode().upper())
hostname = base64.b32encode(item_hash_binary).decode().strip('=').lower()
setup_hostname(hostname)

setup_variables(config.variables)
setup_volumes(config.volumes)
Expand Down

0 comments on commit 3d489b9

Please sign in to comment.