Hostname getting set to fqdn after upgrading to cloud-init-22.2

Bug #1983811 reported by Shreenidhi Shedi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
High
Unassigned

Bug Description

Hi All,

Environment details:
cloud-init-22.2
Photon OS 3.0 and above

I am seeing something weird after upgrading to cloud-init-22.2

My /etc/hosts looks like this:

$ cat /etc/hosts
127.0.1.1 ph3dev.local ph3dev
127.0.0.1 localhost

And my /etc/hostname

$ cat /etc/hostname
ph3dev

Now if I do systemctl restart cloud-init , /etc/hostname is getting changed.

$ cat /etc/hostname
ph3dev.local

And hostname command return fqdn instead of short name. Isn't it incorrect to have fqdn in /etc/hostname?

I have prefer_fqdn_over_hostname = True in photon.py

I changed frequency = PER_ONCE in cc_set_hostname.py and it doesn't modify /etc/hostname after that and this is how it was in cloud-init <= v22.1 and even in v22.1 we have prefer_fqdn_over_hostname set in photon.py but it doesn't modify /etc/hostname file.

I doubt that https://github.com/canonical/cloud-init/pull/1365 has introduced this change, not sure though.

We discussed a bit about this issue in https://github.com/canonical/cloud-init/pull/1365.

If it helps, I see the follwing entries in cloud-init-22.1 logs:

```
2022-08-08 06:58:38,498 - stages.py[DEBUG]: Running module set_hostname (<module 'cloudinit.config.cc_set_hostname' from '/usr/lib/python3.7/site-packages/cloudinit/config/cc_set_hostname.py'>) with frequency once-per-instance
```

And in cloud-init-22.2:
```
2022-08-08 07:00:38,512 - modules.py[DEBUG]: Running module set_hostname (<module 'cloudinit.config.cc_set_hostname' from '/usr/lib/python3.7/site-packages/cloudinit/config/cc_set_hostname.py'>) with frequency always
```
```

Revision history for this message
Shreenidhi Shedi (sshedi) wrote :
Revision history for this message
Shreenidhi Shedi (sshedi) wrote :
Revision history for this message
James Falcon (falcojr) wrote :

Thanks for the detailed bug report. Yes, running always rather than once-per-instance does represent a regression.

Changed in cloud-init:
status: New → Incomplete
status: Incomplete → Triaged
importance: Undecided → High
Revision history for this message
Shreenidhi Shedi (sshedi) wrote :

Issue is fixed in:
https://github.com/canonical/cloud-init/commit/25326a39a51996f37ef8c3cb976fe31c041a2edd

I will close this bug or if it's not possible from my end, feel free to close this issue.

Changed in cloud-init:
status: Triaged → Fix Committed
Revision history for this message
Brett Holman (holmanb) wrote : Fixed in cloud-init version 22.3.

This bug is believed to be fixed in cloud-init in version 22.3. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
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.