Skip to content

IMDS returns SdkClientException on 4XX errors, but reading autoscaling lifecycle state can return 404. #5786

Open
@benjumanji

Description

@benjumanji

Describe the feature

IMDS client should return SdkServiceException when an http request is returned from the service. It's use of SdkClientException doesn't match the description in the docs: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/handling-exceptions.html#sdkclientexception, to wit:

An SdkClientException is generally more severe than an SdkServiceException, and indicates a major problem that is preventing the client from making service calls to AWS services

A request that recieves a response cannot be a client exception. It made the call, the service rejected it.

Use Case

IMDS client returns SdkClientExceptions unconditionally on 4XX errors (

throw SdkClientException.builder().message(responseContent).build();
) but when an instance has been up for some length of time then reading the autoscaling lifecycle state can fail with a 404, this is not a client error and is retryable. We don't want to log these, but the status code isn't accessible to us because the client threw away that information.

Proposed Solution

Return an SdkServiceException any time there is an actual service response.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS Java SDK version used

2

JDK version used

17

Operating System and version

linux 6.11 (nixos)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions