canonical / canonical/cloud-init
Hostname changes after every reboot with OpenNebula
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
This bug was originally filed in Launchpad as [LP: #1771145](https://bugs.launchpad.net/cloud-init/+bug/1771145)
Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2018-05-14T16:07:05.383801+00:00
date_fix_committed = None
date_fix_released = None
id = 1771145
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1771145
milestone = None
owner = cmelanson
owner_name = Corey Melanson
private = False
status = triaged
submitter = cmelanson
submitter_name = Corey Melanson
tags = []
duplicates = []
_Launchpad user **Corey Melanson(cmelanson)** wrote on 2018-05-14T16:07:05.383801+00:00_
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
Contributor guide
Assessment
This issue has not been assessed yet.