Skip to content

Commit 7a34ac5

Browse files
committed
always generate push/fetch pairs - even for read only targets
1 parent 7ae87fd commit 7a34ac5

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

stackinator/mirror.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,28 +403,26 @@ def config_files(self, config_root: pathlib.Path) -> Dict[pathlib.Path, bytes]:
403403
# mount point: spack binaries embed the install prefix, so each mount
404404
# point needs its own cache to avoid relocation issues.
405405
mount = self._mount_path if self.buildcache["mount_specific"] else None
406+
# spack requires both fetch and push connections to be present in the
407+
# mirror entry, even for a read-only (keyless) build cache. Whether
408+
# packages are actually pushed to the cache is governed separately by
409+
# push_to_build_cache (only a build cache with a signing key is pushed to).
406410
entry = {
407411
"source": self.buildcache["source"],
408412
"binary": self.buildcache["binary"],
409413
"fetch": self._connection(self.buildcache, "fetch", mount),
414+
"push": self._connection(self.buildcache, "push", mount),
410415
}
411-
# a build cache is only pushed to when it has a signing key; a keyless
412-
# build cache is read-only (fetched from, never pushed to).
413-
if self.push_to_build_cache is not None:
414-
entry["push"] = self._connection(self.buildcache, "push", mount)
415416
self._add_optional_flags(entry, self.buildcache)
416417
spack_mirrors["mirrors"][self.buildcache["name"]] = entry
417418

418-
# source mirrors are read-only by default (fetch only); a push connection is
419-
# emitted only when one was explicitly configured.
420419
for name, mirror in self.source_mirrors.items():
421420
entry = {
422421
"source": mirror["source"],
423422
"binary": mirror["binary"],
424423
"fetch": self._connection(mirror, "fetch"),
424+
"push": self._connection(mirror, "push"),
425425
}
426-
if mirror.get("push") is not None:
427-
entry["push"] = self._connection(mirror, "push")
428426
self._add_optional_flags(entry, mirror)
429427
spack_mirrors["mirrors"][name] = entry
430428

unittests/test_mirrors.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,15 @@ def test_keyless_command_line_cache(tmp_path, clean_root, mount_path, systems_pa
142142
# no private key is written
143143
assert tmp_path / "key_store" / "buildcache.priv.gpg" not in files
144144

145-
# the mirror is emitted with a fetch url but no push url
145+
# spack requires both fetch and push to be present even for a read-only cache,
146+
# so push mirrors the fetch url; whether packages are pushed is gated separately
147+
# by push_to_build_cache (None here, as there is no signing key).
146148
data = yaml.safe_load(files[tmp_path / "mirrors.yaml"])
147149
assert data["mirrors"]["buildcache"] == {
148150
"source": False,
149151
"binary": True,
150152
"fetch": {"url": "/tmp/foo/user-environment"},
153+
"push": {"url": "/tmp/foo/user-environment"},
151154
}
152155

153156

@@ -170,12 +173,15 @@ def test_readonly_buildcache(tmp_path, clean_root, mount_path, systems_path):
170173
# no private key is written
171174
assert tmp_path / "key_store" / "buildcache.priv.gpg" not in files
172175

173-
# the mirror is emitted with a fetch url but no push url
176+
# spack requires both fetch and push to be present even for a read-only cache,
177+
# so push mirrors the fetch url; whether packages are pushed is gated separately
178+
# by push_to_build_cache (None here, as there is no signing key).
174179
data = yaml.safe_load(files[tmp_path / "mirrors.yaml"])
175180
assert data["mirrors"]["buildcache"] == {
176181
"source": False,
177182
"binary": True,
178183
"fetch": {"url": "https://mirror.spack.io"},
184+
"push": {"url": "https://mirror.spack.io"},
179185
}
180186

181187

0 commit comments

Comments
 (0)