Skip to content

network_xray tool: optional loop that keeps 'netlab validate' results in the lab directory - #4063

Open
rclab-dev wants to merge 1 commit into
ipspace:devfrom
rclab-dev:network-xray-validate-plugin
Open

rclab-dev wants to merge 1 commit into
ipspace:devfrom
rclab-dev:network-xray-validate-plugin

Conversation

@rclab-dev

Copy link
Copy Markdown
Collaborator

As discussed in #4015 (option 1), this adds an opt-in plugin to the network_xray tool definition, in netsim/extra/tools/network_xray.

What it does

When the user sets tools.network_xray.validate: True, the plugin runs netlab validate --format json in the lab directory while the lab is running and writes the results into network_xray/validate.json. network-xray can read that file through the read-only /lab mount and show the results as netlab reports them.

  • Opt-in only; nothing changes for labs that don't set tools.network_xray.validate.
  • tools.network_xray.validate_interval sets the interval (default: 30 seconds). The documentation notes that every run executes all validation tests, so VM-based labs should use a longer interval.
  • It uses the plugin CLI hooks (post_shell_post_tools_start, pre_shell_pre_stop_lab, post_shell_post_cleanup) and does not touch the user CLI hooks.
  • netlab down stops the background process, netlab down --cleanup removes the files, and netlab up --no-tools does not start it. The process also stops when the lab snapshot disappears, after 12 hours (validate_max_hours), or after 20 failed runs in a row.
  • The tool definition only gets the plugin line; the docker commands are unchanged.

Tested with FRR containers (OSPF, one validation test): netlab up, the JSON file updates, a second netlab up, netlab down, netlab up --no-tools, netlab down --cleanup, without validate: True, and with plugin: []. ruff, mypy, yamllint, and the transformation/coverage tests pass.

I wrote this with help from an AI coding assistant, and reviewed and tested it myself.

Happy to change names, defaults, or anything else you'd prefer.

… in the lab directory

The tools.network_xray plugin (loaded with the network_xray tool) can
run 'netlab validate --format json' in the background while the lab is
up and write the results into network_xray/validate.json, so the
network-xray web page can show the validation results.

* Opt-in: runs only when tools.network_xray.validate is True
* tools.network_xray.validate_interval sets the interval (default: 30s)
* Started after the tools by 'netlab up', stopped by 'netlab down',
  files removed by 'netlab down --cleanup'
* Uses the plugin CLI hooks; the user CLI hooks are not changed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant