Skip to content

Implement SSHStore on top of nix-daemon served over ssh - #1053

Merged
edolstra merged 11 commits into
NixOS:masterfrom
shlevy:ssh-store
Nov 9, 2016
Merged

edolstra merged 11 commits into
NixOS:masterfrom
shlevy:ssh-store

Conversation

@shlevy

@shlevy shlevy commented Sep 2, 2016

Copy link
Copy Markdown
Member

Fixes #986

@shlevy

shlevy commented Sep 2, 2016

Copy link
Copy Markdown
Member Author

Replaces #997

@shlevy

shlevy commented Sep 2, 2016

Copy link
Copy Markdown
Member Author

@edolstra I will port over build-remote and nix-copy-closure to this once merged

@shlevy shlevy added this to the perl-to-c++ milestone Sep 2, 2016
@shlevy

shlevy commented Sep 9, 2016

Copy link
Copy Markdown
Member Author

@edolstra ping

Comment thread src/libstore/ssh-store.cc Outdated
else
execlp("ssh", "ssh", "-N", "-M", "-S", socketPath.c_str(), "-i", key.c_str(), uri.c_str(), NULL);
throw SysError("starting ssh master");
}))

@edolstra edolstra Sep 12, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be good to start the SSH master lazily. Otherwise, if you have an SSH store in your binary-caches setting, the SSH master will be started for every Nix command, even when the SSH store isn't used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the SSH master cleaned up? On Linux, dieWithParent is implicit in startProcess(), but what would happen on OS X?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will implement laziness.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed

Comment thread src/nix-daemon/nix-daemon.cc Outdated

auto socketDir = dirOf(socketPath);
if (chdir(socketDir.c_str()) == -1)
throw SysError(format("changing to socket directory %1%") % socketDir);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing quotes around %1%.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed

@edolstra

Copy link
Copy Markdown
Member

Looks good to me.

However: Regarding nix-copy-closure, it will need to be backwards compatible. Otherwise, for instance, a NixOps on Nix 1.12 wouldn't be able to copy closures to a pre-1.12 system. From that perspective, it would actually make sense to implement SSHStore on top of the nix-store --worker protocol.

@shlevy

shlevy commented Sep 12, 2016

Copy link
Copy Markdown
Member Author

@edolstra I don't think it makes sense to implement the entire store API in nix-store --serve, but perhaps a fallback for just the operations already implemented makes sense. Does that sound OK?

@shlevy

shlevy commented Sep 12, 2016

Copy link
Copy Markdown
Member Author

Ugh, there's really no clean way to do that. Maybe it's better to just implement nix-copy-closure on top of the serve API directly and have nix copy be the way of the future.

@shlevy

shlevy commented Sep 12, 2016

Copy link
Copy Markdown
Member Author

@edolstra Alternatively, could we port the nix-daemon changes to 1.11.5 and have a milder compatibility break that way?

@shlevy

shlevy commented Sep 12, 2016

Copy link
Copy Markdown
Member Author

(thanks to @domenkozar for the idea)

@domenkozar

domenkozar commented Sep 12, 2016 •

Copy link
Copy Markdown
Member

The other alternative I see is that we:

  1. ship 1.12 with perl only for nix-copy-closure, so it supports both protocols
  2. really remove perl in 1.13 (maybe 2.0)

I hate this option, but it's better than rewriting some software for one release.

@shlevy

shlevy commented Sep 12, 2016

Copy link
Copy Markdown
Member Author

Actually, we could also bundle nix-copy-closure.pl with the perl bindings package and have nixops hard-code the path to that one, so main nix is still perl-free.

@shlevy

shlevy commented Sep 12, 2016

Copy link
Copy Markdown
Member Author

OK my preferred solution:

  1. remove nix-copy-closure from main nix altogether. nix copy is the way for the future
  2. Have nix-perl contain nix-copy-closure (perl version), and include it by default (maybe with a deprecation warning) in user environments, hard-coded in nixops, etc. until it seems safe to not do so, but give users a way to be perl free if they want.

@domenkozar

Copy link
Copy Markdown
Member

I like that. It's the same as my previous suggestion, but with better separation of concerns.

Can't really judge how much that spares work over reimplementing it in C++.

@shlevy

shlevy commented Sep 21, 2016

Copy link
Copy Markdown
Member Author

@edolstra ?

@edolstra

Copy link
Copy Markdown
Member

My preferred solution would be to have a minimal SSHStore that uses nix-store --serve. That would give the least headaches with backward compatibility. We can keep the full-featured SSHStore, renaming it to SSHStoreNG or something like that.

A more complicated solution would be to have a full-featured, backward-compatible SSHStore that uses nix-store --serve, by extending the serve protocol to upgrade to the Nix daemon protocol if both sides support it. So:

  • nix-store --serve sends a server version of 0x203. (Nix 1.11 is 0x202.)
  • If the client sees a server version of 0x203, it sends a client version of 0x203.
  • If the server sees a client version of 0x203, it then switches over to the Nix daemon protocol for the rest of the connection. This would require moving most of nix-daemon into a library so it can be used by nix-store --serve.
  • If the server sees a client version < 0x203, it uses the old --serve protocol.
  • If the client sees a server version < 0x203, it sends a client version of 0x202 and uses the old --serve protocol. Thus SSHStore will only be able to provide a few operations like copying paths.

@shlevy

shlevy commented Sep 23, 2016

Copy link
Copy Markdown
Member Author

Why is it worth a decent chunk of work (implementing a C++ nix-store --serve client, rewriting nix-copy-closure again) for features we already know in advance are going away eventually (nix-copy-closure for nix copy, serve-store and 1.11 compat for sshstore) when we already have perfectly good backwards compatibility options in keeping nix-copy-closure perl and distributing it either with nix itself or with a separate package that is bundled by default?

@shlevy

shlevy commented Sep 23, 2016

Copy link
Copy Markdown
Member Author

In either case, are there concerns with this PR? It would be good to have it merged before too much chance for drift happens.

@shlevy

shlevy commented Sep 23, 2016

Copy link
Copy Markdown
Member Author

We could have a non-default --without-perl configure flag, and have --with-perl bring in nix-perl during the compliation process. So people building from source get backwards compat by default, and people building in nixpkgs we can do the bundling however we want (either in separate packages automatically included together or or in a single derivation), and people who are ready to switch to nix copy can do so.

@shlevy

shlevy commented Oct 2, 2016

Copy link
Copy Markdown
Member Author

@edolstra ping

1 similar comment
@shlevy

shlevy commented Oct 7, 2016

Copy link
Copy Markdown
Member Author

@edolstra ping

@shlevy

shlevy commented Oct 12, 2016

Copy link
Copy Markdown
Member Author

@edolstra I will do a dumb rewrite of nix-copy-closure like I did with nix-build if you insist on the backwards compatibility, but what is your thought on this PR (and the build-remote that will be based on it)?

@shlevy

shlevy commented Oct 20, 2016

Copy link
Copy Markdown
Member Author

@edolstra ping

@Ericson2314

Copy link
Copy Markdown
Member

...I have to say, while its no news things can move slowly around here, I'd hope things could be better the sake of @shlevy getting his pay and those that chipped in getting their Perl-freedom in a timely manner.

@edolstra

Copy link
Copy Markdown
Member

Sorry about the delay, will try to make some progress on this the next few days.

@copumpkin

Copy link
Copy Markdown
Member

Friendly bump 😄 I'd hate for this to die/bitrot

@edolstra
edolstra merged commit b99c6e0 into NixOS:master Nov 9, 2016
@Ericson2314

Copy link
Copy Markdown
Member

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants