A door refuses all of a body, or applies all of it (#1425) #1426
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1426
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/interface-door-atomic"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #1425.
POST /interfaces/:dev/:portwrites four things — the address,enabled,description, and the cage's role — and wrote them as it went, answering400the moment one was refused:The caller is told the change failed while half of it happened. The board and the sentence about the board then disagree, and a person who reads "refused", reloads and finds a configured port cannot tell which to believe. #1413 promised this door "changes nothing on refusal" — true only when the refused field came first.
Fixed
400, address stored400, nothing written{"enabled":"false"}200, port enabled (!!"false"istrue)400 E_BAD_ENABLED, quoting"false"{"enabled":0}200, port enabled400 E_BAD_ENABLED{"description":42}200, description42400 E_BAD_DESCRIPTIONproblems: [...], all four named, each with a code1 cannot be bogus(reads as a count)port 1 cannot be bogusThe address and its mask stay one field: an address that is not an address is refused before the mask is asked about, so the same field is never reported twice.
Evidence — 12 checks
test/interface-door-atomicity.test.js, against a real server on a managed switch:400and four problems named back, all of them in the message, the address asked once;Reverting
server/index.jsfails 6 of 12, quoting the half-applied address, the200s for"false"/0/42, the missingproblemslist and1 cannot be bogus.Suite: 213 suites, 8,090 assertions, 0 failed; syntax 281 files OK. Docs:
docs/ARCHITECTURE.md, "A door refuses all of a body, or applies all of it".POST /interfaces/:dev/:port writes four things - the address, enabled, description and the cage's role - and it wrote them as it went, in that order, answering 400 the moment one was refused. Measured against a live server: {ip: 10.9.9.9, mask: 255.255.255.0, role: bogus} -> 400, and the address is stored The caller is told the change failed while half of it happened. After that the board and the sentence about the board disagree, and a person who reads 'refused', reloads and finds a configured port has no way to know which of the two to believe. #1413 promised this door 'changes nothing on refusal'; that held only when the refused field happened to come first. Now every field is checked before any is written, and a refusal reports every problem in one response ({code, error, problems:[...]}) instead of the first. The address and its mask are one field: an address that is not an address is refused before the mask is asked about. Two more questions in the same handler were being asked wrongly: {enabled: 'false'} -> 200, and the port was ENABLED because the door asked !!body.enabled, where a string is truthy. enabled is a boolean or a refusal now, and the refusal quotes what it was given. description accepted any type and is a string or a refusal. And a role refusal said '1 cannot be bogus', which reads as a count - it says 'port 1 cannot be bogus'. Evidence: test/interface-door-atomicity.test.js, 12 checks. Nine refused bodies, each compared against a byte-identical snapshot of the port's configuration (address, mask, enabled, description, role, mode, VLANs); four problems named back from one body; five accepted bodies that must actually change the port - a door that refused everything would pass the first half. Reverting server/index.js fails 6 of 12, quoting the half-applied address, the 200s for 'false'/0/42, and the count-reading message. Suite: 213 suites, 8,090 assertions, 0 failed; syntax 281 files OK.