Skip to content

Commit

Permalink
Fix: Use the same hostname on metadata and cloud-init configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
nesitor committed Oct 10, 2023
1 parent 9b8974a commit 5ae783f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vm_supervisor/vm/firecracker/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def create_snapshot(self) -> CompressedDiskVolumeSnapshot:
self.latest_snapshot = snapshot
return compressed_snapshot

def _get_vm_hostname(self) -> str:
def _get_hostname(self) -> str:
item_hash_binary: bytes = base64.b16decode(self.vm_hash.encode().upper())
return base64.b32encode(item_hash_binary).decode().strip("=").lower()

Expand All @@ -191,7 +191,7 @@ def _encode_user_data(self) -> bytes:
ssh_authorized_keys = self.resources.message_content.authorized_keys or []

config: Dict[str, Union[str, bool, List[str]]] = {
"hostname": self._get_vm_hostname(),
"hostname": self._get_hostname(),
"disable_root": False,
"ssh_pwauth": False,
"ssh_authorized_keys": ssh_authorized_keys,
Expand Down Expand Up @@ -243,7 +243,7 @@ def _create_metadata_file(self) -> bytes:

metadata = {
"instance-id": f"iid-instance-{self.vm_id}",
"local-hostname": self._get_vm_hostname(),
"local-hostname": self._get_hostname(),
}

return json.dumps(metadata).encode()
Expand Down

0 comments on commit 5ae783f

Please sign in to comment.