package garbagecollector
import "k8s.io/kubernetes/pkg/controller/garbagecollector"
Index ¶
- Constants
- func DefaultIgnoredResources() map[schema.GroupResource]struct{}
- func GetDeletableResources(logger klog.Logger, discoveryClient discovery.ServerResourcesInterface) (map[schema.GroupVersionResource]struct{}, error)
- func NewDOTVertex(node *node) *dotVertex
- func NewDebugHandler(controller *GarbageCollector) http.Handler
- func NewMissingdotVertex(ownerRef metav1.OwnerReference) *dotVertex
- type GarbageCollector
- func NewComposedGarbageCollector( ctx context.Context, kubeClient clientset.Interface, metadataClient metadata.Interface, mapper meta.ResettableRESTMapper, graphBuilder *GraphBuilder, ) (*GarbageCollector, error)
- func NewGarbageCollector( ctx context.Context, kubeClient clientset.Interface, metadataClient metadata.Interface, mapper meta.ResettableRESTMapper, ignoredResources map[schema.GroupResource]struct{}, sharedInformers informerfactory.InformerFactory, informersStarted <-chan struct{}, ) (*GarbageCollector, error)
- func (gc *GarbageCollector) DebuggingHandler() http.Handler
- func (gc *GarbageCollector) GetDependencyGraphBuilder() *GraphBuilder
- func (gc *GarbageCollector) GraphHasUID(u types.UID) bool
- func (gc *GarbageCollector) IsSynced(logger klog.Logger) bool
- func (gc *GarbageCollector) Name() string
- func (gc *GarbageCollector) Run(ctx context.Context, workers int, initialSyncTimeout time.Duration)
- func (gc *GarbageCollector) Sync(ctx context.Context, discoveryClient discovery.ServerResourcesInterface, period time.Duration)
- type GraphBuilder
- func NewDependencyGraphBuilder( ctx context.Context, metadataClient metadata.Interface, mapper meta.ResettableRESTMapper, ignoredResources map[schema.GroupResource]struct{}, sharedInformers informerfactory.InformerFactory, informersStarted <-chan struct{}, ) *GraphBuilder
- func (gb *GraphBuilder) GetGraphResources() ( attemptToDelete workqueue.TypedRateLimitingInterface[*node], attemptToOrphan workqueue.TypedRateLimitingInterface[*node], absentOwnerCache *ReferenceCache, )
- func (gb *GraphBuilder) GetMonitor(ctx context.Context, resource schema.GroupVersionResource) (*Monitor, error)
- func (gb *GraphBuilder) IsResourceSynced(resource schema.GroupVersionResource) bool
- func (gb *GraphBuilder) IsSynced(logger klog.Logger) bool
- func (gb *GraphBuilder) Name() string
- func (gb *GraphBuilder) Run(ctx context.Context)
- type Monitor
- type ObjectMetaForFinalizersPatch
- type ObjectMetaForPatch
- type ReferenceCache
Constants ¶
ResourceResyncTime defines the resync period of the garbage collector's informers.
Functions ¶
func DefaultIgnoredResources ¶
func DefaultIgnoredResources() map[schema.GroupResource]struct{}
DefaultIgnoredResources returns the default set of resources that the garbage collector controller should ignore. This is exposed so downstream integrators can have access to the defaults, and add to them as necessary when constructing the controller.
func GetDeletableResources ¶
func GetDeletableResources(logger klog.Logger, discoveryClient discovery.ServerResourcesInterface) (map[schema.GroupVersionResource]struct{}, error)
GetDeletableResources returns all resources from discoveryClient that the garbage collector should recognize and work with. More specifically, all preferred resources which support the 'delete', 'list', and 'watch' verbs.
If an error was encountered fetching resources from the server, it is included as well, along with any resources that were successfully resolved.
All discovery errors are considered temporary. Upon encountering any error, GetDeletableResources will log and return any discovered resources it was able to process (which may be none).
func NewDOTVertex ¶
func NewDOTVertex(node *node) *dotVertex
NewDOTVertex creates a new dotVertex.
func NewDebugHandler ¶
func NewDebugHandler(controller *GarbageCollector) http.Handler
NewDebugHandler creates a new debugHTTPHandler.
func NewMissingdotVertex ¶
func NewMissingdotVertex(ownerRef metav1.OwnerReference) *dotVertex
NewMissingdotVertex creates a new dotVertex.
Types ¶
type GarbageCollector ¶
type GarbageCollector struct {
// contains filtered or unexported fields
}
GarbageCollector runs reflectors to watch for changes of managed API objects, funnels the results to a single-threaded dependencyGraphBuilder, which builds a graph caching the dependencies among objects. Triggered by the graph changes, the dependencyGraphBuilder enqueues objects that can potentially be garbage-collected to the `attemptToDelete` queue, and enqueues objects whose dependents need to be orphaned to the `attemptToOrphan` queue. The GarbageCollector has workers who consume these two queues, send requests to the API server to delete/update the objects accordingly. Note that having the dependencyGraphBuilder notify the garbage collector ensures that the garbage collector operates with a graph that is at least as up to date as the notification is sent.
func NewComposedGarbageCollector ¶
func NewComposedGarbageCollector( ctx context.Context, kubeClient clientset.Interface, metadataClient metadata.Interface, mapper meta.ResettableRESTMapper, graphBuilder *GraphBuilder, ) (*GarbageCollector, error)
func NewGarbageCollector ¶
func NewGarbageCollector( ctx context.Context, kubeClient clientset.Interface, metadataClient metadata.Interface, mapper meta.ResettableRESTMapper, ignoredResources map[schema.GroupResource]struct{}, sharedInformers informerfactory.InformerFactory, informersStarted <-chan struct{}, ) (*GarbageCollector, error)
NewGarbageCollector creates a new GarbageCollector.
func (*GarbageCollector) DebuggingHandler ¶
func (gc *GarbageCollector) DebuggingHandler() http.Handler
func (*GarbageCollector) GetDependencyGraphBuilder ¶
func (gc *GarbageCollector) GetDependencyGraphBuilder() *GraphBuilder
GetDependencyGraphBuilder return graph builder which is particularly helpful for testing where controllerContext is not available
func (*GarbageCollector) GraphHasUID ¶
func (gc *GarbageCollector) GraphHasUID(u types.UID) bool
*FOR TEST USE ONLY* GraphHasUID returns if the GraphBuilder has a particular UID store in its uidToNode graph. It's useful for debugging. This method is used by integration tests.
func (*GarbageCollector) IsSynced ¶
func (gc *GarbageCollector) IsSynced(logger klog.Logger) bool
IsSynced returns true if dependencyGraphBuilder is synced.
func (*GarbageCollector) Name ¶
func (gc *GarbageCollector) Name() string
func (*GarbageCollector) Run ¶
Run starts garbage collector workers.
func (*GarbageCollector) Sync ¶
func (gc *GarbageCollector) Sync(ctx context.Context, discoveryClient discovery.ServerResourcesInterface, period time.Duration)
Sync periodically resyncs the garbage collector when new resources are observed from discovery. When new resources are detected, it will reset gc.restMapper, and resync the monitors.
Note that discoveryClient should NOT be shared with gc.restMapper, otherwise the mapper's underlying discovery client will be unnecessarily reset during the course of detecting new resources.
type GraphBuilder ¶
type GraphBuilder struct {
// contains filtered or unexported fields
}
GraphBuilder processes events supplied by the informers, updates uidToNode, a graph that caches the dependencies as we know, and enqueues items to the attemptToDelete and attemptToOrphan.
func NewDependencyGraphBuilder ¶
func NewDependencyGraphBuilder( ctx context.Context, metadataClient metadata.Interface, mapper meta.ResettableRESTMapper, ignoredResources map[schema.GroupResource]struct{}, sharedInformers informerfactory.InformerFactory, informersStarted <-chan struct{}, ) *GraphBuilder
func (*GraphBuilder) GetGraphResources ¶
func (gb *GraphBuilder) GetGraphResources() ( attemptToDelete workqueue.TypedRateLimitingInterface[*node], attemptToOrphan workqueue.TypedRateLimitingInterface[*node], absentOwnerCache *ReferenceCache, )
func (*GraphBuilder) GetMonitor ¶
func (gb *GraphBuilder) GetMonitor(ctx context.Context, resource schema.GroupVersionResource) (*Monitor, error)
GetMonitor returns a monitor for the given resource. If the monitor is not synced, it will return an error and the monitor to allow the caller to decide whether to retry. If the monitor is not found, it will return only an error.
func (*GraphBuilder) IsResourceSynced ¶
func (gb *GraphBuilder) IsResourceSynced(resource schema.GroupVersionResource) bool
IsResourceSynced returns true if a monitor exists for the given resource and has synced
func (*GraphBuilder) IsSynced ¶
func (gb *GraphBuilder) IsSynced(logger klog.Logger) bool
IsSynced returns true if any monitors exist AND all those monitors' controllers HasSynced functions return true. This means IsSynced could return true at one time, and then later return false if all monitors were reconstructed.
func (*GraphBuilder) Name ¶
func (gb *GraphBuilder) Name() string
func (*GraphBuilder) Run ¶
func (gb *GraphBuilder) Run(ctx context.Context)
Run sets the stop channel and starts monitor execution until stopCh is closed. Any running monitors will be stopped before Run returns.
type Monitor ¶
type Monitor struct { Store cache.Store Controller cache.Controller }
type ObjectMetaForFinalizersPatch ¶
type ObjectMetaForFinalizersPatch struct { ResourceVersion string `json:"resourceVersion"` Finalizers []string `json:"finalizers"` }
ObjectMetaForFinalizersPatch defines object meta struct for finalizers patch operation.
type ObjectMetaForPatch ¶
type ObjectMetaForPatch struct { ResourceVersion string `json:"resourceVersion"` OwnerReferences []metav1.OwnerReference `json:"ownerReferences"` }
ObjectMetaForPatch defines object meta struct for patch operation.
type ReferenceCache ¶
type ReferenceCache struct {
// contains filtered or unexported fields
}
ReferenceCache is an LRU cache for uid.
func NewReferenceCache ¶
func NewReferenceCache(maxCacheEntries int) *ReferenceCache
NewReferenceCache returns a ReferenceCache.
func (*ReferenceCache) Add ¶
func (c *ReferenceCache) Add(reference objectReference)
Add adds a uid to the cache.
func (*ReferenceCache) Has ¶
func (c *ReferenceCache) Has(reference objectReference) bool
Has returns if a uid is in the cache.
Source Files ¶
dump.go errors.go garbagecollector.go graph.go graph_builder.go operations.go patch.go uid_cache.go
Directories ¶
Path | Synopsis |
---|---|
pkg/controller/garbagecollector/config | |
pkg/controller/garbagecollector/config/v1alpha1 | |
pkg/controller/garbagecollector/metaonly | |
pkg/controller/garbagecollector/metrics |
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 41 packages
- Last checked
- 3 hours ago –
Tools for package owners.