Closed ConnorJC3 closed 1 month ago
This PR does not change the code coverage
/approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: AndrewSirenko
The full list of commands accepted by this bot can be found here.
The pull request process is described here
Is this a bug fix or adding new feature?
Bug fix
What is this PR about? / Why do we need it?
In
WaitForAttachmentState
, we bail to callingAttachVolume
and immediately returning an error if the volume was reported as attached byDescribeInstances
(i.e. ifalreadyAssigned
is true), but the volume returns a state other thanattached
. This check exists to guard against the case whereDescribeInstances
is incorrect, bailing early allows us to get the attachment moving and avoid sitting in an infinite loop until a timeout occurs.However, this is incorrect - we should only perform this action if the volume is
detached
, not all states other thanattached
. This is for two reasons:AttachVolume
call when the volume is in a state other thandetached
will almost always fail.DescribeInstances
but still report asattaching
viaDescribeVolumes
for a short period of time. In this case, we repeatedly error out at the earliest possible opportunity, preventingWaitForAttachmentState
's exponential backoff from working and peppering the AWS API with spuriousAttachVolume
calls.What testing is done?
Added new unit test. Note that although depending on the test name is a horrible practice we should remove from this test, I have not spent the significant effort that would be required in this small PR to fix it.