Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #120777: reintroduce resourcequota.NewMonitor #120795

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 9 additions & 10 deletions pkg/controller/resourcequota/resource_quota_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,15 @@ func NewController(ctx context.Context, options *ControllerOptions) (*Controller
)

if options.DiscoveryFunc != nil {
qm := &QuotaMonitor{
informersStarted: options.InformersStarted,
informerFactory: options.InformerFactory,
ignoredResources: options.IgnoredResourcesFunc(),
resourceChanges: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "resource_quota_controller_resource_changes"),
resyncPeriod: options.ReplenishmentResyncPeriod,
replenishmentFunc: rq.replenishQuota,
registry: rq.registry,
updateFilter: options.UpdateFilter,
}
qm := NewMonitor(
options.InformersStarted,
options.InformerFactory,
options.IgnoredResourcesFunc(),
options.ReplenishmentResyncPeriod,
rq.replenishQuota,
rq.registry,
options.UpdateFilter,
)

rq.quotaMonitor = qm

Expand Down
14 changes: 14 additions & 0 deletions pkg/controller/resourcequota/resource_quota_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ type QuotaMonitor struct {
updateFilter UpdateFilter
}

// NewMonitor creates a new instance of a QuotaMonitor
func NewMonitor(informersStarted <-chan struct{}, informerFactory informerfactory.InformerFactory, ignoredResources map[schema.GroupResource]struct{}, resyncPeriod controller.ResyncPeriodFunc, replenishmentFunc ReplenishmentFunc, registry quota.Registry, updateFilter UpdateFilter) *QuotaMonitor {
return &QuotaMonitor{
informersStarted: informersStarted,
informerFactory: informerFactory,
ignoredResources: ignoredResources,
resourceChanges: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "resource_quota_controller_resource_changes"),
resyncPeriod: resyncPeriod,
replenishmentFunc: replenishmentFunc,
registry: registry,
updateFilter: updateFilter,
}
}

// monitor runs a Controller with a local stop channel.
type monitor struct {
controller cache.Controller
Expand Down