Fix silent failure in uploadExportFilesToS3 #176
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: N/A
Description of changes:
The recent (currently unreleased) upgrade to AWS SDK v2 introduced a silent failure in the upload of export files to S3. With the new S3 API, there is very little customization that can be done directly on an
UploadDirectoryRequest.Builder
, instead, many configurations such as adding tags must be done via anUploadFileRequestTransformer
, which allows for mutation of the individual file upload requests which ultimately get generated.The bug here is that by attempting to directly update
putObjectRequest()
on theUploadFileRequest.Builder
, the effect is to null all existing non-overridden parameters in thePutObjectRequest
. This includes essential parameters such asbucket
andkey
. The end result is an upload which is guaranteed to fail. The solution here is to clone the originalPutObjectRequest
and create a new builder from it, which then allows customization of the necessary parameters and attachment back to the originalUploadFileRequest
builder.The original code here used to fail silently as a
DirectoryUpload
will not fail exceptionally if one or more (or all) underlying FileUploadRequests fail. The individual file upload failures were buried inside theDirectoryUpload
and there was no indication of any issue other than the files ultimately being missing in S3. This PR also includes a change to log an error for each failed file upload to give proper visibility.Testing:
Verified successful file upload and correct tagging for all code paths which upload files to S3 (Full directory upload, completion file upload, training config file upload for both V1 and V2 ML profiles, and GcLogFile for failed exports).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.