-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Store
hierarchy with a new IndirectRootStore
interface
#8243
Refactor Store
hierarchy with a new IndirectRootStore
interface
#8243
Conversation
Discussed in Nix team meeting 2023-05-12:
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-05-12-nix-team-meeting-minutes-54/28197/1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit “meh” on that change. I see where it's coming from, but at the same time, the API and implementation of IndirectRootStore::addPermRoot
pretty much force any instance of it to be baked by a locally mounted filesystem. This means that – unless I'm overlooking something – any instance of IndirectRootStore
could be made an instance of LocalFSStore
(and benefit from some performance benefits by bypassing the daemon where it can be).
(Btw, 781ead0 seems unrelated to that PR except that it is also part of #7912)
src/libstore/gc-store.hh
Outdated
* - The base Store class has Store::addTempRoot() because for a store | ||
* that doesn't support garbage collection at all, a temporary GC root | ||
* is safely implementable as no-op. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is debatable when the same store can be accessed in different ways where one can be gc-ed and the other can't (For instance I can't add a root over ssh, but that doesn't prevent someone from gc-ing that store locally)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is a good point. I guess I will reward this comment as tech debt TODO instead :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added below.
src/libstore/gc-store.hh
Outdated
* - The derived LocalFSStore class has LocalFSStore::addPermRoot, | ||
* which is not part of this class because it relies on the notion of | ||
* an ambient file system. There are stores (`ssh-ng://`, for one), | ||
* that *do* support garbage collection but *don't* expose any file | ||
* system, and LocalFSStore::addPermRoot thus does not make sense for | ||
* them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not true any more since addPermRoot
is part of IndirectRootStore
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the abstract method is still in LocalFSStore
. IndirectRootStore
merely has an implementation. The next PR ads another implementation.
* possible implementations many of which make no sense. Having this and | ||
* that invariant enforced cuts down that space. | ||
*/ | ||
struct IndirectRootStore : public virtual LocalFSStore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that name is not great. The most important bit here isn't that the store can register indirect roots (any ssh-ng
could in theory), but that it can register permanent roots (although addPermRoot
is implemented and final
here, it only makes sense for stores that have a local filesystem baking)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The important bit is in fact the indirect roots.
it only makes sense for stores that have a local filesystem baking
It is a subclass of LocalFSStore
, so unless you meant something like "non ssh/NFS" by "local" that is in fact always the case.
LocalFSStore
defines addPermRoot
. So the point of this class isn't to define that interfaec, but to merely implement it. The point is the indirect root implementation.
@thufschmitt I think you got the inheritance backwards.
Any instance must be that, because |
fa61b44
to
00edcac
Compare
Indeed, I missed the “IndirectRootStore inherits from LocalFSSTore” bit. But that still doesn't seem right to me: It's not clear why we need an extra class for this (we could simply have this be part of the Also,
Feels a bit weak as a justification to me. This feels less of an issue to me than having to leak the |
Yes, the The client only does The table, which I save for that follow-up PR, is supposed to answer this question (given these leaf classes, we have these combinations to support with intermediate classes...).
I made the type |
... looks like yes, the expected use would be via |
This is because `StoreConfig` also uses it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments help describe the structure and motivation. Implementation makes sense, builds, and allows for the planned future changes in #7912 (and any additional alternative store implementations, also can be useful for layered stores)
Will need to do subclass-specific implementations in the next commit. This isn't because there will be multiple variations of the daemon protocol (whew!) but because different clients pick and choose different parts to use.
See the API doc comments for details.
00edcac
to
60d8dd7
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-07-24-nix-team-meeting-minutes-74/31116/1 |
Motivation
This is preparatory work needed for the "mounted ssh store" feature implemented in Mounted SSH Store #7912. That feature is very useful for Nix with NFS, as in common in organization settings.
Even without the above feature, I think it bring greater clarity to the relationship between the existing stores, and between
addIndirectRoot
andaddPermRoot
.As an example of the above:
SSHStore
had a remote-sideaddIndirectRoot
implementation, but that makes no no sense.SSHStore
does not expose the ambient file system, and so one should run the risk of accidentally making symlinks on the remote side that make no sense.With this,
SSHStore
does not have anaddIndirectRoot
method at all.See the extensive API docs for more details.
Context
#7912 will be rebased on top once this is merged. It will then be much smaller.
The commits here are separated for easier review.
#5729 is somewhat related, though in this case we are cleaning up the subclasses not
Store
itself.(Note can review commit-by-commit.)
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 👍 to pull requests you find important.