Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hostcfgd] hostcfgd will exit when set hostname in DEVICE_METADATA #3394

Merged
merged 2 commits into from
Sep 25, 2019
Merged

[hostcfgd] hostcfgd will exit when set hostname in DEVICE_METADATA #3394

merged 2 commits into from
Sep 25, 2019

Conversation

ouxlwhu
Copy link
Contributor

@ouxlwhu ouxlwhu commented Aug 29, 2019

Signed-off-by: ouxiaolong ouxiaolong@asterfusion.com

- What I did
1.when execute ‘redis-cli -n 4 HSET "DEVICE_METADATA|localhost" hostname 48S-wz.’ in SONiC bash ,hostcfgdwill exit,and there is a Traceback information in /var/log/syslog like this:

Aug 28 17:35:14.551892 48S-wz INFO hostcfgd[21512]: Traceback (most recent call last):
Aug 28 17:35:14.552642 48S-wz INFO hostcfgd[21512]: File "/usr/bin/hostcfgd", line 232, in
Aug 28 17:35:14.553171 48S-wz INFO hostcfgd[21512]: main()
Aug 28 17:35:14.553701 48S-wz INFO hostcfgd[21512]: File "/usr/bin/hostcfgd", line 228, in main
Aug 28 17:35:14.554190 48S-wz INFO hostcfgd[21512]: daemon.start()
Aug 28 17:35:14.554735 48S-wz INFO hostcfgd[21512]: File "/usr/bin/hostcfgd", line 223, in start
Aug 28 17:35:14.555217 48S-wz INFO hostcfgd[21512]: self.config_db.listen()
Aug 28 17:35:14.555704 48S-wz INFO hostcfgd[21512]: File "/usr/local/lib/python2.7/dist-packages/swsssdk/configdb.py", line 102, in listen
Aug 28 17:35:14.556188 48S-wz INFO hostcfgd[21512]: self.__fire(table, row, data)
Aug 28 17:35:14.556750 48S-wz INFO hostcfgd[21512]: File "/usr/local/lib/python2.7/dist-packages/swsssdk/configdb.py", line 87, in __fire
Aug 28 17:35:14.557263 48S-wz INFO hostcfgd[21512]: handler(table, key, data)
Aug 28 17:35:14.557764 48S-wz INFO hostcfgd[21512]: File "/usr/bin/hostcfgd", line 222, in
Aug 28 17:35:14.558266 48S-wz INFO hostcfgd[21512]: self.config_db.subscribe('DEVICE_METADATA', lambda table, key, data: self.hostname_handler(key, data))
Aug 28 17:35:14.558821 48S-wz INFO hostcfgd[21512]: File "/usr/bin/hostcfgd", line 189, in hostname_handler
Aug 28 17:35:14.559325 48S-wz INFO hostcfgd[21512]: if not is_valid_hostname(hostname):
Aug 28 17:35:14.559830 48S-wz INFO hostcfgd[21512]: File "/usr/bin/hostcfgd", line 27, in is_valid_hostname
Aug 28 17:35:14.560476 48S-wz INFO hostcfgd[21512]: if hostname[-1] == ".":
Aug 28 17:35:14.560993 48S-wz INFO hostcfgd[21512]: UnboundLocalError: local variable 'hostname' referenced before assignment

2.after I fixed it, there are some other err log in /var/log/syslog like this

Aug 29 10:13:33.583491 48S-wz INFO hostcfgd[27773]: Set hostname in bgp container
Aug 29 10:13:33.880805 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:36.008242 48S-wz INFO hostcfgd[27773]: Set hostname in swss container
Aug 29 10:13:36.276700 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:38.560297 48S-wz INFO hostcfgd[27773]: Set hostname in syncd container
Aug 29 10:13:38.853333 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:41.084499 48S-wz INFO hostcfgd[27773]: Set hostname in dhcp_relay container
Aug 29 10:13:41.357581 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:43.669783 48S-wz INFO hostcfgd[27773]: Set hostname in radv container
Aug 29 10:13:43.934936 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:46.110223 48S-wz INFO hostcfgd[27773]: Set hostname in snmp container
Aug 29 10:13:46.361012 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:48.693676 48S-wz INFO hostcfgd[27773]: Set hostname in teamd container
Aug 29 10:13:48.965765 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:51.149399 48S-wz INFO hostcfgd[27773]: Set hostname in lldp container
Aug 29 10:13:51.433085 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:53.758775 48S-wz INFO hostcfgd[27773]: Set hostname in pmon container
Aug 29 10:13:54.029597 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid
Aug 29 10:13:56.273657 48S-wz INFO hostcfgd[27773]: Set hostname in database container
Aug 29 10:13:56.549141 48S-wz INFO hostcfgd[27773]: hostname: the specified hostname is invalid

- How I did it
1.fix is_valid_hostname in hostcfgd
2. log warning when hostname is invalid

- How to verify it
execute ‘redis-cli -n 4 HSET "DEVICE_METADATA|localhost" hostname 48S-wz.’ in SONiC bash, then check log in /var/log/syslog

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: ouxiaolong <ouxiaolong@asterfusion.com>
files/image_config/hostcfgd/hostcfgd Outdated Show resolved Hide resolved
Signed-off-by: ouxiaolong <ouxiaolong@asterfusion.com>
@jleveque
Copy link
Contributor

jleveque commented Sep 9, 2019

Retest vs please

@lguohan
Copy link
Collaborator

lguohan commented Sep 11, 2019

retest vs please

@ouxlwhu
Copy link
Contributor Author

ouxlwhu commented Sep 23, 2019

retest vs please

Hi, is there anything that I can do for this?

@jleveque
Copy link
Contributor

@ouxlwhu: Not at the moment. This phrase causes our Jenkins server to kick off a new test.

@jleveque
Copy link
Contributor

Retest vs please

@jleveque jleveque merged commit b6a0999 into sonic-net:master Sep 25, 2019
@ouxlwhu ouxlwhu deleted the fixhostcfgd branch August 10, 2020 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants