Don't sync all objects for replenishment as often as ResourceQuota.

This commit is contained in:
Wojciech Tyczynski
2016-03-07 08:20:32 +01:00
parent 13c17ddc67
commit e2ebc50648
3 changed files with 15 additions and 9 deletions

View File

@@ -45,6 +45,8 @@ type ResourceQuotaControllerOptions struct {
Registry quota.Registry
// Knows how to build controllers that notify replenishment events
ControllerFactory ReplenishmentControllerFactory
// Controls full resync of objects monitored for replenihsment.
ReplenishmentResyncPeriod controller.ResyncPeriodFunc
// List of GroupKind objects that should be monitored for replenishment at
// a faster frequency than the quota controller recalculation interval
GroupKindsToReplenish []unversioned.GroupKind
@@ -124,7 +126,7 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) *Resour
for _, groupKindToReplenish := range options.GroupKindsToReplenish {
controllerOptions := &ReplenishmentControllerOptions{
GroupKind: groupKindToReplenish,
ResyncPeriod: options.ResyncPeriod,
ResyncPeriod: options.ReplenishmentResyncPeriod,
ReplenishmentFunc: rq.replenishQuota,
}
replenishmentController, err := options.ControllerFactory.NewController(controllerOptions)

View File

@@ -113,7 +113,8 @@ func TestSyncResourceQuota(t *testing.T) {
api.Kind("ReplicationController"),
api.Kind("PersistentVolumeClaim"),
},
ControllerFactory: NewReplenishmentControllerFactory(kubeClient),
ControllerFactory: NewReplenishmentControllerFactory(kubeClient),
ReplenishmentResyncPeriod: controller.NoResyncPeriodFunc,
}
quotaController := NewResourceQuotaController(resourceQuotaControllerOptions)
err := quotaController.syncResourceQuota(resourceQuota)
@@ -198,7 +199,8 @@ func TestSyncResourceQuotaSpecChange(t *testing.T) {
api.Kind("ReplicationController"),
api.Kind("PersistentVolumeClaim"),
},
ControllerFactory: NewReplenishmentControllerFactory(kubeClient),
ControllerFactory: NewReplenishmentControllerFactory(kubeClient),
ReplenishmentResyncPeriod: controller.NoResyncPeriodFunc,
}
quotaController := NewResourceQuotaController(resourceQuotaControllerOptions)
err := quotaController.syncResourceQuota(resourceQuota)
@@ -274,7 +276,8 @@ func TestSyncResourceQuotaNoChange(t *testing.T) {
api.Kind("ReplicationController"),
api.Kind("PersistentVolumeClaim"),
},
ControllerFactory: NewReplenishmentControllerFactory(kubeClient),
ControllerFactory: NewReplenishmentControllerFactory(kubeClient),
ReplenishmentResyncPeriod: controller.NoResyncPeriodFunc,
}
quotaController := NewResourceQuotaController(resourceQuotaControllerOptions)
err := quotaController.syncResourceQuota(resourceQuota)