Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: CORS-3856: Add check for asset before destroy #9386

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/destroy/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"

"github.com/openshift/installer/cmd/openshift-install/command"
"github.com/openshift/installer/pkg/asset/installconfig"
azuresession "github.com/openshift/installer/pkg/asset/installconfig/azure"
assetstore "github.com/openshift/installer/pkg/asset/store"
"github.com/openshift/installer/pkg/destroy/providers"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/azure"
Expand Down Expand Up @@ -127,6 +130,24 @@ func New(logger logrus.FieldLogger, metadata *types.ClusterMetadata) (providers.
return nil, err
}

assetStore, err := assetstore.NewStore(command.RootOpts.Dir)
if err != nil {
return nil, fmt.Errorf("failed to create asset store: %w", err)
}

// Ensure that Platform Provision Check asset exists before running destroy cluster.
// PlatformProvisionCheck asset only exists if the create cluster command was used
// for creation of cluster. In the cases like UPI installs, we have no idea what's
// in the resource group and blind deletion of it would cause unintended issues.
// More details: https://issues.redhat.com/browse/CORS-3856
platformProvisionCheck := &installconfig.PlatformProvisionCheck{}
if assetState, err := assetStore.Load(platformProvisionCheck); err != nil {
return nil, fmt.Errorf("failed to get platform provision check asset: %w", err)
} else if assetState == nil {
// Do nothing.
return nil, nil
}

return &ClusterUninstaller{
Session: session,
InfraID: metadata.InfraID,
Expand Down