Skip to content

Commit 3c9e95d

Browse files
committed
vpp: T8080: Fix handling of configuration system lock after vpp commit failure
1 parent aa3b597 commit 3c9e95d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/conf_mode/vpp.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from vyos.utils.kernel import unload_kmod
4040
from vyos.utils.kernel import list_loaded_modules
4141
from vyos.utils.process import call
42+
from vyos.utils.process import is_systemd_service_active
4243

4344
from vyos.vpp import VPPControl
4445
from vyos.vpp import control_host
@@ -771,10 +772,12 @@ def apply(config):
771772

772773
if 'settings' in config and 'interface' in config.get('settings'):
773774
# connect to VPP
774-
# must be performed multiple attempts because API is not available
775-
# immediately after the service restart
776775
try:
777-
vpp_control = VPPControl(attempts=20, interval=500)
776+
# Bail out early if VPP service is not running
777+
if not is_systemd_service_active(f'{service_name}.service'):
778+
raise RuntimeError('VPP service is not running or failed to start')
779+
780+
vpp_control = VPPControl()
778781

779782
# preconfigure LCP plugin
780783
if 'ignore_kernel_routes' in config.get('settings', {}).get('lcp', {}):
@@ -877,7 +880,7 @@ def apply(config):
877880
bitmask |= 1 << wid
878881
vpp_control.set_nat_workers(bitmask)
879882

880-
except (VPPIOError, VPPValueError) as e:
883+
except (VPPIOError, VPPValueError, RuntimeError) as e:
881884
# if cannot connect to VPP or an error occurred then
882885
# we need to stop vpp service and initialize interfaces
883886
call(f'systemctl stop {service_name}.service')

src/helpers/reset_section.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from vyos.config import Config
2727
from vyos.configdiff import get_config_diff
2828
from vyos.xml_ref import is_leaf
29+
from vyos.utils.commit import wait_for_commit_lock
2930

3031

3132
CFG_GROUP = 'vyattacfg'
@@ -100,6 +101,8 @@ def type_str_to_list(value):
100101
os.setgid(cfg_group.gr_gid)
101102
os.umask(0o002)
102103

104+
wait_for_commit_lock()
105+
103106
shared = not bool(reload)
104107

105108
session = ConfigSession(session_id, shared=shared)

0 commit comments

Comments
 (0)