Skip to content

Commit 43c1490

Browse files
committed
Add support for S3 repositories
1 parent 59df127 commit 43c1490

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

alibuild_helpers/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def finaliseArgs(args, parser, star):
234234
if args.architecture == "slc7_x86-64" and not args.preferSystem:
235235
args.noSystem = True
236236
if not args.remoteStore:
237-
args.remoteStore = "https://alicache.cern.ch/"
237+
args.remoteStore = "https://s3.cern.ch/swift/v1/alibuild-repo"
238238

239239
if args.remoteStore or args.writeStore:
240240
args.noSystem = True

alibuild_helpers/build.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,26 @@ def getRetry(self, url, dest=None):
122122
os.rename(dest+".tmp", dest) # we should not have errors here
123123
return True
124124
else:
125-
# No destination specified: JSON request
126-
resp = get(url, verify=not self.insecure, timeout=self.httpTimeoutSec)
127-
if resp.status_code == 404:
128-
# No need to retry any further
129-
return None
130-
resp.raise_for_status()
131-
return resp.json()
125+
# For CERN S3 we need to construct the JSON ourself...
126+
s3Request = re.match("https://s3.cern.ch/swift/v1[/]+([^/]*)/(.*)$", url)
127+
if s3Request:
128+
[bucket, prefix] = s3Request.groups()
129+
url = "https://s3.cern.ch/swift/v1/%s/?prefix=%s" % (bucket, prefix.strip("/"))
130+
resp = get(url, verify=not self.insecure, timeout=self.httpTimeoutSec)
131+
if resp.status_code == 404:
132+
# No need to retry any further
133+
return None
134+
resp.raise_for_status()
135+
resp = resp.text
136+
return [{"name": basename(x), "type": "file"} for x in resp.split()]
137+
else:
138+
# No destination specified: JSON request
139+
resp = get(url, verify=not self.insecure, timeout=self.httpTimeoutSec)
140+
if resp.status_code == 404:
141+
# No need to retry any further
142+
return None
143+
resp.raise_for_status()
144+
return resp.json()
132145
except (RequestException,ValueError,PartialDownloadError) as e:
133146
if i == self.httpConnRetries-1:
134147
error("GET %s failed: %s" % (url, str(e)))

tests/test_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FakeExit(Exception):
6666
((), "init zlib --dist ktf/alidist@dev" , [("dist", {"repo": "ktf/alidist", "ver": "dev"})]),
6767
((), "build zlib --remote-store rsync://test.local/" , [("noSystem", True)]),
6868
((), "build zlib --remote-store rsync://test.local/::rw" , [("noSystem", True), ("remoteStore", "rsync://test.local/"), ("writeStore", "rsync://test.local/")]),
69-
((), "build zlib --architecture slc7_x86-64" , [("noSystem", True), ("preferSystem", False), ("remoteStore", "https://alicache.cern.ch/")]),
69+
((), "build zlib --architecture slc7_x86-64" , [("noSystem", True), ("preferSystem", False), ("remoteStore", "https://s3.cern.ch/swift/v1/alibuild-repo")]),
7070
((), "build zlib --architecture ubuntu1804_x86-64" , [("noSystem", False), ("preferSystem", False), ("remoteStore", "")]),
7171
((), "build zlib -a slc7_x86-64 --docker-image alisw/slc7-builder" , [("docker", True), ("dockerImage", "alisw/slc7-builder")]),
7272
((), "build zlib -a slc7_x86-64 --docker" , [("docker", True), ("dockerImage", "alisw/slc7-builder")]),

0 commit comments

Comments
 (0)