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

fix(sdk-codegen): update errorType in waitable traits to use correct … #6501

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RanVaknin
Copy link
Contributor

Fixes: aws/aws-sdk#639

The SDK incorrectly uses the awsQuery error code as an error matcher for waiters.
This PR pre-processes the aws query API models and swaps the error matcher code with the corresponding shapeID.

End to end test

driver code:

import { ElasticLoadBalancingV2Client, DeleteLoadBalancerCommand, waitUntilLoadBalancersDeleted } from "@aws-sdk/client-elastic-load-balancing-v2";

const client = new ElasticLoadBalancingV2Client({
  region: "us-east-1",
});

async function deleteAndWaitForLoadBalancer(loadBalancerArn) {
  try {
    await client.send(new DeleteLoadBalancerCommand({ LoadBalancerArn: loadBalancerArn }));
    console.log("Load balancer deletion initiated");

    await waitUntilLoadBalancersDeleted(
      { 
        client,
        maxWaitTime: 600,
        minDelay: 15,
        maxDelay: 120
      },
      { LoadBalancerArns: [loadBalancerArn] }
    );
    console.log("Load balancer deleted successfully");
  } catch (err) {
    console.error("Error during load balancer deletion or waiting:", err);
  }
}


const loadBalancerArn = "arn:aws:elasticloadbalancing:us-east-1:REDACTED:loadbalancer/app/foo-123456/REDACTED";

deleteAndWaitForLoadBalancer(loadBalancerArn);

after changes waiter exits successfully

{
  clientName: 'ElasticLoadBalancingV2Client',
  commandName: 'DeleteLoadBalancerCommand',
  input: {
    LoadBalancerArn: 'arn:aws:elasticloadbalancing:us-east-1:REDACTED:loadbalancer/app/foo-123456/REDACTED'
  },
  output: {},
  metadata: {
    httpStatusCode: 200,
    requestId: 'REDACTED',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}
Load balancer deletion initiated
{
  clientName: 'ElasticLoadBalancingV2Client',
  commandName: 'DescribeLoadBalancersCommand',
  input: {
    LoadBalancerArns: [
      'arn:aws:elasticloadbalancing:us-east-1:REDACTED:loadbalancer/app/foo-123456/REDACTED'
    ]
  },
  error: LoadBalancerNotFoundException: One or more load balancers not found
      at de_LoadBalancerNotFoundExceptionRes (/local/home/rvaknin/workplace/ran/aws-sdk-js-v3/clients/client-elastic-load-balancing-v2/dist-cjs/index.js:2837:21)
      at de_CommandError (/local/home/rvaknin/workplace/ran/aws-sdk-js-v3/clients/client-elastic-load-balancing-v2/dist-cjs/index.js:2488:19)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async /local/home/rvaknin/workplace/ran/aws-sdk-js-v3/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
      at async /local/home/rvaknin/workplace/ran/aws-sdk-js-v3/node_modules/@smithy/core/dist-cjs/index.js:165:18
      at async /local/home/rvaknin/workplace/ran/aws-sdk-js-v3/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
      at async /local/home/rvaknin/workplace/ran/aws-sdk-js-v3/packages/middleware-logger/dist-cjs/index.js:34:22
      at async checkState (/local/home/rvaknin/workplace/ran/aws-sdk-js-v3/clients/client-elastic-load-balancing-v2/dist-cjs/index.js:7797:20)
      at async runPolling (/local/home/rvaknin/workplace/ran/aws-sdk-js-v3/node_modules/@smithy/util-waiter/dist-cjs/index.js:83:29)
      at async waitUntilLoadBalancersDeleted (/local/home/rvaknin/workplace/ran/aws-sdk-js-v3/clients/client-elastic-load-balancing-v2/dist-cjs/index.js:7830:18) {
    '$fault': 'client',
    '$metadata': {
      httpStatusCode: 400,
      requestId: 'REDACTED',
      extendedRequestId: undefined,
      cfId: undefined,
      attempts: 1,
      totalRetryDelay: 0
    },
    Error: {
      Type: 'Sender',
      Code: 'LoadBalancerNotFound',
      Message: 'One or more load balancers not found',
      message: 'One or more load balancers not found'
    },
    RequestId: 'REDACTED',
    xmlns: 'http://elasticloadbalancing.amazonaws.com/doc/2015-12-01/'
  },
  metadata: {
    httpStatusCode: 400,
    requestId: 'REDACTED',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}
Load balancer deleted successfully
(24-09-20 17:34:49) <0> [~/workplace/ran/aws-sdk-js-v3/workspace]  

@RanVaknin RanVaknin requested a review from a team as a code owner September 21, 2024 06:56
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.

waitUntilLoadBalancersDeleted never resolves
1 participant