A handle is where a store is made, not only where it is found - #153
Open
torstei wants to merge 1 commit into
Open
A handle is where a store is made, not only where it is found#153torstei wants to merge 1 commit into
torstei wants to merge 1 commit into
Conversation
`timberfs create nginx` made a store in whatever directory it was run from, which `timberfs query nginx` then could not find — the two halves of the same name disagreed. A bare token (no `/`) is a HANDLE for a destination too now: `create`, `append --into` and `import --into` resolve one exactly as reading does, and where nothing holds that handle yet the store is made in the forest, at <forest>/<handle>/<handle>.log — the layout every intake already writes. So `create nginx` then `query nginx` are one store whichever directory either ran in, and a provisioning unit re-running `create --if-not-exists nginx` from a different working directory lands on the store it made last boot instead of making a second one beside it. `append --into nginx` had the same split and gets the same rule, or the two commands would disagree about what `nginx` means the moment create learned the forest. With NO forest declared, or with several, a bare destination is refused and says which. Resolving it to the working directory is the answer that reads as success and leaves a store no handle finds. Only the directory handle is matched — never a declared name or an id prefix, since either can name several stores and a write destination may not be a guess. `is_existing_store` no longer counts a DIRECTORY, which is the same bug seen from the other side: <forest>/nginx is the ordinary shape of a store, so from inside the forest root the token `nginx` meant that directory. Measured before the fix: `query nginx` there failed with "no index file ./nginx.rings" — there and nowhere else — and `create nginx` wrote a flat nginx.trunk/.rings beside the nested store, after which the handle matched both and resolved to neither. A plain file still counts, so a path that is not a store keeps producing the error it always did rather than turning into a handle.
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.
timberfs create nginxmade a store in whatever directory it was run from,which
timberfs query nginxthen could not find — the two halves of the samename disagreed.
A bare token (no
/) is now a handle for a destination too:create,append --intoandimport --intoresolve one exactly as reading does, andwhere nothing holds that handle yet the store is made in the forest, at
<forest>/<handle>/<handle>.log— the layout every intake already writes.append --intohad the same split and gets the same rule: had onlycreatelearned the forest, the two commands would have disagreed about what
nginxmeans, and
appendwould have gone on creating shadow stores in the cwd.Refusals, not a fallback
With no forest declared, or with several, a bare destination is refused
and says which:
Resolving it to the working directory is the answer that reads as success and
leaves a store no handle finds. Only the directory handle is matched —
never a declared name or an id prefix, since either can name several stores and
a write destination may not be a guess.
The same bug from the other side
is_existing_storeno longer counts a directory.<forest>/nginxis theordinary shape of a store, so from inside the forest root the token
nginxmeant that directory. Measured on the current build, before the fix:
query nginxthere failed withno index file ./nginx.rings— there andnowhere else;
create nginxwrote a flatnginx.trunk/nginx.ringsbeside the nestedstore, after which the handle matched both and
query nginxwas ambiguousfrom everywhere.
A plain file still counts, so a path that is not a store keeps producing the
error it always did instead of turning into a handle.
Tests
Six new unit tests in
src/forest.rs(destination in the forest,.logstripped once, an existing handle is the destination itself, paths still pass
through, no-forest/several-forests refused, an ambiguous handle refused, and a
directory is not a store) — 346 pass.
One new VM test,
forest: a bare destination is created in the forest, not the cwd: it is the shippeddefault.confthat decides, which the env-var unittests cannot exercise. It creates from a foreign cwd, appends to the same
handle from
/, reads it back, re-runscreate --if-not-exists, does all ofit again from inside
/var/log/timberfs(asserting no flat store appearsbeside the nested one), and declares a second forest to check the refusal.
Docs
timberfs(1)(a newDESTparagraph under create, and the destinationhalf of the rule in FORESTS), the three
--into/DESThelp strings,README.md, anddocs/concepts.md(forest, handle).