From b0204f3c242e9df25321ff9ce7d80d89b6b0e895 Mon Sep 17 00:00:00 2001 From: "Andres D. Molins" Date: Thu, 21 Sep 2023 11:14:45 +0200 Subject: [PATCH] Fix: Large hostname issue. --- vm_supervisor/vm/firecracker/instance.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vm_supervisor/vm/firecracker/instance.py b/vm_supervisor/vm/firecracker/instance.py index dbe9fd32a..be4f886ba 100644 --- a/vm_supervisor/vm/firecracker/instance.py +++ b/vm_supervisor/vm/firecracker/instance.py @@ -1,4 +1,5 @@ import asyncio +import base64 import json import logging from pathlib import Path @@ -236,9 +237,11 @@ def _create_network_file(self) -> bytes: def _create_metadata_file(self) -> bytes: """Creates metadata configuration file for cloud-init tool""" + hostname = base64.b32encode(self.vm_hash).decode().strip("=").lower() + metadata = { "instance-id": f"iid-instance-{self.vm_id}", - "local-hostname": str(self.vm_hash), + "local-hostname": hostname, } return json.dumps(metadata).encode()