Skip to content

Commit

Permalink
UPSTREAM: <carry>: cluster aware garbage collector factory method
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti committed Oct 26, 2022
1 parent 5accbca commit 0526091
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/controller/garbagecollector/garbagecollector_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,40 @@ import (
"reflect"
"time"

"github.com/kcp-dev/logicalcluster/v2"

"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/discovery"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/metadata"
"k8s.io/client-go/tools/cache"
"k8s.io/controller-manager/pkg/informerfactory"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/controller/garbagecollector/metrics"
)

// NewClusterAwareGarbageCollector creates a new GarbageCollector for the provided logical cluster.
func NewClusterAwareGarbageCollector(
kubeClient clientset.Interface,
metadataClient metadata.Interface,
mapper meta.ResettableRESTMapper,
ignoredResources map[schema.GroupResource]struct{},
sharedInformers informerfactory.InformerFactory,
informersStarted <-chan struct{},
clusterName logicalcluster.Name,
) (*GarbageCollector, error) {
gc, err := NewGarbageCollector(kubeClient, metadataClient, mapper, ignoredResources, sharedInformers, informersStarted)
if err != nil {
return nil, err
}
gc.clusterName = clusterName
gc.dependencyGraphBuilder.clusterName = clusterName
return gc, nil
}

func (gc *GarbageCollector) ResyncMonitors(ctx context.Context, discoveryClient discovery.ServerResourcesInterface) {
oldResources := make(map[schema.GroupVersionResource]struct{})
func() {
Expand Down

0 comments on commit 0526091

Please sign in to comment.