Repository navigation
api: reject state/result changes to done nodes - #726
Merged
Merged
Conversation
The unit tests send requests to versioned_app, which gets the API routes through include_router() and resolves dependencies against its own dependency_overrides. The auth mocks were only registered on app, so every authenticated endpoint test got 401 Unauthorized. Register the same overrides on versioned_app. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
A lab can report a job more than once. The later report silently replaced the first result of a node that was already done (e.g. pass, then fail 15 minutes later), while the KCIDB bridge had already sent the first result to the dashboard, leaving Maestro and the dashboard out of sync with nobody noticing. Make the first final result win: PUT/PATCH /node and PUT /nodes now return 409 Conflict when they would change the state or result of a done node. The hierarchy is checked as a whole before anything is written. Resubmitting the same result is still allowed, and so is the late result for a node closed without one (incomplete, e.g. by node_timeout), which the LAVA callback relies on. Admins can override with force=true. Every rejected or forced change is counted in the metrics and published on the node-integrity channel, so it can be monitored through /events?channel=node-integrity. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A lab can report the same job more than once. On production,
baseline-arm64-sasha-labon jetson-tx1-devkit (node6ae228345c0836a8c2f041a8) was submitted as done/pass at 17:15 and as done/fail (kernel panic) at 17:29 on 2026-10-28. The secondPUT /nodesreplaced the first result. The KCIDB bridge had already sent the PASS, so the dashboard still shows PASS while Maestro shows fail. Nothing reported the mismatch; it only turned up in the dashboard validation workflow.The cause: the state machine allows
done→done, so a done node's result can change freely, andPUT /nodes/{id}replaces the root node without any transition check.Change
PUT /node/{id},PATCH /node/{id}andPUT /nodes/{id}return 409 Conflict if they would change the state or result of a node that is alreadydone. The first final result wins. ForPUT /nodes, every existing node in the hierarchy is checked before anything is written.incompleteor no result, e.g. bynode_timeout), which the LAVA callback relies on?force=true. For other users,forceis ignored.node_done_update_rejected_total/node_done_update_forced_totalnode-integritychannel, with node, runtime, platform, old and attempted state/result, and user. Events are stored in eventhistory, so they can be queried with/events?channel=node-integrity. kernelci-pipeline's dashboard validation workflow posts them to Discord (ci: Report rejected changes to done nodes kernelci-pipeline#1663).A separate commit fixes the unit-test auth mocks. They were registered on
apponly, while requests go toversioned_app, so every authenticated endpoint test returned 401.Testing
Unit tests were run in the
docker/api/Dockerfileimage (tests requirements, kernelci-coremain) against redis 6.2 and mongo 5.0:tests/unit_tests/test_node_done_update.pypass.mainin this environment: the same 15 failures and 8 errors, all in tests this change doesn't touch.Deployment notes
src/timeout.pyalready catchesHTTPError. Each 409 is also visible on thenode-integritychannel.force=true.