Skip to content

http-api: T3955: add commit-confirm to endpoints /configure /config-file #4533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

jestabro
Copy link
Contributor

@jestabro jestabro commented May 30, 2025

Change summary

Requests to the endpoints /configure and /config-file may include a field confirm_time of type int, which if > 0 will invoke commit-confirm with timeout := confirm_time on success of the request operation (set|delete|load|merge).

Confirming the operation is performed with a request containing 'op': 'confirm' to the respective endpoint.

An example for a list of set operations to endpoint /configure; other cases are analogous:

└──> curl -k -X POST -d '{"key": "baz", "commands": [{"op": "set", "path": ["interfaces", "ethernet", "eth1", "address", "192.168.2.137/24"]},{"op": "set", "path": ["interfaces", "ethernet", "eth1", "description", "test"]}], "confirm_time": 1}' https://192.168.122.230/configure
{"success": true, "data": "Initialized commit-confirm; 1 minutes to confirm before reload\n", "error": null}% 

└──> curl -k -X POST -d '{"key": "baz", "op": "confirm"}' https://192.168.122.230/configure
{"success": true, "data": "Reload timer stopped\n", "error": null}% 

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

How to test / Smoketest result

Checklist:

@jestabro jestabro self-assigned this May 30, 2025
Copy link

github-actions bot commented May 30, 2025

👍
No issues in PR Title / Commit Title

@jestabro jestabro force-pushed the api-commit-confirm branch from 9953a1e to b73fc84 Compare May 30, 2025 03:10
Copy link

CI integration 👍 passed!

Details

CI logs

  • CLI Smoketests (no interfaces) 👍 passed
  • CLI Smoketests (interfaces only) 👍 passed
  • Config tests 👍 passed
  • RAID1 tests 👍 passed
  • TPM tests 👍 passed

Copy link
Member

@sever-sever sever-sever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works as expected in my tests.

curl -k -X POST -d '{"key": "baz", "commands": [{"op": "set", "path": ["interfaces", "ethernet", "eth1", "address", "192.168.2.137/24"]},{"op": "set", "path": ["interfaces", "ethernet", "eth1", "description", "test"]}], "confirm_time": 1}' https://192.168.122.14/configure

curl -k -X POST -d '{"key": "baz", "op": "confirm"}' https://192.168.122.14/configure

Logs:

Jun 04 14:31:56 r14 systemd[1]: Started /usr/bin/sg vyattacfg /usr/bin/config-mgmt revert_soft.
Jun 04 14:31:56 r14 vyos-configd[787]: Received message: {"type": "init"}
Jun 04 14:31:56 r14 vyos-configd[787]: config session pid is 5739
Jun 04 14:31:56 r14 vyos-configd[787]: config session sudo_user is root
Jun 04 14:31:56 r14 vyos-configd[787]: commit_scripts: ['interfaces_ethernet_eth1']
Jun 04 14:31:56 r14 vyos-configd[787]: Received message: {"type": "node", "last": true, "data": "VYOS_TAGNODE_VALUE=eth1/usr/libexec/vyos/conf_mode/interfaces_ethernet.py"}
Jun 04 14:31:56 r14 vyos-configd[787]: Sending reply: SUCCESS with output
Jun 04 14:31:56 r14 vyos-configd[787]: scripts_called: ['interfaces_ethernet_eth1']
Jun 04 14:31:57 r14 systemd[1]: opt-vyatta-config-tmp-new_config_5739.mount: Deactivated successfully.
Jun 04 14:31:57 r14 commit[7141]: Successful change to active configuration by user root on unknown
Jun 04 14:31:57 r14 vyos-http-api[5739]: Configuration modified via HTTP API using key 'KID'
Jun 04 14:31:57 r14 vyos-http-api[5739]: INFO:      - "POST /configure HTTP/1.0" 200 OK



Jun 04 14:32:11 r14 systemd[1]: commit-confirm.timer: Deactivated successfully.
Jun 04 14:32:11 r14 systemd[1]: Stopped /usr/bin/sg vyattacfg /usr/bin/config-mgmt revert_soft.
Jun 04 14:32:12 r14 systemd[1]: opt-vyatta-config-tmp-new_config_5739.mount: Deactivated successfully.
Jun 04 14:32:12 r14 vyos-http-api[5739]: Configuration modified via HTTP API using key 'KID'
Jun 04 14:32:12 r14 vyos-http-api[5739]: INFO:      - "POST /configure HTTP/1.0" 200 OK
Jun 04 14:37:37 r14 systemd[1]: Starting Cleanup of Temporary Directories...
Jun 04 14:37:37 r14 systemd[1]: systemd-tmpfiles-clean.service: Deactivated successfully.
Jun 04 14:37:37 r14 systemd[1]: Finished Cleanup of Temporary Directories.
Jun 04 14:37:37 r14 systemd[1]: run-credentials-systemd\x2dtmpfiles\x2dclean.service.mount: Deactivated successfully.
^C
vyos@r14:~$ 

checked confirm and rollback without confirmation

@sever-sever sever-sever merged commit 5b4a665 into vyos:current Jun 4, 2025
15 of 16 checks passed
@github-actions github-actions bot added the mirror-initiated This PR initiated for mirror sync workflow label Jun 4, 2025
@vyosbot vyosbot added mirror-completed and removed mirror-initiated This PR initiated for mirror sync workflow labels Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants