Commit Graph

21 Commits

Author SHA1 Message Date
Matt Moore 222dd25986 Migrate pkg to use the knative.dev/pkg import path (#489)
* Manual changes.

* scripted changes.
2019-06-26 13:02:06 -07:00
Matt Moore 7538724784 Stabilize the controller unit tests. (#482) 2019-06-23 17:16:00 -07:00
Matt Moore c6f03fa600 Push the event recorder stuff into knative/pkg (#443) 2019-06-06 07:35:40 -07:00
Matt Moore 985bff446d Simplify the default controller.Impl constructor. (#427)
A while back we added a "StatsReporter" argument to `controller.NewImpl`,
but in serving every callsite of this is passing:
```
controller.NewImpl(r, logger, "my-string", MustNewStatsReporter("my-string", logger))
```

Where `MustNewStatsReporter` is just a form of knative/pkg's `controller.NewStatsReporter`
that logs fatally when an error is returned.  It is notable that Serving's logic has been
duplicated to both Build and Eventing.

There are a handful of changes here:
1. Move MustNewStatsReporter into knative/pkg
2. Expose the current interface as NewImplWithStats
3. Drop the StatsReporter from NewImpl and default to `MustNewStatsReporter()`

This is a breaking change for downstream repositories, but should make their callsites universally simpler.
2019-05-28 13:16:31 -07:00
Matt Moore d1ccfd6652 This upstreams a useful helper from serving. (#428)
In serving we have `reconciler.Handler` that wraps a handler function
(e.g. `Enqueue`) in the `cache.ResourceEventHandlerFuncs`.  This pattern
was becoming pervasive, so this simpler handler dramatically reduced our
boilerplate.
2019-05-27 23:21:29 -07:00
Matt Moore aae68ba9e0 Add methods for attaching resync duration to context. (#426)
Also adds a method for tracker leases, which should be a multiple of the resync period.
2019-05-26 23:44:29 -07:00
Ville Aikas 5e4512dcb2 Add Filter function by name/namespace (#414) 2019-05-14 13:53:32 -07:00
Victor Agababov c3f131538a add addafter method that permits enqueueing the objects themselves (#408) 2019-05-08 16:14:37 -07:00
Victor Agababov f23f58d373 Expose the EnqueueKeyAfter function on the controller (#402)
This is needed for the positive handoff, so that we can enqueue
the KPA after we received the positive answer from the activator
but still want to have buffer time to make sure the network
changes propagate everywhere.
2019-05-02 17:16:34 -07:00
Nghia Tran 590eb946f1 Add a version of GlobalResync that calls an event handler. (#381)
* Add a version of GlobalResync that calls an event handler.

This allows impl to apply filtering and queuing logic of their own,
instead of calling Enqueue() for everything.

* Fix typo in doc comment.
2019-04-10 13:33:59 -07:00
Matt Moore 7735348150 Add some helpers to reduce boilerplate in controller binaries. (#335)
* Add some helpers to reduce boilerplate in controller binaries.

* Incorporate feedback from Victor.

* Fix a couple test data races.
2019-03-23 10:57:48 -07:00
Brad Hoekstra b8c4664801 Don't rate-limit normal events (#242)
* Don't rate-limit normal events

* Fix test - first enqueue is not rate limited
2019-01-25 14:11:34 -08:00
Matt Moore 102237ce9b Simplify the core controller logic. (#184)
I was hoping to switch from a simple string key to a struct to include additional metadata into our workqueue item (in particular the time at which it was queued), but the great unit tests here reminded me that this would not properly deduplicate keys (they would have different queue times!), so I'm settling for simplifying the loop in a few ways:
1. Keys can only be strings, so remove some error checking and a test.
1. We were wrapping a block in a `func` because it contained `defer`, but the outer function had nothing in it.

I'd still like to try and find a way to track queue times for keys, so that we can surface two interesting metrics:
1. How long are things spending queued?
1. How long between events being observed and us responding? (above + reconcile latency)
2018-12-03 17:02:25 -08:00
mattmoor-sockpuppet d99eb0732f Run gofmt (#171)
Produced via: `gofmt -s -w $(find -name '*.go' | grep -v vendor)`
2018-11-26 07:18:22 -08:00
lichuqiang a5c260df2a Update EnqueueLabelOf to handle resources in same namespace (#166)
* update EnqueueLabelOf to handle resources in same namespace

* spit the EnqueueLabelOf func for namespaced/cluster-scoped resources
2018-11-19 19:04:20 -08:00
lichuqiang fcb0656514 requeue keys on error in controller (#149)
* requeue keys on error in controller

* remove maxRetries limit
2018-10-31 09:59:34 -07:00
lichuqiang d247efe41d update EnqueueControllerOf to properly handle Delete (#146)
* update EnqueueControllerOf to properly handle Delete

* update existing test

* add enqueue label tests

* address comments
2018-10-30 07:13:34 -07:00
Mustafa Demirhan 6c3ae54dda Add reconciler metrics (#127)
* Add reconciler metrics for queue depth, reconcile count & reconcile latency.

* Update deps.

* Change queue depth measurement type to int64 from float64

* Address PR comments

* Add extra unit tests.

* Minor fixes.

* Address PR comments by adding extra documentation

* Add tests for testing/fake_stats_reporter

* Addressed PR comments.

* Address PR comments.
2018-10-22 14:34:30 -07:00
Ivan Mikushin 62bcfe912f Prepare for global resync on ConfigMap changes (#132)
* Prepare for global resync on ConfigMap changes

- Add GlobalResync(cache.SharedInformer) method to *controller.Impl
- Move UntypedStore from serving/pkg/config to pkg/configmap
- Add onAfterStore callbacks to UntypedStore
- Add TypeFilter to enable composable construction of such callbacks

* Address review

- Unit test GlobalResync()
- Reimpl GlobalResync() using ListKeys()

* Update comments

* Add test for onAfterStore

* Update godoc comment for Logger
2018-10-18 09:47:28 -07:00
Matt Moore 4da41e302a Bump the sleep in the controller testing. (#88)
The rate limiting queue makes the sleep necessary.  Locally I see 0-2 failures when this is run with -count=10000.  This bumps the sleep slightly to reduce this further.

Fixes: https://github.com/knative/pkg/issues/56
2018-09-24 07:49:20 -07:00
Matt Moore bf6f9e373f Move our base controller infrastructure into knative/pkg. (#33)
The `controller.go` is from: https://github.com/knative/serving/pull/1770, however, this adds 100% coverage of `controller.go`, which we have been missing in `knative/serving`.

This also adds a `context.Context` to the `Reconcile` signature, to enable better sharing of logger setup across controllers.

Fixes: https://github.com/knative/pkg/issues/8
2018-08-01 14:32:37 -07:00