Page MenuHomeVyOS Platform

Can't load archived configs as they are gzipped
Closed, ResolvedPublic

Description

The current implementation of the config archive stores archived configs in /config/archive, where all but the latest config are gzipped. Trying to load one from config mode results in an error:

vyos@vyos# load /config/archive/config.boot.1.gz
Traceback (most recent call last):
  File "/usr/libexec/vyos/vyos-load-config.py", line 59, in <module>
    with open(canonical_path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/vyatta/etc/config//config/archive/config.boot.1.gz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/libexec/vyos/vyos-load-config.py", line 64, in <module>
    config_file = f.read()
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
[edit]

vyos@vyos# load archive/config.boot.1.gz
Traceback (most recent call last):
  File "/usr/libexec/vyos/vyos-load-config.py", line 60, in <module>
    config_file = f.read()
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
[edit]

This is because vyos-load-config.py expects a plaintext file so it needs to be manually extracted first.

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Behavior change
Issue type
Bug (incorrect behavior)

Event Timeline

jjakob created this object in space S1 VyOS Public.

I think it some code like

if canonical_path.endswith(".gz"):
    canonical_path = gzip.GzipFile(canonical_path, 'rb')

https://github.com/vyos/vyos-1x/blob/current/src/helpers/vyos-load-config.py#L51

Thanks @Viacheslav; I'm running other tests with vyos-load-config at the moment, and will check and add.

jestabro moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus board.
erkin set Issue type to Bug (incorrect behavior).Aug 31 2021, 5:16 PM