Skip to content

Commit 02e4f6c

Browse files
authored
Fix bug where AWS IAM policy deletion could lead to an unhandled "NoSuchEntityException" (#593)
1 parent 18009db commit 02e4f6c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/shared/awsagent/policies.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ func (a *Agent) deleteOldestPolicyVersion(ctx context.Context, policy *types.Pol
348348
VersionId: oldest.VersionId,
349349
}, AWSBackoffRetryerOptions)
350350

351+
if err != nil && errors.As(err, &types.NoSuchEntityException{}) {
352+
logrus.WithFields(logrus.Fields{
353+
"policy": policy.PolicyName,
354+
"version": *oldest.VersionId,
355+
"error": err,
356+
}).Debug("NoSuchEntityException while deleting policy version, it might have been deleted already")
357+
return nil
358+
}
359+
351360
if err != nil {
352361
return errors.Wrap(err)
353362
}

0 commit comments

Comments
 (0)