[go: up one dir, main page]

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(codegen): preprocess AwsQuery error to shapeId in waiter errorType #6501

Merged
merged 4 commits into from
Sep 25, 2024

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]  

@@ -0,0 +1,106 @@
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

use the short header, not 2019

@kuhe kuhe changed the title fix(sdk-codegen): update errorType in waitable traits to use correct … fix(codegen): preprocess AwsQuery error to shapeId in waiter errorType Sep 25, 2024
@kuhe kuhe merged commit b92df20 into aws:main Sep 25, 2024
5 checks passed
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

waitUntilLoadBalancersDeleted never resolves
2 participants