From b56d2383c1e0c39418af35665f7d5b21cf49d381 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 7 Dec 2023 14:30:44 -0500 Subject: [PATCH] Do not attempt to speak a newer version of the protocol Both sides need to agree on a version (with `std::min`) for anything to work. Somehow... we've never done this. With this comment, the next commit succeeds. Without this commit, the next commit fails. This is because the next commit exposes serializers which do different things for proto version 2.7, and we're currently requesting 2.6. Opened https://github.com/NixOS/nix/issues/9584 to track this issue --- src/hydra-queue-runner/build-remote.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index 1fdd5a23..659618b7 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -203,7 +203,9 @@ static std::pair openLogFile(const std::string & logDir, cons */ static void handshake(Machine::Connection & conn, unsigned int repeats) { - conn.to << SERVE_MAGIC_1 << 0x206; + constexpr ServeProto::Version our_version = 0x206; + + conn.to << SERVE_MAGIC_1 << our_version; conn.to.flush(); unsigned int magic = readInt(conn.from); @@ -215,6 +217,9 @@ static void handshake(Machine::Connection & conn, unsigned int repeats) throw Error("unsupported ‘nix-store --serve’ protocol version on ‘%1%’", conn.machine->sshName); if (GET_PROTOCOL_MINOR(conn.remoteVersion) < 3 && repeats > 0) throw Error("machine ‘%1%’ does not support repeating a build; please upgrade it to Nix 1.12", conn.machine->sshName); + + // Do not attempt to speak a newer version of the protocol + conn.remoteVersion = std::min(conn.remoteVersion, our_version); } static BasicDerivation sendInputs(