libstore: drop Store::connect

there's no reason a store should not open a connection during init if it
needs to open any connection to function. delaying connection setup like
this makes openStore less deterministic and graceful fallback impossible

this caused test failures where the old behaviour was required to ensure
test output stability. because of course something like that must happen

Change-Id: I946adddee026f1f4c74b4699d730b4d1ac9a5072
This commit is contained in:
eldritch horrors
2026-07-17 18:00:14 +00:00
parent 57fb4f534d
commit f5b9f105e2
11 changed files with 14 additions and 15 deletions
-1
View File
@@ -272,7 +272,6 @@ try {
logger->startActivity(lvlTalkative, actUnknown, fmt("connecting to '%s'", bestMachine->name));
sshStore = TRY_AWAIT(bestMachine->openStore());
TRY_AWAIT(sshStore->connect());
co_return BuilderConnection{std::move(bestSlotLock), sshStore, bestMachine->storeUri};
} catch (std::exception & e) { // NOLINT(lix-foreign-exceptions)
printError("cannot build on '%s': %s", bestMachine->name, e.what());
+1 -1
View File
@@ -594,7 +594,7 @@ public:
co_return result::current_exception();
}
kj::Promise<Result<void>> connect() override
kj::Promise<Result<void>> init() override
try {
auto conn(TRY_AWAIT(connections->get()));
co_return result::success();
+1 -2
View File
@@ -697,8 +697,7 @@ try {
co_return result::current_exception();
}
kj::Promise<Result<void>> RemoteStore::connect()
kj::Promise<Result<void>> RemoteStore::init()
try {
auto conn(TRY_AWAIT(getConnection()));
co_return result::success();
+1 -1
View File
@@ -170,7 +170,7 @@ public:
kj::Promise<Result<std::optional<std::string>>> getVersion() override;
kj::Promise<Result<void>> connect() override;
kj::Promise<Result<void>> init() override;
kj::Promise<Result<unsigned int>> getProtocol() override;
+2 -7
View File
@@ -253,7 +253,8 @@ public:
/**
* Perform any necessary effectful operation to make the store up and
* running
* running. For stores that open connections to remote hosts `init()`
* must also open such a connection and report errors as appropriate.
*/
virtual kj::Promise<Result<void>> init()
{
@@ -874,12 +875,6 @@ public:
(co_await state.lock())->pathInfoCache.clear();
}
/**
* Establish a connection to the store, for store types that have
* a notion of connection. Otherwise this is a no-op.
*/
virtual kj::Promise<Result<void>> connect() { return {result::success()}; }
/**
* Get the protocol version of this store or it's connection.
*/
-2
View File
@@ -25,7 +25,6 @@ struct CmdPingStore : StoreCommand, MixJSON
{
if (!json) {
notice("Store URL: %s", store->getUri());
aio().blockOn(store->connect());
if (auto version = aio().blockOn(store->getVersion()))
notice("Version: %s", *version);
if (auto trusted = aio().blockOn(store->isTrustedClient()))
@@ -37,7 +36,6 @@ struct CmdPingStore : StoreCommand, MixJSON
});
res["url"] = store->getUri();
aio().blockOn(store->connect());
if (auto version = aio().blockOn(store->getVersion()))
res["version"] = *version;
if (auto trusted = aio().blockOn(store->isTrustedClient()))
+1 -1
View File
@@ -25,5 +25,5 @@ def test_stdio_forward_failure(nix: Nix, files: Path):
.run()
.expect(1)
)
assert "stream ended unexpectedly" in result.stderr_plain
assert "cannot open connection to remote store" in result.stderr_plain
assert "Lix crashed" not in result.stderr_plain
@@ -3,6 +3,8 @@ import pytest
from typing import NamedTuple
from textwrap import dedent
pytestmark = pytest.mark.no_daemon
class ShouldError(NamedTuple):
expr: str
@@ -1,10 +1,14 @@
from collections.abc import Callable
from pathlib import Path
import pytest
from testlib.fixtures.file_helper import with_files, File, AssetSymlink, Symlink
from testlib.fixtures.nix import Nix
from testlib.fixtures.snapshot import Snapshot
pytestmark = pytest.mark.no_daemon
@with_files(
{
@@ -21,6 +21,7 @@ def _clean_output(output: str, origin: Path) -> str:
return re.sub(lix_version_regex, "Lix VERSION", output.replace(str(origin), "/pwd"))
@pytest.mark.nix_settings(trusted_users="*") # silence trusted settings warnings
def test_repl_char(nix: Nix, do_snapshot_update: bool, metadata: ReplTestMetadata, files: Path):
nix.settings.add_xp_feature("nix-command", "flakes", "repl-automation")
with MarkdownRenderer() as renderer:
@@ -9,6 +9,7 @@ from testlib.fixtures.file_helper import File, FileDeclaration, with_files
from testlib.fixtures.http_server import http_server
from testlib.fixtures.nix import Nix
pytestmark = pytest.mark.nix_settings(trusted_users="*")
ca_key: str = """
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==