controller

package
v0.0.0-...-d7f1ee3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FinalizerDeleteDependents = "k8s.io/in-use-protection"
)
View Source
const ResourceResyncTime time.Duration = 0

ResourceResyncTime defines the resync period of the informers.

Variables

This section is empty.

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(discoveryClient discovery.ServerResourcesInterface) map[schema.GroupVersionResource]struct{}

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.

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).

Types

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.

func (*GraphBuilder) IsSynced

func (gb *GraphBuilder) IsSynced() 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) Run

func (gb *GraphBuilder) Run(stopCh <-chan struct{})

Run sets the stop channel and starts monitor execution until stopCh is closed. Any running monitors will be stopped before Run returns.

type InUseProtector

type InUseProtector struct {
	// contains filtered or unexported fields
}

InUseProtector 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 deleted to the `attemptToDelete` queue, and enqueues objects whose dependents need to be orphaned to the `attemptToOrphan` queue. The InUseProtector 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 NewInUseProtector

func NewInUseProtector(
	kubeClient clientset.Interface,
	metadataClient metadata.Interface,
	mapper ResettableRESTMapper,
	ignoredResources map[schema.GroupResource]struct{},
	sharedInformers informerfactory.InformerFactory,
	informersStarted <-chan struct{},
) (*InUseProtector, error)

NewInUseProtector creates a new InUseProtector.

func (*InUseProtector) GraphHasUID

func (gc *InUseProtector) 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 (*InUseProtector) IsSynced

func (gc *InUseProtector) IsSynced() bool

IsSynced returns true if dependencyGraphBuilder is synced.

func (*InUseProtector) Run

func (gc *InUseProtector) Run(workers int, stopCh <-chan struct{})

Run starts in-use protector workers.

func (*InUseProtector) Sync

func (gc *InUseProtector) Sync(discoveryClient discovery.ServerResourcesInterface, period time.Duration, stopCh <-chan struct{})

Sync periodically resyncs the in-use protector when new resources are observed from discovery. When new resources are detected, Sync will stop all workers, 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 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.

type ResettableRESTMapper

type ResettableRESTMapper interface {
	meta.RESTMapper
	Reset()
}

ResettableRESTMapper is a RESTMapper which is capable of resetting itself from discovery.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL