Page MenuHomeVyOS Platform

hosts lost after modified static-host-mapping
Closed, ResolvedPublic

Description

After insert or delete entry in static-host-mapping, /etc/hosts lost all static-host-mapping entries, until modify system host-name

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.2 rolling release
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

qiuchengxuan created this object in space S1 VyOS Public.
qiuchengxuan changed Version from - to VyOS 1.2.3 rolling release.
syncer assigned this task to Viacheslav.Dec 6 2019, 7:53 PM
syncer triaged this task as Normal priority.
syncer added a project: VyOS 1.3 Equuleus.

I don't see this bug in the latest versions of the VyOS (VyOS 1.2-rolling-201912090217 and VyOS 1.3-rolling-201912090242).

Adding static-host-mapping

set system static-host-mapping host-name r03 inet '192.168.122.62'
set system static-host-mapping host-name r04 inet '192.168.122.67'
set system static-host-mapping host-name r05 inet '192.168.122.68'
set system static-host-mapping host-name r06 inet '192.168.122.69'
vyos@1.2-roll-ns# commit
[edit]

Check current hosts:

vyos@1.2-roll-ns# sudo cat /etc/hosts | tail -n 5
# From DHCP and "system static host-mapping"
192.168.122.69	r06	
192.168.122.62	r03	
192.168.122.68	r05	
192.168.122.67	r04

Delete host 'r05'

vyos@1.2-roll-ns# delete system static-host-mapping host-name r05
[edit]
vyos@1.2-roll-ns# commit

vyos@1.2-roll-ns# sudo cat /etc/hosts | tail -n 5

# From DHCP and "system static host-mapping"
192.168.122.62	r03	
192.168.122.69	r06	
192.168.122.67	r04	
[edit]
vyos@1.2-roll-ns#

@qiuchengxuan Can you describe the sequence of how to reproduce this bug?

qiuchengxuan added a comment.EditedDec 9 2019, 9:10 AM

It's probably duplicate of T1863 and T1846, I usually commit configuration under leaf config level

Confirm the problem on edit level.

vyos@vyos# show system static-host-mapping 
 host-name r04 {
     inet 192.168.122.67
 }
 host-name r06 {
     inet 192.168.122.69
 }
[edit]
[edit system static-host-mapping]
vyos@vyos# set host-name r03 inet 192.168.122.65
[edit system static-host-mapping]
vyos@vyos# commit
[edit system static-host-mapping]
vyos@vyos# 
[edit system static-host-mapping]
vyos@vyos# cat /etc/hosts

### Autogenerated by VyOS ###
### Do not edit, your changes will get overwritten ###

# Local host
127.0.0.1       localhost
127.0.1.1       vyos

# The following lines are desirable for IPv6 capable hosts
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

# From DHCP and "system static host-mapping"[edit system static-host-mapping]
vyos@vyos#
pasik added a subscriber: pasik.Dec 10 2019, 1:32 PM

@jestabro problem is not resolved

vyos@vultr# edit system static-host-mapping
[edit system static-host-mapping]
vyos@vultr# set host-name test.lan inet 127.0.0.1
[edit system static-host-mapping]
vyos@vultr# commit
[ system static-host-mapping ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/conf_mode/host_name.py", line 180, in <module>
    c = get_config()
  File "/usr/libexec/vyos/conf_mode/host_name.py", line 48, in get_config
    conf = Config()
  File "/usr/lib/python3/dist-packages/vyos/config.py", line 115, in __init__
    self._running_config = vyos.configtree.ConfigTree(running_config_text)
  File "/usr/lib/python3/dist-packages/vyos/configtree.py", line 182, in __init__
    raise ValueError("Failed to parse config: {0}".format(msg))
ValueError: Failed to parse config: Syntax error on line 1, character 21: Invalid syntax.

[[system static-host-mapping]] failed
Commit failed
[edit system static-host-mapping]
vyos@vultr#

you probably needs to change config.py:L102 running config also

jestabro added a comment.EditedDec 11 2019, 3:30 PM

Thanks; this is necessary when (1) editing at the level of an unset node; (2) reading effective_value(s) in configuration mode. I will extend the original fix.

qiuchengxuan added a comment.EditedDec 13 2019, 9:01 AM

[edit system static-host-mapping]
vyos@vultr# set host-name test.lan inet 127.0.0.1
[edit system static-host-mapping]
vyos@vultr# commit
[edit system static-host-mapping]
vyos@vultr# save
Saving configuration to '/config/config.boot'...
Done
[edit]
vyos@vultr# show system static-host-mapping
host-name test.lan {

inet 127.0.0.1

}
[edit]
vyos@vultr#

Verified as resolved

vyos@vultr:~$ show version
Version: VyOS 1.2-rolling-201912130217

qiuchengxuan closed this task as Resolved.Dec 13 2019, 9:02 AM
qiuchengxuan changed Version from VyOS 1.2.3 rolling release to VyOS 1.2 rolling release.
c-po moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus board.Dec 28 2019, 7:02 PM