Check for 404 errors in GCP termination

This commit is contained in:
katexochen 2022-08-01 14:58:23 +02:00 committed by Paul Meyer
parent 9f599c3993
commit c954ec089f
6 changed files with 179 additions and 43 deletions

View file

@ -4,8 +4,10 @@ import (
"context"
"crypto/rand"
"encoding/json"
"errors"
"fmt"
"math/big"
"net/http"
compute "cloud.google.com/go/compute/apiv1"
admin "cloud.google.com/go/iam/admin/apiv1"
@ -15,6 +17,7 @@ import (
"github.com/edgelesssys/constellation/internal/state"
"go.uber.org/multierr"
"golang.org/x/oauth2/google"
"google.golang.org/api/googleapi"
)
// Client is a client for the Google Compute Engine.
@ -318,3 +321,11 @@ func closeAll(closers []closer) error {
}
return err
}
func isNotFoundError(err error) bool {
var gAPIErr *googleapi.Error
if !errors.As(err, &gAPIErr) {
return false
}
return gAPIErr.Code == http.StatusNotFound
}