Hostname changes after every reboot with OpenNebula

Bug #1771145 reported by Corey Melanson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

When using the OpenNebula datasource (Ubuntu 16.04.4, cloud-init 18.2-4-g05926e48-0ubuntu1~16.04.2) the hostname switches after every reboot between the one defined by the OpenNebula HOSTNAME context variable and one based on the IP address (eg ip-10-22-33-44).

I took some time to review the code, and I believe it's happening because HOSTNAME is a bash environment variable and also in context.sh that is sourced in. When I applied the attached patch to unset HOSTNAME prior to sourcing context.sh, the correct hostname stays persistent across reboots. I'm not sure though if this is a "proper" fix for the issue, but it's working for us.

Example:
root@cjm1604:~# cat /run/cloud-init/instance-data.json | jq .v1
{
  "availability-zone": null,
  "cloud-name": "opennebula",
  "instance-id": "iid-dsopennebula",
  "local-hostname": "cjm1604",
  "region": null
}
root@cjm1604:~# reboot

root@ip-10-236-120-173:~# cat /run/cloud-init/instance-data.json | jq .v1
{
  "availability-zone": null,
  "cloud-name": "opennebula",
  "instance-id": "iid-dsopennebula",
  "local-hostname": "ip-10-236-120-173",
  "region": null
}
root@ip-10-236-120-173:~# reboot

root@cjm1604:~# cat /run/cloud-init/instance-data.json | jq .v1
{
  "availability-zone": null,
  "cloud-name": "opennebula",
  "instance-id": "iid-dsopennebula",
  "local-hostname": "cjm1604",
  "region": null
}
root@cjm1604:~# reboot

Let me know if you require any additional information.

Cheers,
Corey Melanson

Revision history for this message
Corey Melanson (cmelanson) wrote :
Revision history for this message
Scott Moser (smoser) wrote :

Hi Corey,
It looks like you have correctly identified this bug and the right fix. bash was setting the HOSTNAME variable which was throwing a wrench into assumptions of the parse_shell_config.

Could you follow http://cloudinit.readthedocs.io/en/latest/topics/hacking.html and submit a merge proposal?

Please let me know if you have any questions. Feel free to ping in FreeNode IRC (smoser) or here.

Changed in cloud-init:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Triaged → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.