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

pull retry loop forward to cover everything from resolving auth scheme onward #2966

Merged
merged 3 commits into from
Jan 17, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
419 changes: 419 additions & 0 deletions .changelog/70097b97ec1146ffb87105b3aa6ad390.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public void writeAdditionalFiles(
if (supportsComputeInputChecksumsWorkflow) {
goDelegator.useShapeWriter(service, writer -> {
generateInputComputedChecksumMetadataHelpers(writer, model, symbolProvider, service);
writePackageLevelAddInputChecksumMiddleware(writer);
});
}

Expand Down Expand Up @@ -257,16 +258,14 @@ private void writeInputMiddlewareHelper(
writer.openBlock("func $L(stack *middleware.Stack, options Options) error {", "}",
getAddInputMiddlewareFuncName(operationName), () -> {
writer.write("""
return $T(stack, $T{
return addInputChecksumMiddleware(stack, $T{
GetAlgorithm: $L,
RequireChecksum: $L,
RequestChecksumCalculation: options.RequestChecksumCalculation,
EnableTrailingChecksum: $L,
EnableComputeSHA256PayloadHash: true,
EnableDecodedContentLengthHeader: $L,
})""",
SymbolUtils.createValueSymbolBuilder("AddInputMiddleware",
AwsGoDependency.SERVICE_INTERNAL_CHECKSUM).build(),
SymbolUtils.createValueSymbolBuilder("InputMiddlewareOptions",
AwsGoDependency.SERVICE_INTERNAL_CHECKSUM).build(),
hasRequestAlgorithmMember ?
Expand All @@ -279,6 +278,48 @@ private void writeInputMiddlewareHelper(
writer.insertTrailingNewline();
}

// adapted (service/internal/checksum).AddInputMiddleware to give the service client control over its middleware stack,
// per #2507
private void writePackageLevelAddInputChecksumMiddleware(GoWriter writer) {
writer.addUseImports(SmithyGoDependency.SMITHY_MIDDLEWARE);
writer.addUseImports(AwsGoDependency.SERVICE_INTERNAL_CHECKSUM);
writer.write("""
func addInputChecksumMiddleware(stack *middleware.Stack, options internalChecksum.InputMiddlewareOptions) (err error) {
err = stack.Initialize.Add(&internalChecksum.SetupInputContext{
GetAlgorithm: options.GetAlgorithm,
RequireChecksum: options.RequireChecksum,
RequestChecksumCalculation: options.RequestChecksumCalculation,
}, middleware.Before)
if err != nil {
return err
}

stack.Build.Remove("ContentChecksum")
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we had this in place since before you made this change, but is it because ContentChecksum is the older way of doing checksums?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, ContentChecksum is the old MD5, which the recent changes to S3 object integrity effectively removes.


inputChecksum := &internalChecksum.ComputeInputPayloadChecksum{
EnableTrailingChecksum: options.EnableTrailingChecksum,
EnableComputePayloadHash: options.EnableComputeSHA256PayloadHash,
EnableDecodedContentLengthHeader: options.EnableDecodedContentLengthHeader,
}
if err := stack.Finalize.Insert(inputChecksum, "ResolveEndpointV2", middleware.After); err != nil {
return err
}

if options.EnableTrailingChecksum {
trailerMiddleware := &internalChecksum.AddInputChecksumTrailer{
EnableTrailingChecksum: inputChecksum.EnableTrailingChecksum,
EnableComputePayloadHash: inputChecksum.EnableComputePayloadHash,
EnableDecodedContentLengthHeader: inputChecksum.EnableDecodedContentLengthHeader,
}
if err := stack.Finalize.Insert(trailerMiddleware, inputChecksum.ID(), middleware.After); err != nil {
return err
}
}

return nil
}""");
}

private void writeOutputMiddlewareHelper(
GoWriter writer,
Model model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func addRetry(stack *middleware.Stack, o Options) error {
m.LogAttempts = o.ClientLogMode.IsRetries()
m.OperationMeter = o.MeterProvider.Meter($S)
})
if err := stack.Finalize.Insert(attempt, "Signing", middleware.Before); err != nil {
if err := stack.Finalize.Insert(attempt, "ResolveAuthScheme", middleware.Before); err != nil {
return err
}
if err := stack.Finalize.Insert(&retry.MetricsHeader{}, attempt.ID(), middleware.After); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/protocoltest/awsrestjson/api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ AllQueryStringTypes
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ ConstantAndVariableQueryString
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ ConstantQueryString
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ ContentTypeParameters
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ DatetimeOffsets
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ DocumentType
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ DocumentTypeAsMapValue
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ DocumentTypeAsPayload
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ EmptyInputAndEmptyOutput
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ EndpointOperation
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
EndpointHostPrefix
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ EndpointWithHostLabelOperation
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
EndpointHostPrefix
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ FractionalSeconds
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ GreetingWithErrors
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ HostWithPathOperation
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ HttpChecksumRequired
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ HttpEnumPayload
RecursionDetection
spanBuildRequestEnd
Finalize stack step
spanRetryLoop
Retry
RetryMetricsHeader
ResolveAuthScheme
GetIdentity
ResolveEndpointV2
disableHTTPS
ComputePayloadHash
spanRetryLoop
Retry
RetryMetricsHeader
setLegacyContextSigningOptions
Signing
Deserialize stack step
Expand Down
Loading
Loading