-
Notifications
You must be signed in to change notification settings - Fork 3
Add Rhai scripting to faux-mgs enabled by feature "rhaiscripting" #366
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
base: main
Are you sure you want to change the base?
Conversation
9aedb56
to
370c141
Compare
I like the idea of a rhai scripting interface over writing a bunch of shell. I also think there's multiple parts to this: there's the actual rhai interface for faux-mgs and then there's making that interface usable for test scripts. racktest uses rhai but it's slightly different because both the interface and the test scripts are within the same package which is not the case with faux-mgs. I think the Another separate thought: Is this is a sign that we're doing too much with the faux-mgs binary and maybe we need |
I added Hubtools issue #51. Knowledge about Hubris archives should migrate there. Existing Hubtools functions, like |
9db1a1f
to
1ff1811
Compare
This message can be used in favor of resetting the RoT when recovering from a failed or abandoned update. A RoT transient or persistent Hubris activation has a pending phase that is resolved on next boot. Clearing the pending activation allows a new update flow to proceed without resetting the RoT, or with a reset, allows the update flow to proceed without switching to a different image (assuming a properly signed alternate image).
Rust code changes: - add Rhai scripting as a feature (--features=rhaiscript) - add ArchiveInspector for access to RawHubrisArchive - add "system(argv) -> #{exit_code, stdout, stderr}" from std::process::Command - export faux-mgs paramsters to Rhai main. - run any faux-mgs command with "let result = faux_mgs(["arg0", .. "argN"]); - faux-mgs results are passed back to the script as a map even if they are simpler JSON. - ChronoPackage for time handling. - FilesystemPackage for file access. - EnvironmentPackage for env var access. - export "scriptdir" so that script can get other files relative to itself. - "verify_rot_image()" to verify a RoT image vs CFPA, CMPA. - vars available to main(): - "argv" - script main's scope passing all remaining CLI args. - "rbi_default" - expose faux-mgs default "rot_boot_info" version - "interface" - pass the "--interface INTERFACE" value. - "reset_watchdog_timeout_ms" - pass that value to the script. - Route Rhai's debug function to the faux-mgs log. - The `debug("message")` function is routed to the faux-mgs slog logging. Prefixing a message with "crit|", "trace|", "error|", "warn|", "error|", or "debug|" will log at that corresponding level. Leaving off the prefix or using some other prefix will log at the debug level. - Rhai's `print()` still goes to stdout. Rhai scripts: scripts/util.rhai contains common script and faux-mgs support. - getops() - to_hexstring() - cstring_to_string(a) - array_to_mac(a) - ab_to_01(v) - env_expand(s, override) - rot_boot_info() - state() - caboose_value(component, slot, key) - get_device_cabooses() - rkth_to_key_name(rkth) - array_to_blob(a) - get_cmpa() - get_cfpa() - get_rot_keyset() scripts/update-rollback.rhai - Only use MGS messages for testing, no humility or other APIs - perform happy path update and rollback from baseline to under-test images. scripts/targets.json - an example configuration script for scripts/update-rollback.rhai
Fix `json_to_map()` so that JSON errors are reported properly. Some calls to `print()` change to logging to debug or info. Add configuration for `faux-ipcc`. - since system() needs to be used to run faux-ipcc, should there be a regex to parse or are Rhai's existing string functions sufficient to pull out certs and measurements? Since faux-ipcc doesn't handle attestations yet, we'll wait a bit.
Move RawHubrisArchive knowledge to a separate source file.
Also work around baseline not implementing transient boot preference
Also error handling in to_hexstring.
Positional baseline and UT args become options. Remove dead code. Add docs and tests for getopts
Power control is needed to test recovery from failed RoT updates when using transient boot preference and fault insertion.
Checkin TEST_PLAN.md for upgrade-rollback tests Update TODO.md for upgrade-rollback tests The FMR script helps when running single commands from the repo that use rhai scripts.
- Fix `faux_mgs` rhai function to return full error text. - Changed `util::set_rot_boot_preference()` to `util::rot_boot_preference(..., action, ...)` - Test recovery flows for dealing with previous failed or abandoned updates that set RoT image preferences.
Also: Update scripts test plan, scripts todo list, and remove Hubris issue #2093 workaround.
Rhai scripting is added to facilitate developer testing and potential CI use cases.
This scripting feature is much nicer to use than the bash scripts in the sprot-e2e repo. It was the threat of having to update those that motivated this PR.
See the README.md file in
scripts/README.md
.This PR has the
rhaiscript
feature on by default.Thanks to John for some help about a year ago to help me with async recursion.