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

Fix lldpmgrd traceback when hostname is not available #20478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

devpatha
Copy link
Contributor

Why I did it

We see below backtrace when hostname is not available during boot and lldpmgrd exits

Oct 11 03:25:29.131847 sonic INFO lldp#supervisord: lldpmgrd Traceback (most recent call last):
Oct 11 03:25:29.131847 sonic INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 369, in <module>
Oct 11 03:25:29.132038 sonic INFO lldp#supervisord: lldpmgrd     main()
Oct 11 03:25:29.132038 sonic INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 351, in main
Oct 11 03:25:29.132209 sonic INFO lldp#supervisord: lldpmgrd     lldpmgr.run()
Oct 11 03:25:29.132209 sonic INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 319, in run
Oct 11 03:25:29.132333 sonic INFO lldp#supervisord: lldpmgrd     self.lldp_process_device_table_event(op, dict(fvp), key)
Oct 11 03:25:29.132347 sonic INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 253, in lldp_process_device_table_event
Oct 11 03:25:29.132347 sonic INFO lldp#supervisord: lldpmgrd     self.update_hostname(hostname)
Oct 11 03:25:29.132356 sonic INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 88, in update_hostname
Oct 11 03:25:29.132461 sonic INFO lldp#supervisord: lldpmgrd     proc = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Oct 11 03:25:29.132461 sonic INFO lldp#supervisord: lldpmgrd   File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
Oct 11 03:25:29.132611 sonic INFO lldp#supervisord: lldpmgrd     self._execute_child(args, executable, preexec_fn, close_fds,
Oct 11 03:25:29.132622 sonic INFO lldp#supervisord: lldpmgrd   File "/usr/lib/python3.9/subprocess.py", line 1756, in _execute_child
Oct 11 03:25:29.132929 sonic INFO lldp#supervisord: lldpmgrd     self.pid = _posixsubprocess.fork_exec(

This is because string self.hostname is initialized to string 'None'. It is not of NoneType
In the code hostname which has a value of None(NoneType) is compared with 'None'(str object) and it fails.
It then attempts to run lldpcli with hostname as None(NoneType) which results in traceback and exit of lldpmgrd.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Initialize self.hostname to None of NoneType

How to verify it

  1. Removed hostname from config, reboot. Verified that no Traceback seen
  2. set hostname using config CLI and verified that lldpcli is run with correct hostname

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant