Bug 1918681

Summary: Transient hostname is lost upon systemd-hostnamed restart
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.3CC: dtardon, fkrska, systemd-maint-list
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-01-21 14:55:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2021-01-21 11:06:28 UTC
Description of problem:

When changing the Transient hostname through using the following command:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# hostnamectl --transient set-hostname <newhostname>
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The hostname is lost upon systemd-hostnamed stopping and restarting.

Is that expected? If so what is this Transient hostname stuff about?


Version-Release number of selected component (if applicable):

systemd-239-41.el8_3.1.x86_64


How reproducible:

Always

Steps to Reproduce:
1. Modify the transient hostname

# hostnamectl --transient set-hostname vm-gui83-renamed
# hostnamectl | grep vm-gui83
   Static hostname: vm-gui83
Transient hostname: vm-gui83-renamed


2. Wait for systemd-hostnamed to become inactive (~30 seconds)

# while systemctl is-active systemd-hostnamed; do sleep 10; done
active
inactive

3. Check hostname again (which starts systemd-hostnamed)

# hostnamectl | grep vm-gui83
   Static hostname: vm-gui83

Actual results:

   Static hostname: vm-gui83
(Transient hostname lost)

Expected results:

   Static hostname: vm-gui83
Transient hostname: vm-gui83-renamed

Comment 1 Renaud Métrich 2021-01-21 11:12:20 UTC
I would expect Transient hostname to apply to /proc/sys/kernel/hostname only, but it's not the case.

Comment 2 David Tardon 2021-01-21 14:44:44 UTC
(In reply to Renaud Métrich from comment #1)
> I would expect Transient hostname to apply to /proc/sys/kernel/hostname
> only, but it's not the case.

It does, but only if static hostname (/etc/hostname) is not set. Don't ask me what's the reasoning behind this...

Comment 3 David Tardon 2021-01-21 14:55:06 UTC
(In reply to Renaud Métrich from comment #0)
> # hostnamectl --transient set-hostname vm-gui83-renamed
> # hostnamectl | grep vm-gui83
>    Static hostname: vm-gui83
> Transient hostname: vm-gui83-renamed

This is actually a small bug in systemd-hostnamed: the internal data are never updated. In this case, the passed transient hostname was not written into /proc/sys/kernel/hostname because static hostname exists, but the internal transient hostname entry still contains the value passed by hostnamectl.

Comment 4 David Tardon 2021-01-21 14:55:54 UTC
Closing as this works as specified, even if it's a bit weird.