Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CopyObject]: fix hardcoded URL, re-enable CopyObject support and tests #284

Merged
merged 12 commits into from
Jun 1, 2023

Conversation

grrtrr
Copy link
Contributor

@grrtrr grrtrr commented May 10, 2023

This fixes the hardcoded URL for the initial HeadObject call used by the CopyObject method. Also re-enable the tests that were accordingly disabled in #246.

Resolves #282.

With a suitable bucket structure (using us-east-1), tests are now passing:

> ctest -R copy
Test project /home/grenker/crt/aws-c-s3.BUILD/aws-c-s3/build
    Start 168: test_s3_copy_small_object
1/7 Test #168: test_s3_copy_small_object ..........................   Passed    1.12 sec
    Start 169: test_s3_copy_small_object_special_char
2/7 Test #169: test_s3_copy_small_object_special_char .............   Passed    1.12 sec
    Start 170: test_s3_multipart_copy_large_object_special_char
3/7 Test #170: test_s3_multipart_copy_large_object_special_char ...   Passed    7.13 sec
    Start 171: test_s3_multipart_copy_large_object
4/7 Test #171: test_s3_multipart_copy_large_object ................   Passed    4.12 sec
    Start 172: test_s3_copy_object_invalid_source_key
5/7 Test #172: test_s3_copy_object_invalid_source_key .............   Passed    1.12 sec
    Start 173: test_s3_copy_source_prefixed_by_slash
6/7 Test #173: test_s3_copy_source_prefixed_by_slash ..............   Passed    1.12 sec
    Start 174: test_s3_copy_source_prefixed_by_slash_multipart
7/7 Test #174: test_s3_copy_source_prefixed_by_slash_multipart ....   Passed    4.12 sec

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This fixes the hardcoded URL for the initial HeadObject call used by the CopyObject method.
Also re-enable the tests that were accordingly disabled in awslabs#246.
@grrtrr grrtrr changed the title [CopyObject]: fix hardcoded URL, re-enable tests [CopyObject]: fix hardcoded URL, re-enable CopyObject support and tests May 10, 2023
grrtrr added a commit to grrtrr/aws-sdk-cpp that referenced this pull request May 11, 2023
Provide `CopyObject` support based on awslabs/aws-c-s3#284

In contrast to the existing `CopyObject` function, objects larger than 5GB are
supported, and multipart copies are automatically handled in parallel.
struct aws_http_message *base_message) {
AWS_PRECONDITION(allocator);
if (source_bucket.len == 0 || request_path.len == 0) {
AWS_LOGF_ERROR(AWS_LS_S3_GENERAL, "CopyRequest x-amz-copy-source header not in bucket/key format");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: maybe printout the wrong value to simplify the debug, if not sensitive?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user uses arn as source, it may still have / in it and get through this check, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added printout.
ARNs only support / in the resource section meaning that bucket name would have a bunch of non-dns compliant characters and request will fail. arguable, but for simplicity sake i think its fine until we can fix support for copy to work in all cases


struct aws_http_message *message = NULL;
if (aws_byte_buf_init_copy_from_cursor(&head_object_host_header, allocator, source_bucket)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: we could initialize the buffer once with the proper length to avoid further allocation when we do append_dynamic later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could, but code looks slightly uglier since we need to break init into init + append. Personally, i prefer this variant slightly more even if its a little less efficient

source/s3_request_messages.c Outdated Show resolved Hide resolved
++num_parts;
}
aws_s3_calculate_optimal_mpu_part_size_and_num_parts(
copy_object->synced_data.content_length, s_min_copy_part_size, max_part_size, &part_size, &num_parts);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever mention in the public doc that there is a min_copy_part_size? It will override the part size set from user, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we never documented it and it was internal constant ever since we introduced this class.
for copy it needs to be quite a bit bigger than client part size and we probably want to expose separate config for it.
added todo

@DmitriyMusatkin DmitriyMusatkin merged commit 21b0a10 into awslabs:main Jun 1, 2023
sbiscigl pushed a commit to aws/aws-sdk-cpp that referenced this pull request Jul 5, 2023
Provide `CopyObject` support based on awslabs/aws-c-s3#284

In contrast to the existing `CopyObject` function, objects larger than 5GB are
supported, and multipart copies are automatically handled in parallel.
sbiscigl pushed a commit to aws/aws-sdk-cpp that referenced this pull request Jul 6, 2023
Provide `CopyObject` support based on awslabs/aws-c-s3#284

In contrast to the existing `CopyObject` function, objects larger than 5GB are
supported, and multipart copies are automatically handled in parallel.
sbiscigl pushed a commit to aws/aws-sdk-cpp that referenced this pull request Jul 6, 2023
Provide `CopyObject` support based on awslabs/aws-c-s3#284

In contrast to the existing `CopyObject` function, objects larger than 5GB are
supported, and multipart copies are automatically handled in parallel.
jmklix pushed a commit to aws/aws-sdk-cpp that referenced this pull request Aug 11, 2023
Provide `CopyObject` support based on awslabs/aws-c-s3#284

In contrast to the existing `CopyObject` function, objects larger than 5GB are
supported, and multipart copies are automatically handled in parallel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CopyObject]: please re-enable client support and tests for CopyObject
3 participants