{"modulePath":"github.com/stackpointcloud/kubernetes","version":"v1.3.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package controller\n\nPackage controller contains code for controllers (like the replication controller).\n\n## Constants\n\n```go\nconst (\n\tCreatedByAnnotation = \"kubernetes.io/created-by\"\n\n\t// If a watch drops a delete event for a pod, it'll take this long\n\t// before a dormant controller waiting for those packets is woken up anyway. It is\n\t// specifically targeted at the case where some problem prevents an update\n\t// of expectations, without it the controller could stay asleep forever. This should\n\t// be set based on the expected latency of watch events.\n\t//\n\t// Currently a controller can service (create *and* observe the watch events for said\n\t// creation) about 10 pods a second, so it takes about 1 min to service\n\t// 500 pods. Just creation is limited to 20qps, and watching happens with ~10-30s\n\t// latency/pod at the scale of 3000 pods over 100 nodes.\n\tExpectationsTimeout = 5 * time.Minute\n)\n```\n\n## Variables\n\n```go\nvar ExpKeyFunc = func(obj interface{}) (string, error) {\n\tif e, ok := obj.(*ControlleeExpectations); ok {\n\t\treturn e.key, nil\n\t}\n\treturn \"\", fmt.Errorf(\"Could not find key for obj %#v\", obj)\n}\n```\nExpKeyFunc to parse out the key from a ControlleeExpectation\n\n```go\nvar (\n\tKeyFunc = framework.DeletionHandlingMetaNamespaceKeyFunc\n)\n```\n\n```go\nvar UIDSetKeyFunc = func(obj interface{}) (string, error) {\n\tif u, ok := obj.(*UIDSet); ok {\n\t\treturn u.key, nil\n\t}\n\treturn \"\", fmt.Errorf(\"Could not find key for obj %#v\", obj)\n}\n```\nUIDSetKeyFunc to parse out the key from a UIDSet.\n\n## Functions\n\n```go\nfunc FilterActivePods(pods []api.Pod) []*api.Pod\n```\nFilterActivePods returns pods that have not terminated.\n\n```go\nfunc FilterActiveReplicaSets(replicaSets []*extensions.ReplicaSet) []*extensions.ReplicaSet\n```\nFilterActiveReplicaSets returns replica sets that have (or at least ought to have) pods.\n\n```go\nfunc GetPodFromTemplate(template *api.PodTemplateSpec, parentObject runtime.Object) (*api.Pod, error)\n```\n\n```go\nfunc IsPodActive(p api.Pod) bool\n```\n\n```go\nfunc NoResyncPeriodFunc() time.Duration\n```\nReturns 0 for resyncPeriod in case resyncing is not needed.\n\n```go\nfunc PodKey(pod *api.Pod) string\n```\nPodKey returns a key unique to the given pod within a cluster. It's used so we consistently use the same key scheme in this module. It does exactly what cache.MetaNamespaceKeyFunc would have done expcept there's not possibility for error since we know the exact type.\n\n## Types\n\n```go\ntype ActivePods []*api.Pod\n```\nActivePods type allows custom sorting of pods so a controller can pick the best ones to delete.\n\n```go\nfunc (s ActivePods) Len() int\n```\n\n```go\nfunc (s ActivePods) Less(i, j int) bool\n```\n\n```go\nfunc (s ActivePods) Swap(i, j int)\n```\n\n```go\ntype ControlleeExpectations struct {\n\t// contains filtered or unexported fields\n}\n```\nControlleeExpectations track controllee creates/deletes.\n\n```go\nfunc (e *ControlleeExpectations) Add(add, del int64)\n```\nAdd increments the add and del counters.\n\n```go\nfunc (e *ControlleeExpectations) Fulfilled() bool\n```\nFulfilled returns true if this expectation has been fulfilled.\n\n```go\nfunc (e *ControlleeExpectations) GetExpectations() (int64, int64)\n```\nGetExpectations returns the add and del expectations of the controllee.\n\n```go\ntype ControllerExpectations struct {\n\tcache.Store\n}\n```\nControllerExpectations is a cache mapping controllers to what they expect to see before being woken up for a sync.\n\n```go\nfunc NewControllerExpectations() *ControllerExpectations\n```\nNewControllerExpectations returns a store for ControllerExpectations.\n\n```go\nfunc (r *ControllerExpectations) CreationObserved(controllerKey string)\n```\nCreationObserved atomically decrements the \\`add\\` expecation count of the given controller.\n\n```go\nfunc (r *ControllerExpectations) DeleteExpectations(controllerKey string)\n```\nDeleteExpectations deletes the expectations of the given controller from the TTLStore.\n\n```go\nfunc (r *ControllerExpectations) DeletionObserved(controllerKey string)\n```\nDeletionObserved atomically decrements the \\`del\\` expectation count of the given controller.\n\n```go\nfunc (r *ControllerExpectations) ExpectCreations(controllerKey string, adds int) error\n```\n\n```go\nfunc (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int) error\n```\n\n```go\nfunc (r *ControllerExpectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)\n```\nGetExpectations returns the ControlleeExpectations of the given controller.\n\n```go\nfunc (r *ControllerExpectations) LowerExpectations(controllerKey string, add, del int)\n```\nDecrements the expectation counts of the given controller.\n\n```go\nfunc (r *ControllerExpectations) RaiseExpectations(controllerKey string, add, del int)\n```\nIncrements the expectation counts of the given controller.\n\n```go\nfunc (r *ControllerExpectations) SatisfiedExpectations(controllerKey string) bool\n```\nSatisfiedExpectations returns true if the required adds/dels for the given controller have been observed. Add/del counts are established by the controller at sync time, and updated as controllees are observed by the controller manager.\n\n```go\nfunc (r *ControllerExpectations) SetExpectations(controllerKey string, add, del int) error\n```\nSetExpectations registers new expectations for the given controller. Forgets existing expectations.\n\n```go\ntype ControllerExpectationsInterface interface {\n\tGetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)\n\tSatisfiedExpectations(controllerKey string) bool\n\tDeleteExpectations(controllerKey string)\n\tSetExpectations(controllerKey string, add, del int) error\n\tExpectCreations(controllerKey string, adds int) error\n\tExpectDeletions(controllerKey string, dels int) error\n\tCreationObserved(controllerKey string)\n\tDeletionObserved(controllerKey string)\n\tRaiseExpectations(controllerKey string, add, del int)\n\tLowerExpectations(controllerKey string, add, del int)\n}\n```\nControllerExpectationsInterface is an interface that allows users to set and wait on expectations. Only abstracted out for testing. Warning: if using KeyFunc it is not safe to use a single ControllerExpectationsInterface with different types of controllers, because the keys might conflict across types.\n\n```go\ntype ControllersByCreationTimestamp []*api.ReplicationController\n```\nControllersByCreationTimestamp sorts a list of ReplicationControllers by creation timestamp, using their names as a tie breaker.\n\n```go\nfunc (o ControllersByCreationTimestamp) Len() int\n```\n\n```go\nfunc (o ControllersByCreationTimestamp) Less(i, j int) bool\n```\n\n```go\nfunc (o ControllersByCreationTimestamp) Swap(i, j int)\n```\n\n```go\ntype Expectations interface {\n\tFulfilled() bool\n}\n```\nExpectations are either fulfilled, or expire naturally.\n\n```go\ntype FakePodControl struct {\n\tsync.Mutex\n\tTemplates     []api.PodTemplateSpec\n\tDeletePodName []string\n\tErr           error\n}\n```\n\n```go\nfunc (f *FakePodControl) Clear()\n```\n\n```go\nfunc (f *FakePodControl) CreatePods(namespace string, spec *api.PodTemplateSpec, object runtime.Object) error\n```\n\n```go\nfunc (f *FakePodControl) CreatePodsOnNode(nodeName, namespace string, template *api.PodTemplateSpec, object runtime.Object) error\n```\n\n```go\nfunc (f *FakePodControl) DeletePod(namespace string, podID string, object runtime.Object) error\n```\n\n```go\ntype MatchingCache struct {\n\t// contains filtered or unexported fields\n}\n```\nMatchingCache save label and selector matching relationship\n\n```go\nfunc NewMatchingCache(maxCacheEntries int) *MatchingCache\n```\nNewMatchingCache return a NewMatchingCache, which save label and selector matching relationship.\n\n```go\nfunc (c *MatchingCache) Add(labelObj objectWithMeta, selectorObj objectWithMeta)\n```\nAdd will add matching information to the cache.\n\n```go\nfunc (c *MatchingCache) GetMatchingObject(labelObj objectWithMeta) (controller interface{}, exists bool)\n```\nGetMatchingObject lookup the matching object for a given object. Note: the cache information may be invalid since the controller may be deleted or updated, we need check in the external request to ensure the cache data is not dirty.\n\n```go\nfunc (c *MatchingCache) InvalidateAll()\n```\nInvalidateAll invalidate the whole cache.\n\n```go\nfunc (c *MatchingCache) Update(labelObj objectWithMeta, selectorObj objectWithMeta)\n```\nUpdate update the cached matching information.\n\n```go\ntype PodControlInterface interface {\n\t// CreatePods creates new pods according to the spec.\n\tCreatePods(namespace string, template *api.PodTemplateSpec, object runtime.Object) error\n\t// CreatePodsOnNode creates a new pod accorting to the spec on the specified node.\n\tCreatePodsOnNode(nodeName, namespace string, template *api.PodTemplateSpec, object runtime.Object) error\n\t// DeletePod deletes the pod identified by podID.\n\tDeletePod(namespace string, podID string, object runtime.Object) error\n}\n```\nPodControlInterface is an interface that knows how to add or delete pods created as an interface to allow testing.\n\n```go\ntype RealPodControl struct {\n\tKubeClient clientset.Interface\n\tRecorder   record.EventRecorder\n}\n```\nRealPodControl is the default implementation of PodControlInterface.\n\n```go\nfunc (r RealPodControl) CreatePods(namespace string, template *api.PodTemplateSpec, object runtime.Object) error\n```\n\n```go\nfunc (r RealPodControl) CreatePodsOnNode(nodeName, namespace string, template *api.PodTemplateSpec, object runtime.Object) error\n```\n\n```go\nfunc (r RealPodControl) DeletePod(namespace string, podID string, object runtime.Object) error\n```\n\n```go\ntype ReplicaSetsByCreationTimestamp []*extensions.ReplicaSet\n```\nReplicaSetsByCreationTimestamp sorts a list of ReplicationSets by creation timestamp, using their names as a tie breaker.\n\n```go\nfunc (o ReplicaSetsByCreationTimestamp) Len() int\n```\n\n```go\nfunc (o ReplicaSetsByCreationTimestamp) Less(i, j int) bool\n```\n\n```go\nfunc (o ReplicaSetsByCreationTimestamp) Swap(i, j int)\n```\n\n```go\ntype ResyncPeriodFunc func() time.Duration\n```\n\n```go\nfunc StaticResyncPeriodFunc(resyncPeriod time.Duration) ResyncPeriodFunc\n```\nStaticResyncPeriodFunc returns the resync period specified\n\n```go\ntype UIDSet struct {\n\tsets.String\n\t// contains filtered or unexported fields\n}\n```\nUIDSet holds a key and a set of UIDs. Used by the UIDTrackingControllerExpectations to remember which UID it has seen/still waiting for.\n\n```go\ntype UIDTrackingControllerExpectations struct {\n\tControllerExpectationsInterface\n\t// contains filtered or unexported fields\n}\n```\nUIDTrackingControllerExpectations tracks the UID of the pods it deletes. This cache is needed over plain old expectations to safely handle graceful deletion. The desired behavior is to treat an update that sets the DeletionTimestamp on an object as a delete. To do so consistenly, one needs to remember the expected deletes so they aren't double counted. TODO: Track creates as well (#22599)\n\n```go\nfunc NewUIDTrackingControllerExpectations(ce ControllerExpectationsInterface) *UIDTrackingControllerExpectations\n```\nNewUIDTrackingControllerExpectations returns a wrapper around ControllerExpectations that is aware of deleteKeys.\n\n```go\nfunc (u *UIDTrackingControllerExpectations) DeleteExpectations(rcKey string)\n```\nDeleteExpectations deletes the UID set and invokes DeleteExpectations on the underlying ControllerExpectationsInterface.\n\n```go\nfunc (u *UIDTrackingControllerExpectations) DeletionObserved(rcKey, deleteKey string)\n```\nDeletionObserved records the given deleteKey as a deletion, for the given rc.\n\n```go\nfunc (u *UIDTrackingControllerExpectations) ExpectDeletions(rcKey string, deletedKeys []string) error\n```\nExpectDeletions records expectations for the given deleteKeys, against the given controller.\n\n```go\nfunc (u *UIDTrackingControllerExpectations) GetUIDs(controllerKey string) sets.String\n```\nGetUIDs is a convenience method to avoid exposing the set of expected uids. The returned set is not thread safe, all modifications must be made holding the uidStoreLock.\n\n","path":"github.com/stackpointcloud/kubernetes/pkg/controller","name":"controller","synopsis":"Package controller contains code for controllers (like the replication controller).","isRedistributable":true}
