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 authored Aug 28, 2020
1 parent c25987d commit 42e2f83
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 42e2f83

Please sign in to comment.