Skip to content

Commit

Permalink
Add check for 403 during rollback to prevent spam (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Voswinkel committed Sep 15, 2020
1 parent 4005bee commit 30af289
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugin/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (b *backend) deleteServiceAccount(ctx context.Context, iamAdmin *iam.Servic
}

_, err := iamAdmin.Projects.ServiceAccounts.Delete(account.ResourceName()).Do()
if err != nil && !isGoogleAccountNotFoundErr(err) {
if err != nil && (!isGoogleAccountNotFoundErr(err) || !isGoogleAccountUnauthorizedErr(err)) {
return errwrap.Wrapf("unable to delete service account: {{err}}", err)
}
return nil
Expand Down Expand Up @@ -285,6 +285,10 @@ func isGoogleAccountNotFoundErr(err error) bool {
return isGoogleApiErrorWithCodes(err, 404)
}

func isGoogleAccountUnauthorizedErr(err error) bool {
return isGoogleApiErrorWithCodes(err, 403)
}

func isGoogleAccountKeyNotFoundErr(err error) bool {
return isGoogleApiErrorWithCodes(err, 403, 404)
}
Expand Down

0 comments on commit 30af289

Please sign in to comment.