cloud-init strips ending newline from "/var/lib/cloud/data/previous-hostname"

Bug #2015043 reported by Anirban Sinha
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Committed
Undecided
Unassigned

Bug Description

Steps to Reproduce:
1. enable cloud-init for rhel8

Actual results:
[root@mj-rhel87 ~]# cat /etc/hostname
mj-rhel87
[root@mj-rhel87 ~]# cat /var/lib/cloud/data/previous-hostname
mj-rhel87[root@mj-rhel87 ~]#

2023-03-28 14:47:45,733 - util.py[DEBUG]: Reading from /var/lib/cloud/data/previous-hostname (quiet=False)
2023-03-28 14:47:45,734 - util.py[DEBUG]: Read 9 bytes from /var/lib/cloud/data/previous-hostname
2023-03-28 14:47:45,734 - subp.py[DEBUG]: Running command ['hostname'] with allowed return codes [0] (shell=False, capture=True)
2023-03-28 14:47:45,738 - __init__.py[INFO]: /var/lib/cloud/data/previous-hostname differs from /etc/hostname, assuming user maintained hostname.

Expected results:
file /var/lib/cloud/data/previous-hostname will be terminated with new line as well

The issue is seen on RHEl 7, RHEL 8 and RHEL 9.

Ubuntu doesn't have this problem.
-------------
ubuntu@xiachen-test-ubuntu:~$ cat /etc/hostname
xiachen-test-ubuntu
ubuntu@xiachen-test-ubuntu:~$ cat /var/lib/cloud/data/previous-hostname
xiachen-test-ubuntu
ubuntu@xiachen-test-ubuntu:~$

Revision history for this message
Anirban Sinha (anisinha) wrote :
Revision history for this message
Chad Smith (chad.smith) wrote :

Thanks Anirban for submitting the PR and Aciba for review/landing here. Marking Fix committed.

Changed in cloud-init:
status: New → Fix Committed
Revision history for this message
Chad Smith (chad.smith) wrote :

Expect this fix released in cloud-init version 23.2

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.