Skip to content

Commit 52c732b

Browse files
committed
Remove S3LogStore.close return URL
This adds unnecessary complexity since it depends on the S3 server, so rely on the user to know how to get the URL
1 parent 83d0f28 commit 52c732b

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

repo2docker/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,6 @@ def start(self):
759759
finally:
760760
try:
761761
r = self._logstore.close()
762-
if r:
763-
self.log.info(f"Log path: {r}")
764762
except Exception as e:
765763
self.log.error("Failed to save log: {}".format(e))
766764

repo2docker/logstore.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
try:
99
import boto3
10-
from botocore import UNSIGNED
11-
from botocore.config import Config
1210

1311
S3_ENABLED = True
1412
except ImportError:
@@ -31,8 +29,7 @@ def write(self, s):
3129
pass
3230

3331
def close(self):
34-
"""Finish logging. Implementations may save or copy the log.
35-
May return a path to the saved log"""
32+
"""Finish logging. Implementations may save or copy the log."""
3633
pass
3734

3835

@@ -89,7 +86,9 @@ def close(self):
8986
# Empty log means image already exists so nothing was built
9087
return
9188
dest = f"{self.keyprefix}{self.logname}"
92-
self.log.debug(f"Uploading log to {self.endpoint} key:{self.bucket}/{dest}")
89+
self.log.info(
90+
f"Uploading log to {self.endpoint} bucket:{self.bucket} key:{dest}"
91+
)
9392
s3 = boto3.resource(
9493
"s3",
9594
config=boto3.session.Config(signature_version="s3v4"),
@@ -101,22 +100,3 @@ def close(self):
101100
ExtraArgs={"ContentType": "text/plain", "ACL": self.acl},
102101
)
103102
os.remove(self._logfile.name)
104-
return self._get_url()
105-
106-
def _get_url(self):
107-
# For simple S3 servers you can easily build the canonical URL.
108-
# For AWS S3 this can be more complicated as it depends on your region.
109-
# boto3 doesn't have a way to just get the public URL, so instead we create a pre-signed
110-
# URL but discard the parameters since the object is public.
111-
s3unsigned = boto3.client(
112-
"s3", config=Config(UNSIGNED), **self._s3_credentials()
113-
)
114-
link = s3unsigned.generate_presigned_url(
115-
"get_object",
116-
ExpiresIn=0,
117-
Params={
118-
"Bucket": self.bucket,
119-
"Key": f"{self.keyprefix}{self.logname}",
120-
},
121-
)
122-
return link.split("?", 1)[0]

0 commit comments

Comments
 (0)