mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 11:18:16 +00:00
Made cache.Controller to be interface.
This commit is contained in:
@@ -48,7 +48,7 @@ type CertificateController struct {
|
||||
kubeClient clientset.Interface
|
||||
|
||||
// CSR framework and store
|
||||
csrController *cache.Controller
|
||||
csrController cache.Controller
|
||||
csrStore cache.StoreToCertificateRequestLister
|
||||
|
||||
syncHandler func(csrKey string) error
|
||||
|
||||
@@ -63,26 +63,26 @@ type DisruptionController struct {
|
||||
kubeClient clientset.Interface
|
||||
|
||||
pdbStore cache.Store
|
||||
pdbController *cache.Controller
|
||||
pdbController cache.Controller
|
||||
pdbLister cache.StoreToPodDisruptionBudgetLister
|
||||
|
||||
podController cache.ControllerInterface
|
||||
podController cache.Controller
|
||||
podLister cache.StoreToPodLister
|
||||
|
||||
rcIndexer cache.Indexer
|
||||
rcController *cache.Controller
|
||||
rcController cache.Controller
|
||||
rcLister cache.StoreToReplicationControllerLister
|
||||
|
||||
rsStore cache.Store
|
||||
rsController *cache.Controller
|
||||
rsController cache.Controller
|
||||
rsLister cache.StoreToReplicaSetLister
|
||||
|
||||
dIndexer cache.Indexer
|
||||
dController *cache.Controller
|
||||
dController cache.Controller
|
||||
dLister cache.StoreToDeploymentLister
|
||||
|
||||
ssStore cache.Store
|
||||
ssController *cache.Controller
|
||||
ssController cache.Controller
|
||||
ssLister cache.StoreToStatefulSetLister
|
||||
|
||||
// PodDisruptionBudget keys that need to be synced.
|
||||
|
||||
@@ -147,8 +147,8 @@ type EndpointController struct {
|
||||
|
||||
// Since we join two objects, we'll watch both of them with
|
||||
// controllers.
|
||||
serviceController *cache.Controller
|
||||
podController cache.ControllerInterface
|
||||
serviceController cache.Controller
|
||||
podController cache.Controller
|
||||
// podStoreSynced returns true if the pod store has been synced at least once.
|
||||
// Added as a member to the struct to allow injection for testing.
|
||||
podStoreSynced func() bool
|
||||
|
||||
@@ -48,7 +48,7 @@ const ResourceResyncTime time.Duration = 0
|
||||
|
||||
type monitor struct {
|
||||
store cache.Store
|
||||
controller *cache.Controller
|
||||
controller cache.Controller
|
||||
}
|
||||
|
||||
type objectReference struct {
|
||||
|
||||
@@ -56,7 +56,7 @@ type NamespaceController struct {
|
||||
// store that holds the namespaces
|
||||
store cache.Store
|
||||
// controller that observes the namespaces
|
||||
controller *cache.Controller
|
||||
controller cache.Controller
|
||||
// namespaces that have been queued up for processing by workers
|
||||
queue workqueue.RateLimitingInterface
|
||||
// function to list of preferred resources for namespace deletion
|
||||
|
||||
@@ -64,12 +64,12 @@ type StatefulSetController struct {
|
||||
// podStoreSynced returns true if the pod store has synced at least once.
|
||||
podStoreSynced func() bool
|
||||
// Watches changes to all pods.
|
||||
podController cache.ControllerInterface
|
||||
podController cache.Controller
|
||||
|
||||
// A store of StatefulSets, populated by the psController.
|
||||
psStore cache.StoreToStatefulSetLister
|
||||
// Watches changes to all StatefulSets.
|
||||
psController *cache.Controller
|
||||
psController cache.Controller
|
||||
|
||||
// A store of the 1 unhealthy pet blocking progress for a given ps
|
||||
blockingPetStore *unhealthyPetTracker
|
||||
|
||||
@@ -66,13 +66,13 @@ type HorizontalController struct {
|
||||
// A store of HPA objects, populated by the controller.
|
||||
store cache.Store
|
||||
// Watches changes to all HPA objects.
|
||||
controller *cache.Controller
|
||||
controller cache.Controller
|
||||
}
|
||||
|
||||
var downscaleForbiddenWindow = 5 * time.Minute
|
||||
var upscaleForbiddenWindow = 3 * time.Minute
|
||||
|
||||
func newInformer(controller *HorizontalController, resyncPeriod time.Duration) (cache.Store, *cache.Controller) {
|
||||
func newInformer(controller *HorizontalController, resyncPeriod time.Duration) (cache.Store, cache.Controller) {
|
||||
return cache.NewInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
|
||||
@@ -50,7 +50,7 @@ type PodGCController struct {
|
||||
internalPodInformer cache.SharedIndexInformer
|
||||
|
||||
podStore cache.StoreToPodLister
|
||||
podController cache.ControllerInterface
|
||||
podController cache.Controller
|
||||
|
||||
deletePod func(namespace, name string) error
|
||||
terminatedPodThreshold int
|
||||
|
||||
@@ -37,6 +37,10 @@ func (*FakeController) HasSynced() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (*FakeController) LastSyncResourceVersion() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func TestGCTerminated(t *testing.T) {
|
||||
type nameToPhase struct {
|
||||
name string
|
||||
|
||||
@@ -86,7 +86,7 @@ type ReplicationManager struct {
|
||||
// A store of pods, populated by the podController
|
||||
podLister cache.StoreToPodLister
|
||||
// Watches changes to all pods
|
||||
podController cache.ControllerInterface
|
||||
podController cache.Controller
|
||||
// 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 func() bool
|
||||
|
||||
@@ -90,7 +90,7 @@ func ObjectReplenishmentDeleteFunc(options *ReplenishmentControllerOptions) func
|
||||
type ReplenishmentControllerFactory interface {
|
||||
// NewController returns a controller configured with the specified options.
|
||||
// This method is NOT thread-safe.
|
||||
NewController(options *ReplenishmentControllerOptions) (cache.ControllerInterface, error)
|
||||
NewController(options *ReplenishmentControllerOptions) (cache.Controller, error)
|
||||
}
|
||||
|
||||
// replenishmentControllerFactory implements ReplenishmentControllerFactory
|
||||
@@ -118,7 +118,8 @@ func NewReplenishmentControllerFactoryFromClient(kubeClient clientset.Interface)
|
||||
func controllerFor(
|
||||
groupResource schema.GroupResource,
|
||||
f informers.SharedInformerFactory,
|
||||
handlerFuncs cache.ResourceEventHandlerFuncs) (cache.ControllerInterface, error) {
|
||||
handlerFuncs cache.ResourceEventHandlerFuncs,
|
||||
) (cache.Controller, error) {
|
||||
genericInformer, err := f.ForResource(groupResource)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -128,7 +129,7 @@ func controllerFor(
|
||||
return informer.GetController(), nil
|
||||
}
|
||||
|
||||
func (r *replenishmentControllerFactory) NewController(options *ReplenishmentControllerOptions) (result cache.ControllerInterface, err error) {
|
||||
func (r *replenishmentControllerFactory) NewController(options *ReplenishmentControllerOptions) (result cache.Controller, err error) {
|
||||
if r.kubeClient != nil && r.kubeClient.Core().RESTClient().GetRateLimiter() != nil {
|
||||
metrics.RegisterMetricAndTrackRateLimiterUsage("replenishment_controller", r.kubeClient.Core().RESTClient().GetRateLimiter())
|
||||
}
|
||||
@@ -276,7 +277,7 @@ func IsUnhandledGroupKindError(err error) bool {
|
||||
// returning the first success or failure it hits. If there are no hits either way, it return an UnhandledGroupKind error
|
||||
type UnionReplenishmentControllerFactory []ReplenishmentControllerFactory
|
||||
|
||||
func (f UnionReplenishmentControllerFactory) NewController(options *ReplenishmentControllerOptions) (cache.ControllerInterface, error) {
|
||||
func (f UnionReplenishmentControllerFactory) NewController(options *ReplenishmentControllerOptions) (cache.Controller, error) {
|
||||
for _, factory := range f {
|
||||
controller, err := factory.NewController(options)
|
||||
if !IsUnhandledGroupKindError(err) {
|
||||
|
||||
@@ -60,7 +60,7 @@ type ResourceQuotaController struct {
|
||||
// An index of resource quota objects by namespace
|
||||
rqIndexer cache.Indexer
|
||||
// Watches changes to all resource quota
|
||||
rqController *cache.Controller
|
||||
rqController cache.Controller
|
||||
// ResourceQuota objects that need to be synchronized
|
||||
queue workqueue.RateLimitingInterface
|
||||
// missingUsageQueue holds objects that are missing the initial usage informatino
|
||||
@@ -72,7 +72,7 @@ type ResourceQuotaController struct {
|
||||
// knows how to calculate usage
|
||||
registry quota.Registry
|
||||
// controllers monitoring to notify for replenishment
|
||||
replenishmentControllers []cache.ControllerInterface
|
||||
replenishmentControllers []cache.Controller
|
||||
}
|
||||
|
||||
func NewResourceQuotaController(options *ResourceQuotaControllerOptions) *ResourceQuotaController {
|
||||
@@ -83,7 +83,7 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) *Resour
|
||||
missingUsageQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "resourcequota_priority"),
|
||||
resyncPeriod: options.ResyncPeriod,
|
||||
registry: options.Registry,
|
||||
replenishmentControllers: []cache.ControllerInterface{},
|
||||
replenishmentControllers: []cache.Controller{},
|
||||
}
|
||||
if options.KubeClient != nil && options.KubeClient.Core().RESTClient().GetRateLimiter() != nil {
|
||||
metrics.RegisterMetricAndTrackRateLimiterUsage("resource_quota_controller", options.KubeClient.Core().RESTClient().GetRateLimiter())
|
||||
|
||||
@@ -54,7 +54,7 @@ type RouteController struct {
|
||||
clusterName string
|
||||
clusterCIDR *net.IPNet
|
||||
// Node framework and store
|
||||
nodeController *cache.Controller
|
||||
nodeController cache.Controller
|
||||
nodeStore cache.StoreToNodeLister
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ type ServiceController struct {
|
||||
// A store of services, populated by the serviceController
|
||||
serviceStore cache.StoreToServiceLister
|
||||
// Watches changes to all services
|
||||
serviceController *cache.Controller
|
||||
serviceController cache.Controller
|
||||
eventBroadcaster record.EventBroadcaster
|
||||
eventRecorder record.EventRecorder
|
||||
nodeLister cache.StoreToNodeLister
|
||||
|
||||
@@ -145,8 +145,8 @@ type TokensController struct {
|
||||
secrets cache.Indexer
|
||||
|
||||
// Since we join two objects, we'll watch both of them with controllers.
|
||||
serviceAccountController *cache.Controller
|
||||
secretController *cache.Controller
|
||||
serviceAccountController cache.Controller
|
||||
secretController cache.Controller
|
||||
|
||||
// syncServiceAccountQueue handles service account events:
|
||||
// * ensures a referenced token exists for service accounts which still exist
|
||||
|
||||
@@ -146,10 +146,10 @@ const createProvisionedPVInterval = 10 * time.Second
|
||||
// cache.Controllers that watch PersistentVolume and PersistentVolumeClaim
|
||||
// changes.
|
||||
type PersistentVolumeController struct {
|
||||
volumeController *cache.Controller
|
||||
volumeController cache.Controller
|
||||
volumeInformer cache.Indexer
|
||||
volumeSource cache.ListerWatcher
|
||||
claimController *cache.Controller
|
||||
claimController cache.Controller
|
||||
claimInformer cache.Store
|
||||
claimSource cache.ListerWatcher
|
||||
classReflector *cache.Reflector
|
||||
|
||||
Reference in New Issue
Block a user