Repository navigation
fix(rest,cli): refuse a DrbdOptions property LINSTOR's whitelist refuses - #313
Conversation
LINSTOR refuses to store a property its whitelist does not list for the object, and a value the key's rule refuses. blockstor stored any DrbdOptions key verbatim, so a typo reached the satellites and every replica's .res. The package holds the DrbdOptions rules of the linstor-common that linstor-server v1.33.1 builds from, per object, and checks a key and value the way LINSTOR's Property classes do, with LINSTOR's own description of what a rule accepts. hack/gen-drbd-whitelist regenerates the embedded catalogue from a linstor-common checkout. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A typo such as DrbdOptions/AutoSnapshot/Keep was stored, every satellite rendered it into the .res, drbdadm refused the file and every replica of the definition failed each apply until the key was deleted. The caller had been told the write succeeded. Every door that stores properties now checks the DrbdOptions keys it would set against the whitelist of the object they land on, and refuses the request with LINSTOR's FAIL_INVLD_PROP entry, storing none of it, as LINSTOR does. A key on the wrong object and a value the key's rule refuses are refused the same way. Deletes are not judged, so a key stored before the check can still be removed. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The native CLI writes the CRDs directly, so the check the REST doors apply did not reach `rd sp`, the command the typo came through. set-property and drbd-options now judge the key and value against the whitelist of the noun's object before they touch the bag; a delete is not judged. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Rows 62 and 66 recorded that blockstor stored any DrbdOptions value and any option class on any object. Both are now refused as upstream refuses them, so the rows go, and an L6 cell and an L7 replay pin the refusal at the operator CLI. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Several cases wrote values or keys LINSTOR refuses, and the REST and CLI doors now refuse them too: ping-timeout 500 (its range ends at 300), sndbuf-size 512K (a byte count without unit), protocol on a volume definition, and a net option on a single replica. They now use a value in range or a key the object takes, so they keep testing what they were written for. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The whitelist is LINSTOR's, and LINSTOR does not list the few DrbdOptions keys blockstor reads on its own: the definition and group switch for the auto tiebreaker (AutoAddQuorumTiebreaker) and the node port and minor ranges (TcpPortRange, MinorNrRange). They are documented as the way to set what they set, GET returns the tiebreaker switch in a definition's props, and the e2e suites write it through REST, so refusing them turned each of those writes into a 400 and left no way to turn the tiebreaker off per definition. Accept them next to the generated catalogue, each only on the objects its reader looks at and with a value that reader can parse. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
The check accepts Yes or TRUE without regard to case, as LINSTOR's does, but stored the value as given. LINSTOR stores it normalised (WhitelistProps.normalize): yes/no in lower case, a true/false key as true or false. The readers are not as lenient as the check. drbdadm takes only yes and no, so the satellite leaves a stored Yes out of the .res and the option silently has no effect; strconv.ParseBool takes no yes or no, so AutoEvictAllowEviction=no read as unset. Rewrite an accepted value to LINSTOR's form at every REST door and in the CLI's set-property and drbd-options before it is stored. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
drbd-options offered --after-resync-source and --disconnected, two handlers drbd.conf documents but LINSTOR's whitelist does not list. The whitelist check refuses their keys on every object, so the flags could only ever fail. Drop them, and test that every offered knob resolves to a key the whitelist accepts. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
The parity part matches LINSTOR v1.33.2. CtrlPropsHelper.fillProperties refuses a known key with a bad value as Invalid property(<key>) value: <value> with the rule in details, and an unknown key as Invalid property key: <key> / The key '<key>' is not whitelisted. (CtrlPropsHelper.java:613-630). WhitelistProps.isAllowed passes a null value, the delete (WhitelistProps.java:294-325), and normalize stores the canonical form (334-342). The REST and CLI wiring judges only the keys a request sets, and the upgrade note covers the linstor-csi StorageClass case. My one blocker is licensing, inline.
I know the tree already has third_party/linstor-common as a submodule and a hand port of drbdoptions entries in pkg/drbd/options.go. If linstor-common data is meant to be acceptable input, that exception belongs in AGENTS.md, so the rule matches what the code does.
| @@ -0,0 +1,845 @@ | |||
| { | |||
| "source": "linstor-common 64240e34a6e2 (linstor-server v1.33.1)", | |||
There was a problem hiding this comment.
This file is generated by a tool from properties.json and drbdoptions.json in linstor-common, the submodule of the GPLv3 linstor-server. linstor-common has no license file of its own, and its genproperties.py stamps GPLv3 on what it generates. AGENTS.md lists "no GPL artifacts may enter the tree" as a hard rule, including any GPL-marked spec file and "code generated from a GPL source by any tool". Committing this output plus hack/gen-drbd-whitelist reads as exactly that case. Please either derive the rules clean-room (the drbdsetup man pages are on the safe list), or record an explicit exception for linstor-common data in AGENTS.md in this PR, so the rule and the tree agree.
There was a problem hiding this comment.
Took the second option: 8a829da records the exception in AGENTS.md, next to the GPL rule, so the rule and the tree agree. It is narrow. A tool may read drbdoptions.json and properties.json from third_party/linstor-common as data and carry over only the interface facts a client depends on: key names, value types, enum values, ranges and units. Nothing else crosses: no descriptions or help text, no code, no comments, and nothing genproperties.py writes under its GPLv3 stamp, GeneratedPropertyRules.java included. A file built this way names its linstor-common commit.
drbdoptions.json itself is gendrbdoptions.py output over drbdsetup xml-help, so it holds the same facts as the drbdsetup man pages. The generated pkg/propwhitelist/drbdoptions.json keeps a type and the bounds per key and nothing more (no description field), and its source names linstor-common 64240e34a6e2. The same exception also covers the existing submodule and the hand port in pkg/drbd/options.go.
The licensing rules forbid anything generated from a GPL source, yet the tree already reads linstor-common: the submodule, the hand port in pkg/drbd/options.go and now the generated DrbdOptions whitelist. The rule and the tree have to agree. Record the exception narrowly. drbdoptions.json is gendrbdoptions.py output over drbdsetup xml-help, the same facts the drbdsetup man pages carry, and properties.json lists LINSTOR's accepted keys. Only those interface facts may cross: key names, types, enum values, ranges and units. Descriptions, code and everything genproperties.py writes under its GPLv3 stamp stay out. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
Thanks for checking the parity against CtrlPropsHelper and WhitelistProps. The licensing point is answered inline, with the exception in AGENTS.md (8a829da). I also merged main into the branch in 30d59d6 (a normal merge); the conflicts were the imports in |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
The AGENTS.md exception answers my licensing point, and the committed drbdoptions.json stays inside it: only types, ranges, units and enum values, with the linstor-common commit named in source. The merge of main keeps the whitelist refusal ahead of the new witness hold in createResources, so a refused request returns before taking the hold. The red unit tests fail the same way on main.
The only conflict was the import block of internal/cli/handlers.go, where main added pkg/naming next to this branch's pkg/propwhitelist; both are kept. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
LGTM. I compared this head with the one I approved at 30d59d6. The patch is the same apart from one blank line; the rest is the merge of main.
What this PR does
blockstor stored any
DrbdOptions/*property it was given. A typo such asblockstor rd sp <rd> DrbdOptions/AutoSnapshot/Keep 2(meant asAutoSnapshot/Keep) was accepted, every satellite rendered it into theoptionsblock of the resource's.res,drbdadmrefused the file, and every replica of the definition reportedApplyFailedand retried with back-off until the key was deleted. The caller saw success; the mistake surfaced only as Warning events on the nodes.LINSTOR refuses such a write before it stores anything. Its whitelist lists, per object, which keys may be set, and each key has a rule its value must meet (
CtrlPropsHelper.fillProperties,WhitelistProps.isAllowed). This PR does the same for theDrbdOptions/namespace, on the REST API and in the native CLI, which writes the CRDs directly and so needs the check of its own.Whitelist. A new
pkg/propwhitelistpackage embeds the DrbdOptions rules of thelinstor-commonthat linstor-server v1.33.1 builds from (properties.jsonanddrbdoptions.json), per object: controller, node, resource definition, volume definition, resource, volume, storage pool, storage pool definition, node connection, resource connection. A resource group is judged as a resource definition and a volume group as a volume definition, as LINSTOR does. Values are checked the way LINSTOR'sPropertyclasses check them (yes/no booleans, ranges, symbols, numeric-or-symbol, longs).hack/gen-drbd-whitelistregenerates the catalogue from alinstor-commoncheckout.REST. Every door that stores properties checks the keys it would set: controller set-property, node create and modify, resource group create and modify (with its volume groups), volume group create and modify, resource definition create, modify and clone, volume definition create and modify, resource create and modify, volume modify, node connection, storage pool and storage pool definition modify. A refused write stores nothing and answers 400 with LINSTOR's
FAIL_INVLD_PROP(213) entry:Invalid property key: <key>/The key '<key>' is not whitelisted.for an unknown key,Invalid property(<key>) value: <value>with the rule indetailsfor a bad value, and the controller's own wording on the controller. An empty value (the set-property delete) anddelete_propsare not judged, so a key stored before this check can still be removed. Keys outsideDrbdOptions/are not judged.CLI.
set-propertyanddrbd-optionson every noun apply the same check before they touch the bag;delete-propertyis not judged.blockstor's own keys. blockstor reads three DrbdOptions keys LINSTOR does not list, documents them as the way to set what they set, and returns one of them in a definition's props:
DrbdOptions/AutoAddQuorumTiebreaker(the per-definition and per-group tiebreaker switch) on the controller, definitions and groups, andDrbdOptions/TcpPortRangeandDrbdOptions/MinorNrRange(writtenmin-max) on nodes. They are accepted next to the generated catalogue, only on those objects and only with a value their reader can parse, so the e2e suites that write the tiebreaker switch through REST and clients that write back the props they read keep working.Normalised values. Like LINSTOR (
WhitelistProps.normalize), an accepted boolean is stored in its canonical form, at every REST door and in the CLI.Licensing. AGENTS.md forbids anything generated from a GPL source, and linstor-common is a submodule of the GPLv3 linstor-server with no license file of its own. This PR adds a narrow exception there: a tool may read
drbdoptions.jsonandproperties.jsonas data and carry over only interface facts (key names, value types, enum values, ranges, units), never descriptions, code, comments or anythinggenproperties.pystamps GPLv3.pkg/propwhitelist/drbdoptions.jsonholds only those facts and names the linstor-common commit it was built from. The same exception covers the existing submodule and the hand port inpkg/drbd/options.go.Behaviour changes
DrbdOptions/*key LINSTOR does not whitelist for the object is refused withFAIL_INVLD_PROP, including a valid DRBD option on the wrong object (anetoption on a volume definition, any section option on a node or a replica).DrbdOptions/*key with a value its rule refuses is refused, for examplequorum-minimum-redundancy bogusormax-buffers 8.docs/cli-parity-known-deltas.mdare closed and removed.Yesasyesfor a yes/no option,NoorFALSEasfalsefor a true/false key. Before, it was stored as given, so the satellite left a capitalisedYesout of the.res(drbdadm takesyesandnoonly) andAutoEvictAllowEviction noread as unset.drbd-options --after-resync-sourceand--disconnectedare gone. LINSTOR does not whitelist those handlers, so the flags could only fail.Known limitations
drbdsetup xml-helpdescribes to the controller whitelist at startup. blockstor uses the static catalogue for every object, so a controller option newer than drbd-utils 9.32 is refused until the catalogue is regenerated.DrbdOptions/auto-add-quorum-tiebreaker, is accepted and stored but blockstor does not read it, as before this PR; onlyAutoAddQuorumTiebreakerturns the witness off. A definition adopted from LINSTOR that carriesauto-add-quorum-tiebreaker falsestill gets a witness. Reading it changes which witnesses exist on adopted clusters, so it is left to a separate change.DrbdOptions/namespace is checked; LINSTOR checks every namespace exceptAux/and a few EBS tags..reswith a Warning Event instead of failing every apply, is in fix(satellite): render volume definition disk options the way LINSTOR does #275.Upgrade note
The check judges only the keys a request sets, so an object that already carries a refused key keeps it and can still be modified. A request that sends such a key again is refused, as LINSTOR refuses it. This matters for linstor-csi, which sends a StorageClass's
property.linstor.csi.linbit.com/*parameters with each provisioning: a StorageClass carrying a refused DrbdOptions key will fail every PVC after the upgrade. Before upgrading, check the StorageClass parameters and the props of groups and definitions that clients write back against the whitelist. On the test cluster this PR was checked against, every StorageClass parameter and every group prop passes; the only stored values it refuses are two keys LINSTOR's controller writes for itself (auto-verify-algon definitions,auto-verify-algo-allowed-liston the controller) andauto-quorum=majorityon some definitions, none of which a client sends.Testing
pkg/propwhitelist: unknown keys, keys on the wrong object, value rules for every type with LINSTOR's messages, other namespaces untouched.pkg/rest: the typo is refused withFAIL_INVLD_PROPon each of the doors listed above; a request with one bad key stores none of its keys; a bad value is refused with the rule indetails; the controller uses its own wording;delete_propsand the empty-value set-property still remove a key stored earlier; whitelisted options and other namespaces still land. The C6 corner case now asserts the refusal.internal/cli:set-propertyrefuses the typo, a bad value and a misspelt net key on a definition and on the controller and stores nothing;delete-propertystill removes such a key;drbd-optionsrefuses a value its rule refuses.Yes,NoandYESare stored asyes,falseandtrueover REST (definition and node) and by the CLI'sset-propertyanddrbd-options.drbd-optionsoffers resolves to a key the whitelist accepts on a definition.set-propertyor indrbd-options, and putting the two handler flags back.tests/e2e/cli-matrix/rd-sp-unwhitelisted-drbd-option-rejected.shand L7 replaytests/operator-harness/replay/rd-sp-unwhitelisted-drbd-option-rejected.yaml.make lint-config && make lint: 0 issues.go test ./...with envtest 1.35.0 passes.go test -tags=integration ./tests/integration/...passes; five cases there wrote values or keys LINSTOR refuses (ping-timeout 500,sndbuf-size 512K,protocolon a volume definition, a net option on a replica) and now use accepted ones. In the full run one case failed with the python CLI container exiting 139 (a segfault of the emulated client image, not a blockstor answer); it passed on rerun together with every case this PR touched.Merging into the alpha line
This branch starts from
main. Ondev/v0.4.0-alpha.14it conflicts in four places, each an insertion next to code the alpha line changed:internal/cli/handlers.go(the noun table),pkg/rest/autoplace.go(createResources),pkg/rest/storage_pools.go(the pool modify refusals) anddocs/cli-parity-known-deltas.md. Keep both sides.Not tested
cli-parity-refresh.shwas not run.