Skip to content

Commit

Permalink
Merge pull request #3941 from SujanaN08/OCPBUG-187
Browse files Browse the repository at this point in the history
Bug 1846125: deleting vsphere cluster tag after deleting the attached resources
  • Loading branch information
openshift-merge-robot committed Jul 30, 2020
2 parents e1a76ab + 2118983 commit 1e8dec8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/destroy/vsphere/vsphere.go
Expand Up @@ -130,6 +130,15 @@ func getAttachedObjectsOnTag(ctx context.Context, client *rest.Client, tagName s
return attached, nil
}

func deleteTag(ctx context.Context, client *rest.Client, tagID string) error {
tagManager := tags.NewManager(client)
tag, err := tagManager.GetTag(ctx, tagID)
if err == nil {
err = tagManager.DeleteTag(ctx, tag)
}
return err
}

// Run is the entrypoint to start the uninstall process.
func (o *ClusterUninstaller) Run() error {
var folderList []types.ManagedObjectReference
Expand Down Expand Up @@ -192,5 +201,11 @@ func (o *ClusterUninstaller) Run() error {
return err
}

o.Logger.Debug("delete tag")
if err = deleteTag(context.TODO(), o.RestClient, o.InfraID); err != nil {
o.Logger.Errorln(err)
return err
}

return nil
}

0 comments on commit 1e8dec8

Please sign in to comment.