summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOleksandr Kuchmystyi <o.kuchmystyi@vyos.io>2026-02-24 15:12:44 +0300
committerOleksandr Kuchmystyi <o.kuchmystyi@vyos.io>2026-02-25 10:35:55 +0300
commite8c6a8f37470416e72a26fbbdfad24f8dcea7208 (patch)
tree45b563d25a7d0f8035ad87fad21038b388c461ee /src
parent662b45c159393aa9451c93b168da415021949857 (diff)
downloadvyos-1x-e8c6a8f37470416e72a26fbbdfad24f8dcea7208.tar.gz
vyos-1x-e8c6a8f37470416e72a26fbbdfad24f8dcea7208.zip
vpp: T8297: Fixed double enabling of VPP
When trying to configure the VPP interface using `set vpp settings interface eth0` and `commit`, user first see a success. Upon repeating the configuration after deleting and re-adding it, the commit fails with an error: - `FileExistsError: Cannot open locked storage: /run/vpp/vpp_conf.json` This indicates that another process is using the file or a previous operation did not release the lock, preventing new changes from being written. The commit adds context manager support and safe close to `JSONStorage` and refactor VPP config handling.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/vpp.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py
index b02c809ec..90356e6f4 100755
--- a/src/conf_mode/vpp.py
+++ b/src/conf_mode/vpp.py
@@ -231,10 +231,10 @@ def get_config(config=None):
# this is required because some interfaces after they are connected
# to VPP is really hard or impossible to restore without knowing
# their original parameters (like IDs)
- persist_config = JSONStorage('vpp_conf')
- eth_ifaces_persist: dict[str, dict[str, str]] = persist_config.read(
- 'eth_ifaces', {}
- )
+ with JSONStorage('vpp_conf') as persist_config:
+ eth_ifaces_persist: dict[str, dict[str, str]] = persist_config.read(
+ 'eth_ifaces', {}
+ )
if config:
conf = config
@@ -692,10 +692,10 @@ def apply(config):
modules = ('vfio_iommu_type1', 'vfio_pci', 'vfio_pci_core', 'vfio')
# Open persistent config
# It is required for operations with interfaces
- persist_config = JSONStorage('vpp_conf')
if not config or ('removed_ifaces' in config and 'settings' not in config):
# Cleanup persistent config
- persist_config.delete()
+ with JSONStorage('vpp_conf') as persist_config:
+ persist_config.delete()
# And stop the service
call(f'systemctl stop {service_name}.service')
# Unlod modules (modprobe -r)
@@ -869,7 +869,8 @@ def apply(config):
# Save persistent config
if 'persist_config' in config and config['persist_config']:
- persist_config.write('eth_ifaces', config['persist_config'])
+ with JSONStorage('vpp_conf') as persist_config:
+ persist_config.write('eth_ifaces', config['persist_config'])
# reinitialize interfaces, but not during the first boot
if boot_configuration_complete():