From 48ddb8e481c0ba0b59b7193df4aa914ce83a9032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Wed, 29 Jan 2020 11:47:39 +0100 Subject: [PATCH 1/3] retry on HTTP status code 429 --- src/libstore/download.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstore/download.cc b/src/libstore/download.cc index cdf56e09d..b1a7a0282 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -357,9 +357,10 @@ struct CurlDownloader : public Downloader } else if (httpStatus == 401 || httpStatus == 403 || httpStatus == 407) { // Don't retry on authentication/authorization failures err = Forbidden; - } else if (httpStatus >= 400 && httpStatus < 500 && httpStatus != 408) { + } else if (httpStatus >= 400 && httpStatus < 500 && httpStatus != 408 && httpStatus != 429) { // Most 4xx errors are client errors and are probably not worth retrying: // * 408 means the server timed out waiting for us, so we try again + // * 429 means too many requests, so we retry (with a delay) err = Misc; } else if (httpStatus == 501 || httpStatus == 505 || httpStatus == 511) { // Let's treat most 5xx (server) errors as transient, except for a handful: From c5319e5d0b7fe9b93ae29dfe410e5baa4d3b7140 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 1 Feb 2020 12:37:22 +0100 Subject: [PATCH 2/3] Show "warning:" in yellow instead of red --- src/libutil/logging.cc | 2 +- src/libutil/util.hh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index b379306f6..fa5c84a27 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -21,7 +21,7 @@ Logger * logger = makeDefaultLogger(); void Logger::warn(const std::string & msg) { - log(lvlWarn, ANSI_RED "warning:" ANSI_NORMAL " " + msg); + log(lvlWarn, ANSI_YELLOW "warning:" ANSI_NORMAL " " + msg); } class SimpleLogger : public Logger diff --git a/src/libutil/util.hh b/src/libutil/util.hh index abf1c95d6..3bfebcd15 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -429,6 +429,7 @@ void ignoreException(); #define ANSI_FAINT "\e[2m" #define ANSI_RED "\e[31;1m" #define ANSI_GREEN "\e[32;1m" +#define ANSI_YELLOW "\e[33;1m" #define ANSI_BLUE "\e[34;1m" From 8745c63d3c674871393aa3f56c8457b056af8c87 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Mon, 3 Feb 2020 23:18:34 +0100 Subject: [PATCH 3/3] ssh-store: add remote-store and remote-program query params Brings the functionality of ssh-ng:// in sync with the legacy ssh:// implementation. Specifying the remote store uri enables various useful things. eg. $ nix copy --to ssh-ng://cache?remote-store=file://mnt/cache --all --- src/libstore/ssh-store.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstore/ssh-store.cc b/src/libstore/ssh-store.cc index 42ee06501..af99ad40a 100644 --- a/src/libstore/ssh-store.cc +++ b/src/libstore/ssh-store.cc @@ -16,6 +16,8 @@ public: const Setting sshKey{(Store*) this, "", "ssh-key", "path to an SSH private key"}; const Setting compress{(Store*) this, false, "compress", "whether to compress the connection"}; + const Setting remoteProgram{this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"}; + const Setting remoteStore{this, "", "remote-store", "URI of the store on the remote system"}; SSHStore(const std::string & host, const Params & params) : Store(params) @@ -82,7 +84,9 @@ ref SSHStore::getFSAccessor() ref SSHStore::openConnection() { auto conn = make_ref(); - conn->sshConn = master.startCommand("nix-daemon --stdio"); + conn->sshConn = master.startCommand( + fmt("%s --stdio", remoteProgram) + + (remoteStore.get() == "" ? "" : " --store " + shellEscape(remoteStore.get()))); conn->to = FdSink(conn->sshConn->in.get()); conn->from = FdSource(conn->sshConn->out.get()); initConnection(*conn);