build-remote/logging: use machine names instead of uris

Change-Id: Iafe7b3e780d3a69dc4bb2d745ff40db6df7111e8
This commit is contained in:
rootile
2026-06-16 17:58:23 +02:00
parent 4b0371bff3
commit 7bf0edcc0d
2 changed files with 40 additions and 8 deletions
+4 -8
View File
@@ -96,7 +96,7 @@ static std::tuple<bool, Machine *, AutoCloseFD> selectBestMachine(
uint64_t bestLoad = 0;
for (auto & m : machines) {
debug("considering building on remote machine '%s'", m.storeUri);
debug("considering building on remote machine '%s'", m.name);
if (m.enabled && m.systemSupported(neededSystem) && m.allSupported(requiredFeatures)
&& m.mandatoryMet(requiredFeatures))
@@ -329,9 +329,8 @@ try {
Pipe logPipe;
try {
auto act = logger->startActivity(
lvlTalkative, actUnknown, fmt("connecting to '%s'", bestMachine->storeUri)
);
auto act =
logger->startActivity(lvlTalkative, actUnknown, fmt("connecting to '%s'", bestMachine->name));
std::tie(sshStore, logPipe) = TRY_AWAIT(bestMachine->openStore());
TRY_AWAIT(sshStore->connect());
@@ -341,10 +340,7 @@ try {
} catch (std::exception & e) { // NOLINT(lix-foreign-exceptions)
std::string msg = logPipe.readSide ? chomp(drainFD(logPipe.readSide.get(), false)) : "";
printError(
"cannot build on '%s': %s%s",
bestMachine->storeUri,
e.what(),
msg.empty() ? "" : ": " + msg
"cannot build on '%s': %s%s", bestMachine->name, e.what(), msg.empty() ? "" : ": " + msg
);
bestMachine->enabled = false;
}
+36
View File
@@ -1,3 +1,7 @@
from testlib.fixtures.file_helper import CopyFile
from testlib.fixtures.file_helper import File
from pathlib import Path
from textwrap import dedent
import pytest
import re
import textwrap
@@ -150,3 +154,35 @@ def test_remote_trustless_ca(
out_path = (env.dirs.home / "result").readlink()
assert nix.physical_store_path_for(out_path).read_text() == "FOO BAR BAZ\n"
@with_files(
{
"check-reqs.nix": CopyFile("assets/check-reqs.nix"),
"config.nix": get_global_asset("config.nix"),
"builders.toml": File(
dedent("""
[machines.fox]
uri = "file://test-home/fox-store"
supported-features = ["kvm", "big", "benchmark"]
[machines.dragon]
uri = "file:///dev/null/"
supported-features = ["kvm", "big", "benchmark"]
[machines.plushie]
uri = "ssh-ng://plushie@example.com"
""")
),
}
)
def test_logging_uses_machine_name(nix: Nix, files: Path):
nix.settings["builders"] = f"@{files}/builders.toml"
nix.settings["max-jobs"] = 0
res = nix.nix_build(["check-reqs.nix", "-vvvvv"]).run().expect(1)
for builder in ["fox", "dragon", "plushie"]:
assert f"considering building on remote machine '{builder}'" in res.stderr_plain
assert f"cannot build on '{builder}': error: " in res.stderr_plain
assert f"connecting to '{builder}'..." in res.stderr_plain