Skip to content

Commit

Permalink
gc
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Feb 3, 2025
1 parent 668bc0a commit c64b683
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions pkg/services/gc/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,29 +232,19 @@ func (gc *GC) delete(
}

func (gc *GC) discoverResources() ([]*metav1.APIResourceList, error) {
// Notes:
// - We rely on the discovery API to retrieve all the resources GVK,
// that results in an unbounded set that can impact garbage collection
// latency when scaling up.
// - Swallow group discovery errors, e.g., Knative serving exposes
// an aggregated API for custom.metrics.k8s.io that requires special
// authentication scheme while discovering preferred resources.

namespacedItems, err := gc.client.Discovery().ServerPreferredNamespacedResources()
// We rely on the discovery API to retrieve all the resources GVK, that
// results in an unbounded set that can impact garbage collection latency
// when scaling up.
items, err := gc.client.Discovery().ServerPreferredResources()

// Swallow group discovery errors, e.g., Knative serving exposes an
// aggregated API for custom.metrics.k8s.io that requires special
// authentication scheme while discovering preferred resources.
if err != nil && !discovery.IsGroupDiscoveryFailedError(err) {
return nil, fmt.Errorf("failure retrieving supported namespaced resources: %w", err)
return nil, fmt.Errorf("failure retrieving supported resources: %w", err)
}

clusterItems, err := gc.client.Discovery().ServerPreferredResources()
if err != nil && !discovery.IsGroupDiscoveryFailedError(err) {
return nil, fmt.Errorf("failure retrieving supported cluster resources: %w", err)
}

res := make([]*metav1.APIResourceList, 0, len(namespacedItems)+len(clusterItems))
res = append(res, namespacedItems...)
res = append(res, clusterItems...)

return res, nil
return items, nil
}

func (gc *GC) computeDeletableTypes(
Expand Down

0 comments on commit c64b683

Please sign in to comment.