Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changes/next-release/enhancement-Migration-87248.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "enhancement",
"category": "Migration",
"description": "Added support to upgrade debug mode for detecting breaking change introduced in AWS CLI v2: in v2, Cyclic Redundancy Check 64 (CRC64NVME) is used by default for ``aws s3`` commands that upload a file to S3, but Cyclic Redundancy Check 32 (CRC32) is used instead in v1. To use upgrade debug mode, specify the ``--v2-debug`` global parameter on a command."
}
18 changes: 18 additions & 0 deletions awscli/customizations/s3/subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,24 @@ def run(self):
'#cliv2-migration-s3-copy-metadata.\n\n',
out_file=sys.stderr
)
elif (
operation_name == 'upload'
and self.parameters.get('checksum_algorithm') is None
):
uni_print(
'\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for '
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: From the work on standardized error output, shouldn't warnings be prefixed with aws: [WARNING]?

'`aws s3` commands that upload a file to an S3 bucket, '
'Cyclic Redundancy Check 64 (CRC64NVME) will be used to '
'compute object checksums by default and include it in '
Comment thread
aemous marked this conversation as resolved.
Outdated
'the request. This is different from v1 behavior, where '
'Cyclic Redundancy Check 32 (CRC32) checksums will '
'instead be used. For guidance on retaining v1 behavior '
Comment thread
aemous marked this conversation as resolved.
Outdated
'in AWS CLI v2, or for more details, see '
'https://docs.aws.amazon.com/cli/latest/userguide/'
'cliv2-migration-changes.html'
'#cliv2-migration-checksums.\n\n',
out_file=sys.stderr
)

fgen_kwargs = {
'client': self._source_client, 'operation_name': operation_name,
Expand Down
27 changes: 27 additions & 0 deletions tests/functional/s3/test_cp_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,33 @@ def test_download_with_checksum_mode_crc32c(self):
self.assertEqual(self.operations_called[1][0].name, 'GetObject')
self.assertEqual(self.operations_called[1][1]['ChecksumMode'], 'ENABLED')

def test_upload_with_no_checksum_param_v2_debug(self):
full_path = self.files.create_file('foo.txt', 'contents')
cmdline = f'{self.prefix} {full_path} s3://bucket/key.txt --v2-debug'
_, stderr, _ = self.run_cmd(cmdline, expected_rc=0)
self.assertIn(
'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` '
'commands that upload a file to an S3 bucket, Cyclic Redundancy '
'Check 64 (CRC64NVME) will be used to compute object checksums by '
'default and include it in the request.',
stderr
)

def test_upload_with_crc32_checksum_v2_debug(self):
full_path = self.files.create_file('foo.txt', 'contents')
cmdline = (
f'{self.prefix} {full_path} s3://bucket/key.txt '
f'--checksum-algorithm CRC32 --v2-debug'
)
_, stderr, _ = self.run_cmd(cmdline, expected_rc=0)
self.assertNotIn(
'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` '
'commands that upload a file to an S3 bucket, Cyclic Redundancy '
'Check 64 (CRC64NVME) will be used to compute object checksums by '
'default and include it in the request.',
stderr
)


class TestStreamingCPCommand(BaseAWSCommandParamsTest):
def test_streaming_upload(self):
Expand Down
27 changes: 27 additions & 0 deletions tests/functional/s3/test_mv_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,33 @@ def test_download_with_checksum_mode_crc32(self):
self.assertEqual(self.operations_called[1][0].name, 'GetObject')
self.assertEqual(self.operations_called[1][1]['ChecksumMode'], 'ENABLED')

def test_upload_with_no_checksum_param_v2_debug(self):
full_path = self.files.create_file('foo.txt', 'contents')
cmdline = f'{self.prefix} {full_path} s3://bucket/key.txt --v2-debug'
_, stderr, _ = self.run_cmd(cmdline, expected_rc=0)
self.assertIn(
'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` '
'commands that upload a file to an S3 bucket, Cyclic Redundancy '
'Check 64 (CRC64NVME) will be used to compute object checksums by '
'default and include it in the request.',
stderr
)

def test_upload_with_crc32_checksum_v2_debug(self):
full_path = self.files.create_file('foo.txt', 'contents')
cmdline = (
f'{self.prefix} {full_path} s3://bucket/key.txt '
f'--checksum-algorithm CRC32 --v2-debug'
)
_, stderr, _ = self.run_cmd(cmdline, expected_rc=0)
self.assertNotIn(
'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` '
'commands that upload a file to an S3 bucket, Cyclic Redundancy '
'Check 64 (CRC64NVME) will be used to compute object checksums by '
'default and include it in the request.',
stderr
)


class TestMvCommandWithValidateSameS3Paths(BaseS3TransferCommandTest):

Expand Down