Page MenuHomeVyOS Platform

Improve errorhandling when/if config.boot is deleted or missing
Closed, ResolvedPublicBUG

Description

I deleted /config/config.boot on purpose but couldnt then reboot or shutdown the VyOS box through cli:

root@vyos:/config# reboot
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 236, in <module>
    main()
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 219, in main
    execute_shutdown(args.reboot, reboot=True, ask=args.yes)
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 120, in execute_shutdown
    check_unsaved_config()
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 113, in check_unsaved_config
    if unsaved_commits() and boot_configuration_success():
       ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/config_mgmt.py", line 76, in unsaved_commits
    ret = not cmp(tmp_save, config_file, shallow=False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/filecmp.py", line 54, in cmp
    s2 = _sig(os.stat(f2))
              ^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/opt/vyatta/etc/config/config.boot'
root@vyos:/config# poweroff
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 236, in <module>
    main()
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 227, in main
    execute_shutdown(args.poweroff, reboot=False, ask=args.yes)
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 120, in execute_shutdown
    check_unsaved_config()
  File "/usr/libexec/vyos/op_mode/powerctrl.py", line 113, in check_unsaved_config
    if unsaved_commits() and boot_configuration_success():
       ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/config_mgmt.py", line 76, in unsaved_commits
    ret = not cmp(tmp_save, config_file, shallow=False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/filecmp.py", line 54, in cmp
    s2 = _sig(os.stat(f2))
              ^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/opt/vyatta/etc/config/config.boot'

Suggestion to add errorhandling for this case which should include an option if config should be restored from archive (commit-revisions).

If admin answers "no" then during next boot a config.boot will be recreated from config.boot.default anyway.

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.4-rolling-202308260020
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)