Skip to content

Commit 470b45f

Browse files
authored
Change S3 bucket sync logic based on region (#14)
Fix Issue aws-controllers-k8s/community#800
1 parent 8798f0a commit 470b45f

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

test/e2e/service_bootstrap.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import logging
1919
from time import sleep
2020
import json
21+
import time
22+
import subprocess
2123

2224
from acktest import resources
2325
from acktest.aws.identity import get_region, get_account_id
@@ -109,7 +111,30 @@ def create_data_bucket() -> str:
109111

110112
source_bucket = s3_resource.Bucket(SAGEMAKER_SOURCE_DATA_BUCKET)
111113
destination_bucket = s3_resource.Bucket(bucket_name)
112-
duplicate_bucket_contents(source_bucket, destination_bucket)
114+
temp_dir = "/tmp/ack_s3_data"
115+
# awscli is not installed in test-infra container hence use boto3 to copy in us-west-2
116+
if region == "us-west-2":
117+
duplicate_bucket_contents(source_bucket, destination_bucket)
118+
# above method does an async copy
119+
# TODO: find a way to remove random wait
120+
sleep(180)
121+
else:
122+
# workaround to copy if buckets are across regions
123+
# TODO: check if there is a better way and merge to test-infra
124+
subprocess.call(["mkdir", f"{temp_dir}"])
125+
subprocess.call(
126+
[
127+
"aws",
128+
"s3",
129+
"sync",
130+
f"s3://{SAGEMAKER_SOURCE_DATA_BUCKET}",
131+
f"./{temp_dir}/",
132+
"--quiet",
133+
]
134+
)
135+
subprocess.call(
136+
["aws", "s3", "sync", f"./{temp_dir}/", f"s3://{bucket_name}", "--quiet"]
137+
)
113138

114139
logging.info(f"Synced data bucket")
115140

0 commit comments

Comments
 (0)