-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[LLDP] Add lldpmgrd Daemon to Manage LLDP Configuration #1428
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented
@@ -2,7 +2,7 @@ | |||
|
|||
DOCKER_LLDP_SV2 = docker-lldp-sv2.gz | |||
$(DOCKER_LLDP_SV2)_PATH = $(DOCKERS_PATH)/docker-lldp-sv2 | |||
$(DOCKER_LLDP_SV2)_DEPENDS += $(LLDPD) | |||
$(DOCKER_LLDP_SV2)_DEPENDS += $(LLDPD) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need LIBSWSSCOMMON here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it uses python-binding of libswsscommon for getting table notification from redis db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
""" | ||
Infinite loop. Subscribes to notifications of changes in the PORT table | ||
of the Redis State database. When we are notified of the creation of an | ||
interface, update LLDP configuration accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about removing of an interface. Do you catch such case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. We decided this was unnecessary.
dockers/docker-lldp-sv2/lldpmgrd
Outdated
|
||
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
|
||
(stdout, stderr) = proc.communicate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably it's better to get exit code from the command too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm already checking the return code from the command on line 145 (if proc.returncode != 0:
)
dockers/docker-lldp-sv2/lldpmgrd
Outdated
# Retrieve all entires from the Port table | ||
port_table = swsscommon.Table(self.config_db, swsscommon.CFG_PORT_TABLE_NAME, TABLE_SEPARATOR) | ||
(status, fvp) = port_table.get(port_name) | ||
if status is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 'if not status' would be better here
dockers/docker-lldp-sv2/lldpmgrd
Outdated
# Retrieve all entires from the Device Neighbor table | ||
device_neighbor_table = swsscommon.Table(self.config_db, swsscommon.CFG_DEVICE_NEIGHBOR_TABLE_NAME, TABLE_SEPARATOR) | ||
(status, fvp) = device_neighbor_table.get(port_name) | ||
if status is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'if not status'
|
@pavel-shirshov: I understand that Docker sends a SIGKILL after 10 seconds, I'm just stating that with the current implementation of this daemon, the LLDP docker will always take the full 10 seconds to stop. |
dockers/docker-lldp-sv2/lldpmgrd
Outdated
|
||
if len(fvp) == 1 and fvp[0][0] == "state" and fvp[0][1] == "ok": | ||
if op == "SET" and fvp_dict["state"] == "ok": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you always have "state" in fvp_dict?
Probably better
"state" in fvp_dict and fvp_dict["state"] == "ok"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should always be there, but it can't hurt to check. Will update shortly.
dockers/docker-lldp-sv2/lldpmgrd
Outdated
(status, fvp) = device_neighbor_table.get(port_name) | ||
if not status: | ||
log_info("Port '{}' not found in {} table in Config DB. Not updating LLDP config for this port.".format(port_name, swsscommon.CFG_DEVICE_NEIGHBOR_TABLE_NAME)) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be complete, we should also listen to CFG_DEVICE_NEIGHBOR_TABLE_NAME change, since if user configure this table, we may need to update the message we send out. I understand this is not an issue now, but we should add an comment to mark as TODO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we should return here, in case there is no description, we should send "ldpcli configure ports {0} lldp portidsubtype local {1}". this will ensure we send out the correct port name instead of mac address.
dockers/docker-lldp-sv2/lldpmgrd
Outdated
port_table = swsscommon.Table(self.config_db, swsscommon.CFG_PORT_TABLE_NAME, TABLE_SEPARATOR) | ||
(status, fvp) = port_table.get(port_name) | ||
if not status: | ||
log_error("Port '{}' not found in {} table in Config DB.".format(port_name, swsscommon.CFG_PORT_TABLE_NAME)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be complete, we should also listen to PORT_TABLE_NAME change, same reason as above.
dockers/docker-lldp-sv2/lldpmgrd
Outdated
port_alias = port_table_dict["alias"] | ||
if not port_alias: | ||
log_error("Failed to obtain port alias for port '{}'".format(port_name)) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case there is no alias, then we should use port name to send out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to handle no alias case, need to handle no neighbor description case.
- Remove reconfigure.sh
…, omit description
of the Redis State database. When we are notified of the creation of an | ||
interface, update LLDP configuration accordingly. | ||
""" | ||
# Subscribe to PORT table notifications in the State DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I noted in my previous comments, we should also listen CFG_PORT_TABLE and CFG_NEIGBHRO_TABLE in case port alias change or neighbor info change, then we can send updated information to the neighbor. We do not need to do this now, but we should mark it as TODO in the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a TODO in the file header comment (lines 12-13). I think you missed it.
as I noted in my previous comments, we should also listen CFG_PORT_TABLE and CFG_NEIGBHRO_TABLE in case port alias change or neighbor info change, then we can send updated information to the neighbor. We do not need to do this now, but we should mark it as TODO in the comment. |
Commits include: * src/sonic-utilities c7e46c9...42cab68 (3): > [consutil] Look for udevprefix.conf file under platform dir, not plugins (#1431) > [ci]: download from sonic-buildimage.vs artifact (#1428) > [storyteller] sort output by time and improve lag support (#1430)
sonic-net#6768 change the kvm artifact name from kvm to vs Signed-off-by: Guohan Lu <[email protected]>
Update SAI submodule v1.9 with the following fixes 7594e53 (HEAD, origin/v1.9) Skip brcm teardown assertion (sonic-net#1423) (sonic-net#1428) 0c33f4a [FIX]Fix the circular reference issue when build sai header py (sonic-net#1427) 7e0fc24 Add support for building under Doxygen 1.9.1 (sonic-net#1414) (sonic-net#1424) 8ecf3ef [Fix]Correct enum check on branch 1.9 (sonic-net#1418) e2b2f39 Add Thrift 0.14.1 compatibility (sonic-net#1403) (sonic-net#1416)
jinja2.exceptions.UndefinedError: 'PORT' is undefined
if PORT table wasn't available at the timesel.select()
blocks and is not interrupted by signals, therefore callingdocker stop lldp
will not return until it times out after 10 seconds.