Skip to content

Commit 9762a83

Browse files
committed
more s3 stuff
1 parent 183eb32 commit 9762a83

3 files changed

Lines changed: 53 additions & 22 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"Jinja2",
1616
"jsonschema",
1717
"PyYAML",
18+
"boto3"
1819
]
1920
classifiers = [
2021
"Development Status :: 5 - Production/Stable",

stackinator/mirror.py

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,17 @@ def build_cache_mirror(self) -> Optional[str]:
276276
def push_to_build_cache(self) -> Optional[str]:
277277
"""The build cache mirror name to push built packages to, or None.
278278
279-
Pushing requires a private signing key; a build cache configured without one
280-
is read-only - fetched from but never pushed to.
279+
Pushing requires a private signing key or an access pair for an S3 bucket;
280+
a build cache configured without one is read-only - fetched from but never pushed to.
281281
"""
282282

283-
if self.buildcache is not None and self.buildcache["private_key"] is not None:
283+
if (
284+
self.buildcache is not None
285+
and (
286+
self.buildcache.get("private_key") is not None
287+
or self.buildcache.get("access_pair") is not None
288+
)
289+
):
284290
return self.buildcache["name"]
285291
return None
286292

@@ -403,20 +409,51 @@ def config_files(self, config_root: pathlib.Path) -> Dict[pathlib.Path, bytes]:
403409
# point needs its own cache to avoid relocation issues.
404410
if self.buildcache["mount_specific"]:
405411
url = url.rstrip("/") + "/" + self._mount_path.as_posix().lstrip("/")
406-
entry = {"fetch": {"url": url}}
407-
# only a build cache with a signing key is pushed to
408-
if self.buildcache["private_key"] is not None:
409-
entry["push"] = {"url": url}
410-
spack_mirrors["mirrors"][self.buildcache["name"]] = entry
411-
412-
# source mirrors are read-only and provide sources only: fetch url, no push.
413-
for name, mirror in self.source_mirrors.items():
414-
spack_mirrors["mirrors"][name] = {
415-
"source": True,
416-
"binary": False,
412+
if self.buildcache["access_pair"] and self.buildcache["endpoint_url"]:
413+
spack_mirrors["mirrors"][self.buildcache["name"]] = {
414+
"fetch": {
415+
"url": mirror["url"],
416+
"access_pair": mirror["access_pair"],
417+
"endpoint_url": mirror["url"]
418+
},
419+
"push": {
420+
"url": mirror["url"],
421+
"access_pair": mirror["access_pair"],
422+
"endpoint_url": mirror["url"]
423+
},
424+
}
425+
else:
426+
spack_mirrors["mirrors"][self.buildcache["name"]] = {
417427
"fetch": {"url": mirror["url"]},
428+
"push": {"url": mirror["url"]},
418429
}
419430

431+
432+
# source mirrors are read-only and provide sources only. Push url is required but never used
433+
for name, mirror in self.source_mirrors.items():
434+
if mirror["access_pair"] and mirror["endpoint_url"]:
435+
spack_mirrors["mirrors"][name] = {
436+
"source": True,
437+
"binary": False,
438+
"fetch": {
439+
"url": mirror["url"],
440+
"access_pair": mirror["access_pair"],
441+
"endpoint_url": mirror["url"]
442+
},
443+
"push": {
444+
"url": mirror["url"],
445+
"access_pair": mirror["access_pair"],
446+
"endpoint_url": mirror["url"]
447+
},
448+
}
449+
else:
450+
spack_mirrors["mirrors"][name] = {
451+
"source": True,
452+
"binary": False,
453+
"fetch": {"url": mirror["url"]},
454+
"push": {"url": mirror["url"]},
455+
}
456+
420457
files[config_root / self.MIRRORS_YAML] = yaml.dump(
421458
spack_mirrors, default_flow_style=False, sort_keys=False
422459
).encode()

stackinator/schema/mirror.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
"type": "object",
77
"properties": {
88
"description": {"type": "string", "default": ""},
9-
"url": {"type": "string"},
10-
"access_pair": {
11-
"type": "array",
12-
"items": { "type": "string" },
13-
"minItems": 2,
14-
"maxItems": 2
15-
},
16-
"endpoint_url": {"type": "string"}
9+
"url": {"type": "string"}
1710
},
1811
"additionalProperties": false,
1912
"required": ["url"]

0 commit comments

Comments
 (0)