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

Skip error if role no longer exists in instance profile deletion #1719

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/controller/iam/instanceprofile/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package instanceprofile
import (
"context"

"github.com/aws/aws-sdk-go/aws/awserr"
svcsdk "github.com/aws/aws-sdk-go/service/iam"
svcsdkapi "github.com/aws/aws-sdk-go/service/iam/iamiface"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -114,5 +115,12 @@ func (u *updater) preDelete(ctx context.Context, cr *svcapitypes.InstanceProfile
}

_, err := u.client.RemoveRoleFromInstanceProfileWithContext(ctx, input)
if awsErr, ok := err.(awserr.Error); ok {
// If the role no longer exists, then we have already deleted the role from the instance profile.
if awsErr.Code() == svcsdk.ErrCodeNoSuchEntityException {
return false, nil
}
}

return false, err
}