Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public final class RemoteOptions extends OptionsBase {
)
public String s3CacheBucket;

@Option(
name = "s3_full_control_userid",
defaultValue = "null",
category = "remote",
help = "An AWS canonical user id for a user who should have full control over uploaded objects"
)
public String s3FullControlUserId;

@Option(name = "remote_fallback_strategy",
allowMultiple = true,
converter = AssignmentConverter.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@ThreadSafe
public final class S3ActionCache2 {
private final String bucketName;
private final String s3userId;
private final boolean debug;

private static volatile int numConsecutiveErrors;
Expand All @@ -57,6 +58,7 @@ public final class S3ActionCache2 {
*/
public S3ActionCache2(RemoteOptions options) {
this.bucketName = options.s3CacheBucket;
this.s3userId = options.s3FullControlUserId;
this.debug = options.remoteCacheDebug;
}

Expand Down Expand Up @@ -205,6 +207,13 @@ private void putObject(String key, PutObjectRequest object) {

long t0 = System.currentTimeMillis();
try {
if (s3userId != null) {
Grantee grantee = new CanonicalGrantee(s3userId);
AccessControlList acl = new AccessControlList();
acl.grantPermission(grantee, Permission.FullControl);
object = object.withAccessControlList(acl);
}

client.putObject(object);
if (debug) {
System.err.println("S3 Cache Upload: key:" + key + " (" + (System.currentTimeMillis() - t0) + "ms)");
Expand Down