[ZTP] Re-assert front panel port config after ZTP profile removal - #6
Merged
gord1306 merged 1 commit intoAug 11, 2026
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 down until something writes CONFIG_DB, which is why a manual config interface shutdown/startup recovers it. Anything running on the Linux netdev, LLDP and DHCP in particular, stops working on the affected port while "show interfaces status" keeps reporting up/up, since that command reads APPL_DB. Which ports are affected depends on which ones happened to be oper up when interfaces-config sampled APPL_DB with redis-dump, so the failure can look 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. The write is idempotent and does not flap a port that is already up. Measured on a 54 port platform: the loop issues 108 portmgrd re-applications, mtu and admin_status for each port, and completes in 1.8 seconds. 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>
gord1306
force-pushed
the
fix/ztp-reassert-port-config-after-teardown
branch
from
August 11, 2026 02:47
a0f6f27 to
dd82ca1
Compare
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, 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, and 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 down until something writes CONFIG_DB — which is why a manualconfig interface shutdown/startuprecovers it.Anything running on the Linux netdev, LLDP and DHCP in particular, stops working on the affected port while
show interfaces statuskeeps reporting up/up, since that command reads APPL_DB.Which ports are affected depends on which ones happened to be oper up when
interfaces-config.sh:34sampled APPL_DB withredis-dump, so the failure can look intermittent. Note that waiting for all ports to come up before that sample would make it worse rather than 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_statusis written. The write is idempotent and does not flap a port that is already up.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" and the profile has been removed:
The second command returns 0, confirming the ZTP stanzas are gone and the removal path has run. Without this change the first command also drops to 0 while
show interfaces statusstill reports every port as up. With the change the front panel ports that have carrier stay up, andshow interfaces statusagrees withip link.Measured on a 54 port unit: the loop issues 108
portmgrdre-applications (mtu and admin_status for each port) and completes in 1.8 seconds.Notes
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.