Bug 2084469

Summary: RFE: static hostname modification
Product: Red Hat Enterprise Linux 9 Reporter: Quique Llorente <ellorent>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.1CC: ferferna, fge, jiji, jishi, network-qe, sfaye, till
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 10:00:45 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 Quique Llorente 2022-05-12 08:25:18 UTC
Description of problem:

At openshift the hostname of nodes are taken from DHCP if interfaces are configured statically setting "dhcp: false" the nodes does not get the hostname and the cluster startup fail.

Setting the hostname statically withing the nmstate yaml that move the interfaces to "dhcp: false" would help here.


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


How reproducible: 


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Gris Ge 2022-05-27 08:54:06 UTC
Patch posted to upstream: https://github.com/nmstate/nmstate/pull/1911

Example yaml:

```yaml
---
hostname:
  running: "nmstate-test.example.org"
  config: "nmstate-test.example.org"
```

The `running` is the activating hostname. The `config` is the on-disk
hostname in /etc/hostname. Then setting empty string to `config`,
nmstate will remove on-disk hostname.

Comment 3 Quique Llorente 2022-05-27 09:02:04 UTC
(In reply to Gris Ge from comment #2)
> Patch posted to upstream: https://github.com/nmstate/nmstate/pull/1911
> 
> Example yaml:
> 
> ```yaml
> ---
> hostname:
>   running: "nmstate-test.example.org"
>   config: "nmstate-test.example.org"
> ```
> 
> The `running` is the activating hostname. The `config` is the on-disk
> hostname in /etc/hostname. Then setting empty string to `config`,
> nmstate will remove on-disk hostname.

There is also the following concept on hostnamectl, don't know if we have that at NM.

     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname

Comment 4 Fernando F. Mancera 2022-06-02 10:46:14 UTC
Tested with integration tests out of a container. It works as expected. Thanks!

Comment 7 Mingyu Shi 2022-06-15 03:22:58 UTC
nmstate-2.1.1-0.alpha.20220602.5accbd1.el9.x86_64

It seems successful according to the output, but nmstatectl got error when applying.
@Gris could you please take a look?


The original hostname in `nmstatectl show`:
hostname:
  running: sweetpig-8.4a2m.lab.eng.bos.redhat.com
  config: ""


Then I applied such state:
hostname:
  running: sweetpig-8.4a2m.lab.eng.bos.redhat.com
  config: test.name


It reported error(returned 65):
[11:12:13@sweetpig-8 ~]0# nmstatectl edit 
[2022-06-15T03:12:23Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:12:23Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
[2022-06-15T03:12:56Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:12:57Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
[2022-06-15T03:12:57Z INFO  nmstate::net_state] Ignoring kernel interface lo
[2022-06-15T03:12:57Z INFO  nmstate::net_state] Created checkpoint /org/freedesktop/NetworkManager/Checkpoint/6
[2022-06-15T03:12:57Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:12:57Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
[2022-06-15T03:12:57Z ERROR nmstate::hostname] VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:12:57Z INFO  nmstate::net_state] Retrying on verification failure: VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:12:58Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:12:58Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
[2022-06-15T03:12:58Z ERROR nmstate::hostname] VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:12:58Z INFO  nmstate::net_state] Retrying on verification failure: VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:12:59Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:12:59Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
[2022-06-15T03:12:59Z ERROR nmstate::hostname] VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:12:59Z INFO  nmstate::net_state] Retrying on verification failure: VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:13:00Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:13:00Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
[2022-06-15T03:13:00Z ERROR nmstate::hostname] VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:13:00Z INFO  nmstate::net_state] Retrying on verification failure: VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:13:01Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:13:01Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
[2022-06-15T03:13:01Z ERROR nmstate::hostname] VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")
[2022-06-15T03:13:01Z INFO  nmstate::net_state] Rollbacked to checkpoint /org/freedesktop/NetworkManager/Checkpoint/6
NmstateError: VerificationError: Verification fail, desire hostname.running: sweetpig-8.4a2m.lab.eng.bos.redhat.com, current: Some("test.name")


But it actually succeeded by checking:
[11:13:52@sweetpig-8 ~]0# nmstatectl show | yq '.hostname'
[2022-06-15T03:14:14Z INFO  nmstate::nispor::show] Got unsupported interface lo type Loopback
[2022-06-15T03:14:15Z INFO  nmstate::nm::show] Got unsupported interface type generic: lo, ignoring
running: test.name
config: test.name
[11:14:15@sweetpig-8 ~]0# hostname
test.name

Comment 8 Mingyu Shi 2022-06-20 07:21:05 UTC
In here, "running" and "config" under "hostname" are different, "running" takes effect at runtime(is recovered after rebooting)

Mark it as verified, filed a new bug to trace the problem in #comment7

Comment 10 errata-xmlrpc 2022-11-15 10:00:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (nmstate bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7991