// A ReplicaSet is temporarily suspended after creating/deleting these many replicas. // It resumes normal action after observing the watch events for them. burstReplicas int // To allow injection of syncReplicaSet for testing. syncHandler func(ctx context.Context, rsKey string)error
// A TTLCache of pod creates/deletes each rc expects to see. expectations *controller.UIDTrackingControllerExpectations
// A store of ReplicaSets, populated by the shared informer passed to NewReplicaSetController rsLister appslisters.ReplicaSetLister // rsListerSynced returns true if the pod store has been synced at least once. // Added as a member to the struct to allow injection for testing. rsListerSynced cache.InformerSynced rsIndexer cache.Indexer
// A store of pods, populated by the shared informer passed to NewReplicaSetController podLister corelisters.PodLister // podListerSynced returns true if the pod store has been synced at least once. // Added as a member to the struct to allow injection for testing. podListerSynced cache.InformerSynced
// Controllers that need to be synced queue workqueue.RateLimitingInterface }
successfulCreations, err := slowStartBatch(diff, controller.SlowStartInitialBatchSize, func()error { err := rsc.podControl.CreatePods(ctx, rs.Namespace, &rs.Spec.Template, rs, metav1.NewControllerRef(rs, rsc.GroupVersionKind)) if err != nil { if apierrors.HasStatusCause(err, v1.NamespaceTerminatingCause) { // if the namespace is being terminated, we don't have to do // anything because any creation will fail returnnil } } return err })
// Any skipped pods that we never attempted to start shouldn't be expected. // The skipped pods will be retried later. The next controller resync will // retry the slow start process. if skippedPods := diff - successfulCreations; skippedPods > 0 { logger.V(2).Info("Slow-start failure. Skipping creation of pods, decrementing expectations", "podsSkipped", skippedPods, "kind", rsc.Kind, "replicaSet", klog.KObj(rs)) for i := 0; i < skippedPods; i++ { // Decrement the expected number of creates because the informer won't observe this pod rsc.expectations.CreationObserved(logger, rsKey) } } return err }
// pkg/controller/controller_utils.go:332 type UIDTrackingControllerExpectations struct { ControllerExpectationsInterface // TODO: There is a much nicer way to do this that involves a single store, // a lock per entry, and a ControlleeExpectationsInterface type. uidStoreLock sync.Mutex // Store used for the UIDs associated with any expectation tracked via the // ControllerExpectationsInterface. uidStore cache.Store }