srl-labs / containerlab

container-based networking labs
https://containerlab.dev
BSD 3-Clause "New" or "Revised" License
1.56k stars 266 forks source link

Startup-config doesn't work on n9kv #1477

Closed achurak closed 1 year ago

achurak commented 1 year ago

Hello,

Not sure if I'm missing something here or if it's truly a bug but as the last command in the default n9kv config it saves the running config:

2023-07-22 06:08:58,662: vrnetlab   TRACE    read from serial console:  feature netconf
feature grpc
2023 Jul 22 06:08:55 spine01 %$ VDC-1 %$ %SECURITYD-2-FEATURE_NXAPI_ENABLE: Feature nxapi is being enabled on HTTPS.
spine01(config)#
2023-07-22 06:08:58,662: vrnetlab   DEBUG    writing to serial console: exit
2023-07-22 06:08:58,662: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,614: vrnetlab   TRACE    read from serial console:  feature grpc
spine01(config)#
2023-07-22 06:09:01,614: vrnetlab   DEBUG    writing to serial console: copy running-config startup-config

The way nexus devices indicate copy progress looks like this:

switch# copy r s
[########################################] 100%
Copy complete, now saving to disk (please wait)...
Copy complete.

So when the custom startup config is being applied the config is still being saved but every # from that progress bar is erroneously treated as the switch being ready to accept the next command:

2023-07-22 06:09:01,614: vrnetlab   DEBUG    writing to serial console: copy running-config startup-config
2023-07-22 06:09:01,614: launch     TRACE    Startup config file /config/startup-config.cfg exists
2023-07-22 06:09:01,614: launch     TRACE    Parsed startup config file /config/startup-config.cfg
2023-07-22 06:09:01,615: launch     INFO     Writing lines from /config/startup-config.cfg
2023-07-22 06:09:01,615: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,655: vrnetlab   TRACE    read from serial console:  exit
spine01#
2023-07-22 06:09:01,655: vrnetlab   DEBUG    writing to serial console: configure terminal
2023-07-22 06:09:01,655: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,728: vrnetlab   TRACE    read from serial console:  copy running-config startup-config
configure terminal
[#
2023-07-22 06:09:01,728: vrnetlab   DEBUG    writing to serial console: username admin password secret role network-admin
2023-07-22 06:09:01,728: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,824: vrnetlab   TRACE    read from serial console:                                        ]   0%username admin password Hangup3-Upswing-Feast role network-admin
[#
2023-07-22 06:09:01,824: vrnetlab   DEBUG    writing to serial console: vrf context custom
2023-07-22 06:09:01,824: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,867: vrnetlab   TRACE    read from serial console:                                        ]   1%vrf context ndfc
[#
2023-07-22 06:09:01,867: vrnetlab   DEBUG    writing to serial console:   address-family ipv4 unicast
2023-07-22 06:09:01,867: vrnetlab   TRACE    waiting for '#' on serial console
[#23-07-22 06:09:01,867: vrnetlab   TRACE    read from serial console:                                        ]   2%
2023-07-22 06:09:01,867: vrnetlab   DEBUG    writing to serial console: interface Eth1/1
2023-07-22 06:09:01,867: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,867: vrnetlab   TRACE    read from serial console: #
2023-07-22 06:09:01,867: vrnetlab   DEBUG    writing to serial console:   no switchport
2023-07-22 06:09:01,867: vrnetlab   TRACE    waiting for '#' on serial console
[#23-07-22 06:09:01,867: vrnetlab   TRACE    read from serial console:                                       ]   3%
2023-07-22 06:09:01,867: vrnetlab   DEBUG    writing to serial console:   vrf member custom
2023-07-22 06:09:01,867: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,867: vrnetlab   TRACE    read from serial console: #
2023-07-22 06:09:01,867: vrnetlab   DEBUG    writing to serial console:   ip address dhcp
2023-07-22 06:09:01,867: vrnetlab   TRACE    waiting for '#' on serial console
[#23-07-22 06:09:01,867: vrnetlab   TRACE    read from serial console:                                       ]   4%
2023-07-22 06:09:01,867: vrnetlab   DEBUG    writing to serial console:   no shutdown
2023-07-22 06:09:01,868: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,868: vrnetlab   TRACE    read from serial console: #
2023-07-22 06:09:01,868: vrnetlab   DEBUG    writing to serial console: end
2023-07-22 06:09:01,868: vrnetlab   TRACE    waiting for '#' on serial console
2023-07-22 06:09:01,868: vrnetlab   TRACE    read from serial console: #
2023-07-22 06:09:01,868: vrnetlab   DEBUG    writing to serial console: copy running-config startup-config
2023-07-22 06:09:01,868: launch     INFO     Startup complete in: 0:07:05.629641

Because of this sometimes a few first commands from the custom startup-config manage to squeeze in and the rest is ignored and sometimes all of them are ignored depending on the latency and luck.

Am I doing something wrong? Is there a way to apply my custom config only after the default one is saved or is there a way to skip the config save step in the default config?

hellt commented 1 year ago

Hi @achurak yes, this looks like a bug. A long term fix would be us switching from vrnetlab to boxen (wink @carlmontanari), but for a short term fix we would need to fix the prompt to make it # instead of #.

Since this is purely a vrnetlab issue, could you please move this to github.com/hellt/vrnetlab? Thanks

achurak commented 1 year ago

Done: https://github.com/hellt/vrnetlab/issues/132