Skip to content

Commit

Permalink
Merge pull request openshift#2056 from csrwng/gcp_lb_destroy_fix
Browse files Browse the repository at this point in the history
 [gcp] pkg/destroy: handle deletion of lb related resources
  • Loading branch information
openshift-merge-robot authored Jul 25, 2019
2 parents 900a921 + 1dfc18b commit 94495d9
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 46 deletions.
26 changes: 20 additions & 6 deletions pkg/destroy/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
gcpconfig "github.com/openshift/installer/pkg/asset/installconfig/gcp"
"github.com/openshift/installer/pkg/destroy/providers"
"github.com/openshift/installer/pkg/types"
gcptypes "github.com/openshift/installer/pkg/types/gcp"
"github.com/openshift/installer/pkg/version"
)

Expand All @@ -44,19 +45,24 @@ type ClusterUninstaller struct {
dnsSvc *dns.Service
storageSvc *storage.Service

// cloudControllerUID is the cluster ID used by the cluster's cloud controller
// to generate load balancer related resources. It can be obtained either
// from metadata or by inferring it from existing cluster resources.
cloudControllerUID string

requestIDTracker
pendingItemTracker
}

// New returns an AWS destroyer from ClusterMetadata.
func New(logger logrus.FieldLogger, metadata *types.ClusterMetadata) (providers.Destroyer, error) {
return &ClusterUninstaller{
Logger: logger,
Region: metadata.ClusterPlatformMetadata.GCP.Region,
ProjectID: metadata.ClusterPlatformMetadata.GCP.ProjectID,
ClusterID: metadata.InfraID,
Context: context.Background(),

Logger: logger,
Region: metadata.ClusterPlatformMetadata.GCP.Region,
ProjectID: metadata.ClusterPlatformMetadata.GCP.ProjectID,
ClusterID: metadata.InfraID,
Context: context.Background(),
cloudControllerUID: gcptypes.CloudControllerUID(metadata.InfraID),
requestIDTracker: newRequestIDTracker(),
pendingItemTracker: newPendingItemTracker(),
}, nil
Expand Down Expand Up @@ -157,6 +163,14 @@ func isNoOp(err error) bool {
return ok && (ae.Code == http.StatusNotFound || ae.Code == http.StatusNotModified)
}

func isNotFound(err error) bool {
if err == nil {
return false
}
ae, ok := err.(*googleapi.Error)
return ok && ae.Code == http.StatusNotFound
}

// aggregateError is a utility function that takes a slice of errors and an
// optional pending argument, and returns an error or nil
func aggregateError(errs []error, pending ...int) error {
Expand Down
Loading

0 comments on commit 94495d9

Please sign in to comment.