Skip to content

fault_manager: change rosbag retention parameters while the node runs - #864

Draft
bburda wants to merge 1 commit into
feat/rosbag-retention-5cfrom
feat/rosbag-retention-6
Draft

bburda wants to merge 1 commit into
feat/rosbag-retention-5cfrom
feat/rosbag-retention-6

Conversation

@bburda

@bburda bburda commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Today every rosbag retention parameter is read-only after startup, so PUT .../configurations/snapshots.rosbag.retention... on the gateway answers 403. Issue 705 rule 10 asks that each retention parameter can be changed while the node runs: "A bad value is rejected with HTTP 400 and the reason. A valid value applies to existing recordings at once. Adding or removing a rule needs a restart."

This PR is on top of twelve PRs in the stack. Please review those first. The diff of this PR is against the branch of the PR directly below it.

What it adds:

  • Writable retention parameters. Every retention parameter given at startup can be set. The top-level min_free_disk_mb and sweep_interval_sec are always declared, with their defaults. A key not given at startup is not declared, so a PUT of it answers 400 ("not declared"): adding a rule needs a restart.

  • Validation. A change is checked as the whole configuration with the change applied, using the same parser as at startup. It is rejected only for errors it adds, so with two invalid values at startup each one can be fixed on its own. When the whole configuration becomes valid, the node leaves degrade and clears ROSBAG_RETENTION_CONFIG_INVALID.

    • A value cannot be unset.
    • A set that mixes retention and other parameters is refused.
  • Applied at once. The new policy is published right away. One job on the retention worker then applies it to existing recordings:

    • a lower max_bags trims at once;
    • on_cleared or on_healed turning to delete applies to faults already in that status, after a status check under the fault manager's lock;
    • a changed age, floor or interval resets the periodic job and runs one pass.

    A priority or over_quota change removes nothing. A storage failure logs a WARN, and the same PUT again retries.

  • The gateway's parameter write, for every node:

    • The gateway reads the parameter's descriptor before a PUT.
    • A dynamically typed parameter now gets the JSON value's own type, so 1.5 for an integer field reaches the node and is rejected. Before, it was truncated to 1.
    • A rejection answers 403 only when the descriptor says read-only. Before, a reason that contained the text "read-only" (for example a fault code) answered 403.
    • Parameters with a fixed type convert as before.
  • Docs: docs/config/fault-manager.rst (with a PUT example), docs/api/rest.rst, the gateway and fault manager READMEs, the design doc and the example retention file.

What changes for users

  • Retention parameters can be changed over the API. A change is lost at restart: the parameters file wins.
  • A bad value answers 400 with the reason, and nothing changes.
  • The gateway keeps the JSON type for dynamically typed parameters of any node. A client that sent a string or a fraction for such a parameter and relied on the conversion now gets the node's own answer. Each PUT makes one more round trip (the descriptor read).
  • A node that rejects a value with "read only" in its own reason, on a parameter that is not declared read-only, now gets 400. Before, it got 403.

Issue


Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

  • colcon build --packages-up-to ros2_medkit_fault_manager ros2_medkit_gateway ros2_medkit_integration_tests --cmake-args -DPOSTGRES_SUPPORT=ON, then colcon test for those packages and colcon test-result --verbose.
  • src/ros2_medkit_integration_tests/test/features/test_retention_runtime.test.py runs a real gateway and real fault manager over HTTP. It covers:
    • each field family;
    • a priority change on the list;
    • a lower max_bags trimming;
    • status actions on existing faults;
    • age, interval and floor changes;
    • bad values and types;
    • keys not given at startup;
    • leaving degrade one key at a time;
    • reset;
    • other parameters still read-only;
    • a priority change that runs no pass.
  • In the fault manager package:
    • test_retention_config.test.py covers mixed and unset values.
    • test_retention_runtime_pg.test.py covers a storage failure during the job, and the retry.
    • test_rosbag_storage_availability.test.py covers a trim that leaves a recording of an unavailable storage alone.
  • One in-process test, RosbagRetention.StatusActionSkipsAFaultActiveAgain, covers a fault that fails again between the job's list and its action. A real process cannot force that order.
  • I ran this on Jazzy with PostgreSQL 14. Humble and Lyrical run in CI. clang-tidy on the changed files reports nothing new.

Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

@bburda
bburda added this pull request to stack #836 December 1, 2026 13:21
@bburda
bburda force-pushed the feat/rosbag-retention-6 branch from 5a06a1f to 24748c3 Compare December 1, 2026 15:43
@bburda
bburda force-pushed the feat/rosbag-retention-6 branch from 24748c3 to b23fb3b Compare December 2, 2026 12:15
* feat(fault_manager): change rosbag retention parameters while the node runs
* fix(fault_manager): refuse mixed parameter sets; PostgreSQL case in the fault manager
* fix(fault_manager): run retention passes only for age, floor or interval changes
* fix: decide each floor step and open-time check with one retention policy
@bburda
bburda force-pushed the feat/rosbag-retention-6 branch from b23fb3b to 68ec80b Compare December 2, 2026 18:24

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