Skip to content

Commit

Permalink
Parse resource from backup tarball directly rather than resolving it …
Browse files Browse the repository at this point in the history
…via discovery service to avoid #4009

If the resource is a CR and the CRD is removed, the resource cannot be fully resolved via discovery and the backup cannot be deleted anymore. This commit parses the resource from backup tarball directly to avoid this

Fixes #4009

Signed-off-by: Wenkai Yin(尹文开) <[email protected]>
  • Loading branch information
ywk253100 committed Dec 21, 2021
1 parent d627362 commit 52cb7a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/4398-ywk253100
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the issue that the backup cannot be deleted after the application uninstalled
11 changes: 1 addition & 10 deletions internal/delete/delete_item_action_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,8 @@ func InvokeDeleteActions(ctx *Context) error {

processdResources := sets.NewString()

ctx.Log.Debugf("Trying to reconcile resource names with Kube API server.")
// Transform resource names based on what's canonical in the API server.
for resource := range backupResources {
gvr, _, err := ctx.DiscoveryHelper.ResourceFor(schema.ParseGroupResource(resource).WithVersion(""))
if err != nil {
return errors.Wrapf(err, "failed to resolve resource into complete group/version/resource: %v", resource)
}

groupResource := gvr.GroupResource()
groupResource := schema.ParseGroupResource(resource)

// We've already seen this group/resource, so don't process it again.
if processdResources.Has(groupResource.String()) {
Expand All @@ -92,8 +85,6 @@ func InvokeDeleteActions(ctx *Context) error {
// Get a list of all items that exist for this resource
resourceList := backupResources[groupResource.String()]
if resourceList == nil {
// After canonicalization from the API server, the resources may not exist in the tarball
// Skip them if that's the case.
continue
}

Expand Down

0 comments on commit 52cb7a7

Please sign in to comment.