Skip to content

Commit

Permalink
Fix WAL entries persisting when gcp project no longer exists (#104) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Voswinkel authored Jan 21, 2021
1 parent 00739c6 commit 3a6d6d2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions plugin/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ func (b *backend) serviceAccountPolicyRollback(ctx context.Context, req *logical

p, err := r.GetIamPolicy(ctx, apiHandle)
if err != nil {
if isGoogleAccountNotFoundErr(err) || isGoogleAccountUnauthorizedErr(err) {
return nil
}
return err
}

Expand All @@ -222,8 +225,10 @@ func (b *backend) deleteServiceAccount(ctx context.Context, iamAdmin *iam.Servic
}

_, err := iamAdmin.Projects.ServiceAccounts.Delete(account.ResourceName()).Do()
if err != nil && (!isGoogleAccountNotFoundErr(err) || !isGoogleAccountUnauthorizedErr(err)) {
return errwrap.Wrapf("unable to delete service account: {{err}}", err)
if err != nil {
if !isGoogleAccountNotFoundErr(err) && !isGoogleAccountUnauthorizedErr(err) {
return errwrap.Wrapf("unable to delete service account: {{err}}", err)
}
}
return nil
}
Expand Down Expand Up @@ -297,11 +302,13 @@ func isGoogleApiErrorWithCodes(err error, validErrCodes ...int) bool {
if err == nil {
return false
}
gErr, ok := err.(*googleapi.Error)
ok := errwrap.ContainsType(err, new(googleapi.Error))
if !ok {
return false
}

gErr := errwrap.GetType(err, new(googleapi.Error)).(*googleapi.Error)

for _, code := range validErrCodes {
if gErr.Code == code {
return true
Expand Down

0 comments on commit 3a6d6d2

Please sign in to comment.