[ZTP] Re-assert front panel port config after ZTP profile removal - #6
Open
gord1306 wants to merge 1 commit into
Open
[ZTP] Re-assert front panel port config after ZTP profile removal#6gord1306 wants to merge 1 commit into
gord1306 wants to merge 1 commit into
Conversation
When ZTP completes, ztp-profile.sh remove deletes ZTP|mode from CONFIG_DB and then restarts interfaces-config. interfaces-config regenerates /etc/network/interfaces from interfaces.j2, whose ZTP in-band block is gated on ZTP['mode'] being defined. With that table gone the block is no longer rendered and the regenerated file contains no Ethernet stanza at all. interfaces-config.sh then runs "systemctl restart networking", which performs "ifdown -a" followed by "ifup -a". ifupdown2 tears down every front panel port it had adopted for ZTP in-band DHCP, and ifup -a does not bring them back because they are no longer listed. The netdev is left administratively down with its MTU reset to the kernel default of 1500, while CONFIG_DB, APPL_DB and the ASIC all continue to report the port as up. portmgrd only acts on CONFIG_DB events and keeps no desired state, so it never notices nor corrects the drift. The port stays broken until an operator runs config interface shutdown/startup, which writes CONFIG_DB and thereby produces the event portmgrd needs. Because lldpd sends and receives on the Linux netdev, LLDP stops working on the affected port while "show interfaces status" keeps reporting up/up, since that command reads APPL_DB. On a customer AS4630-54PE this left an uplink without LLDP neighbors until a manual port bounce. Whether one or both uplinks are hit depends only on which ports happened to be oper up when interfaces-config sampled APPL_DB, so the failure looks intermittent. Re-assert the front panel port configuration after the interfaces-config restart. Writing any field of CONFIG_DB PORT|<port> back with its current value produces a keyspace event, and SubscriberStateTable delivers the entire hash to the consumer, so portmgrd re-applies both mtu and admin_status. This was verified on an AS4630-54PE: a single no-op HSET of admin_status produced portmgrd: doTask: Configure Ethernet50 MTU to 9100 portmgrd: doTask: Configure Ethernet50 admin status to up and "ip -o link show" was byte for byte identical before and after, confirming the operation is idempotent and does not flap a port that is already up. interfaces-config.service and networking.service are both Type=oneshot and neither restart uses --no-block, so ifdown/ifup have completed by the time the loop runs. Signed-off-by: gord_chen <gord_chen@edge-core.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I did it
When ZTP completes,
ztp-profile.sh removedeletesZTP|modefrom CONFIG_DB and then restartsinterfaces-config:interfaces-configregenerates/etc/network/interfacesfrominterfaces.j2, whose ZTP in-band block is gated onZTP['mode']being defined:With that table gone the block is no longer rendered, so the regenerated file contains no Ethernet stanza at all.
interfaces-config.sh:70then runssystemctl restart networking, which performsifdown -afollowed byifup -a. ifupdown2 tears down every front panel port it had adopted for ZTP in-band DHCP, andifup -adoes not bring them back because they are no longer listed. The netdev is left administratively down with its MTU reset to the kernel default of 1500, while CONFIG_DB, APPL_DB and the ASIC all continue to report the port as up.portmgrdonly acts on CONFIG_DB events and keeps no desired state (portmgr.cpp:336erases the event once applied; the 1 s tick inportmgrd.cpp:58callsConsumer::drain(), which returns immediately whenm_toSyncis empty). It therefore never notices nor corrects the drift, and the port stays broken until an operator runsconfig interface shutdown/startup— which works only because that writes CONFIG_DB and thereby produces the event portmgrd needs.Because lldpd sends and receives on the Linux netdev, LLDP stops working on the affected port while
show interfaces statuskeeps reporting up/up, since that command reads APPL_DB. Observed on a customer AS4630-54PE:How many ports are hit depends only on which ones happened to be oper up when
interfaces-config.sh:34sampled APPL_DB withredis-dump, so the failure looks intermittent. Two real cases from the same customer unit:Note that waiting for all ports to come up before the snapshot would make this worse, not better: it would turn an intermittent single port failure into a deterministic all ports failure.
How I did it
Re-assert the front panel port configuration after the
interfaces-configrestart.Writing any field of
CONFIG_DB PORT|<port>back with its current value produces a keyspace event, andSubscriberStateTable::pops()delivers the entire hash to the consumer:so
portmgrdre-applies bothmtuandadmin_statuseven though onlyadmin_statuswas written.Verified on an AS4630-54PE. A single no-op HSET of
admin_statusproduced:and
ip -o link show Ethernet50was byte for byte identical before and after, confirming the operation is idempotent and does not flap a port that is already up. The keyspace event fires even though the value is unchanged.interfaces-config.serviceandnetworking.serviceare bothType=oneshotand neither restart uses--no-block, soifdown/ifuphave completed by the time the loop runs.How to verify it
On a unit doing inband ZTP, after ZTP reaches "ZTP successfully completed":
Before this change at least one front panel port is left
state DOWN mtu 1500and missing fromshow lldp table, recoverable only by a manualconfig interface shutdown/startup.Notes and limitations
KEYSplus twosonic-db-clicalls per port. On a 54 port unit that is around 110 process spawns. ZTP teardown is not time critical, but a reviewer may prefer batching this into a single call. I kept the plain loop because that is the exact form I was able to verify on hardware.config-fallbacksub-path already performsconfig reload, which re-applies everything, so the loop is redundant but harmless there.tests/test_ztp_engine.pydoes not exerciseztp-profile.sh.Related