summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2026-10-13 12:48:48 -0500
committerJohn Estabrook <jestabro@vyos.io>2026-10-27 11:53:47 -0500
commit38d34ad3010622631bc651b69c470acf0b0b8cc5 (patch)
treed64eadd37dc40425b1ec82fb9a32326bff747a79 /python
parent089c767056910d1b89f72a97d96b1455d25e5bcd (diff)
downloadvyos-1x-38d34ad3010622631bc651b69c470acf0b0b8cc5.tar.gz
vyos-1x-38d34ad3010622631bc651b69c470acf0b0b8cc5.zip
T9446: start reload commit-confirm timer after commit completes
In the case of reload (revert config instead of reboot), wait until commit has returned before starting the timer. This is to avoid collision and corruption when commit time > confirm interval. For tight coupling with the commit in question, refactor to start timer from post-commit script commit_revision. The case of reboot on unconfirmed commit-confirm is unchanged.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/config_mgmt.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/python/vyos/config_mgmt.py b/python/vyos/config_mgmt.py
index 63dd11552..e3508c4da 100644
--- a/python/vyos/config_mgmt.py
+++ b/python/vyos/config_mgmt.py
@@ -226,8 +226,8 @@ are confirmed.
Proceed ?"""
else:
prompt_str = f"""
-commit-confirm will automatically reload previous config in {minutes} minutes
-unless changes are confirmed.
+commit-confirm will automatically reload previous config {minutes} minutes
+after commit completes, unless changes are confirmed.
Proceed ?"""
prompt_str = W + prompt_str
@@ -236,6 +236,21 @@ Proceed ?"""
return msg, 1
if self.reboot_unconfirmed:
+ try:
+ msg = self.commit_confirm_start_timer(str(minutes))
+ except ConfigMgmtError as e:
+ return str(e), 1
+ else:
+ msg = ''
+
+ return msg, 0
+
+ def commit_confirm_start_timer(self, timeout: str = None):
+ minutes = timeout or os.getenv(
+ 'COMMIT_CONFIRM_TIME', str(DEFAULT_COMMIT_CONFIRM_MINUTES)
+ )
+
+ if self.reboot_unconfirmed:
action = 'sg vyattacfg "/usr/bin/config-mgmt revert"'
else:
action = 'sg vyattacfg "/usr/bin/config-mgmt revert_soft"'
@@ -243,7 +258,8 @@ Proceed ?"""
cmd = f'sudo systemd-run --quiet --on-active={minutes}m --unit={timer_name} {action}'
rc, out = rc_cmd(cmd)
if rc != 0:
- raise ConfigMgmtError(out)
+ msg = f'commit-confirm timer error: {out}'
+ raise ConfigMgmtError(msg)
# start notify
if self.reboot_unconfirmed:
@@ -267,7 +283,7 @@ Proceed ?"""
else:
msg = f'Initialized commit-confirm; {minutes} minutes to confirm before reload'
- return msg, 0
+ return msg
def confirm(self) -> Tuple[str, int]:
"""Do not reboot/reload to saved/completed config following 'commit-confirm'.
@@ -496,8 +512,15 @@ Proceed ?"""
commit_revision is called in post-commit-hooks, if
['commit-archive', 'commit-revisions'] is configured.
"""
+
if os.getenv('IN_COMMIT_CONFIRM', ''):
self._new_log_entry(tmp_file=tmp_log_entry)
+ if not self.reboot_unconfirmed:
+ try:
+ msg = self.commit_confirm_start_timer()
+ except ConfigMgmtError as e:
+ print(str(e))
+ print(msg)
return
if self._archive_active_config():