Skip to content

[lldp] Add check for hostname in lldpmgrd#68

Open
DavidZagury wants to merge 1 commit intomasterfrom
check_hostname_lldpmgrd
Open

[lldp] Add check for hostname in lldpmgrd#68
DavidZagury wants to merge 1 commit intomasterfrom
check_hostname_lldpmgrd

Conversation

@DavidZagury
Copy link
Copy Markdown
Owner

Why I did it

When a switch run with a config db that is missing the key hostname from the DEVICE_METADATA, exception is thrown, which isn't an user friendly.

Before:

2025 Mar 25 15:43:06.091724 sonic-switch INFO lldp#supervisord 2025-03-25 15:43:06,091 INFO spawned: 'lldpmgrd' with pid 38
2025 Mar 25 15:43:06.415066 sonic-switch INFO lldp#supervisord: lldpmgrd Traceback (most recent call last):
2025 Mar 25 15:43:06.415066 sonic-switch INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 370, in <module>
2025 Mar 25 15:43:06.415099 sonic-switch INFO lldp#supervisord: lldpmgrd     main()
2025 Mar 25 15:43:06.415099 sonic-switch INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 352, in main
2025 Mar 25 15:43:06.415167 sonic-switch INFO lldp#supervisord: lldpmgrd     lldpmgr.run()
2025 Mar 25 15:43:06.415231 sonic-switch INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 320, in run
2025 Mar 25 15:43:06.415289 sonic-switch INFO lldp#supervisord: lldpmgrd     self.lldp_process_device_table_event(op, dict(fvp), key)
2025 Mar 25 15:43:06.415349 sonic-switch INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 254, in lldp_process_device_table_event
2025 Mar 25 15:43:06.415407 sonic-switch INFO lldp#supervisord: lldpmgrd     self.update_hostname(hostname)
2025 Mar 25 15:43:06.415415 sonic-switch INFO lldp#supervisord: lldpmgrd   File "/usr/bin/lldpmgrd", line 87, in update_hostname
2025 Mar 25 15:43:06.415474 sonic-switch INFO lldp#supervisord: lldpmgrd     proc = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2025 Mar 25 15:43:06.415534 sonic-switch INFO lldp#supervisord: lldpmgrd            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025 Mar 25 15:43:06.415543 sonic-switch INFO lldp#supervisord: lldpmgrd   File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
2025 Mar 25 15:43:06.415719 sonic-switch INFO lldp#supervisord: lldpmgrd     self._execute_child(args, executable, preexec_fn, close_fds,
2025 Mar 25 15:43:06.415719 sonic-switch INFO lldp#supervisord: lldpmgrd   File "/usr/lib/python3.11/subprocess.py", line 1834, in _execute_child
2025 Mar 25 15:43:06.416058 sonic-switch INFO lldp#supervisord: lldpmgrd     self.pid = _fork_exec(
2025 Mar 25 15:43:06.416058 sonic-switch INFO lldp#supervisord: lldpmgrd                ^^^^^^^^^^^
2025 Mar 25 15:43:06.416058 sonic-switch INFO lldp#supervisord: lldpmgrd TypeError: expected str, bytes or os.PathLike object, not NoneType
2025 Mar 25 15:43:06.466073 sonic-switch INFO lldp#supervisord 2025-03-25 15:43:06,465 WARN exited: lldpmgrd (exit status 1; not expected)

After:
2025 Mar 26 09:36:58.109307 sonic-switch ERR lldp#lldpmgrd[733]: Hostname is not defined

Work item tracking
  • Microsoft ADO (number only):

How I did it

Added a check the make sure that hostname exists and if not, print a user friendly error instead of the traceback.

How to verify it

Remove the hostname configuration and start lldp docker.

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)

DavidZagury pushed a commit that referenced this pull request Apr 28, 2025
… automatically (sonic-net#886)

#### Why I did it
src/sonic-platform-common
```
* 3b780b0 - (HEAD -> 202412, origin/202412) [code sync] Merge code from sonic-net/sonic-platform-common:202411 to 202412 (#68) (21 hours ago) [mssonicbld]
```
#### How I did it
#### How to verify it
#### Description for the changelog
DavidZagury pushed a commit that referenced this pull request Apr 28, 2025
…tomatically (sonic-net#1000)

#### Why I did it
src/sonic-swss
```
* 9e9442d - (HEAD -> 202412, origin/202412) [orchagent] Fix issue: typo in high BER (#68) (3 hours ago) [mssonicbld]
```
#### How I did it
#### How to verify it
#### Description for the changelog
DavidZagury pushed a commit that referenced this pull request Oct 15, 2025
…ly (sonic-net#23194)

#### Why I did it
src/sonic-ztp
```
* c20ba9c - (HEAD -> 202505, origin/202505) [ci] Upgrade agent pool from ubuntu 20.04 to latest. (#68) (24 hours ago) [mssonicbld]
```
#### How I did it
#### How to verify it
#### Description for the changelog
DavidZagury pushed a commit that referenced this pull request Mar 9, 2026
…sonic-net#25508)

#### Why I did it
src/dhcpmon
```
* d78974f - (HEAD -> master, origin/master, origin/HEAD) [dhcp_mon] Add missing #include <algorithm> for std::replace (#68) (31 hours ago) [rustiqly]
* d4934fa - Add .github/copilot-instructions.md for AI-assisted development (#67) (31 hours ago) [rustiqly]
```
#### How I did it
#### How to verify it
#### Description for the changelog
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