* Check example-hash label for consistency in ConfigMap webhook.
We've seen users try to edit our configuration and falling into the trap of editing the '_example' block a lot. This attempts at guiding the users to do "the right thing" by checking the ConfigMap's '_example' value (if present) against a precomputed hash of the same value (if present). The idea is that we precompute this has using the tool herein in code generation and thus allow us to easily change the example block automatically while making it hard to change it on ppurpose. If the hashes don't match on an upgrade, the webhook will return an error synchronously, guiding the user to the correct behavior.
* Add tests.
* Add hash check to test utilities.
* Add a bit of coverage.
* Rewrite into a table test.
* Rename.
* Reduce test surface.
* Godoc.
* Code nits.
* Docs.
* Use CRC32.
* Nits.
Generally, the `onAfterStore` function is used to kick off a global resync, which should be a very quick operation. Having `onAfterStore` being called asynchronously on a goroutine makes it very hard or straight out impossible to control it, especially in tests.
If there's a costly operation being done `onAfterStore`, it should be up to the caller to decide to make that asynchronous and thus put it into a goroutine.
* tests: Rename 'cm' vars to 'cmw' for consistency
* Filter tracked sharedmain ConfigMaps based on label selector
The ConfigMap watcher only tracks the ConfigMaps which contain the label
defined by the optional SYSTEM_RESOURCE_LABEL env var if the latter
exists.
* Ignore idempotent updates and other cleanups
This makes sure we don't call the configmap update on the idempotent updates, which we get now and
that causes us lots of global resyncs. (┛◉Д◉)┛彡┻━┻.
In addition I went ahead and applied some nitpicking to the code.
/assign mattmoor
* fix races
* resync to zero
* Profiling support
* Move ProfilingPort to profiling package
* Fix golint errors
* Refactor watcher to accept variable length observers
* Cleaner happy path
* Remove profiling handlers argument
* use :8008 string as const
* Make the profiling port package private
* Make UpdateFromConfigMap member of profiling handler
* use mutex when accessing the enabled flag
* test the server as well
* Fixes
* Initialize profiling from configMap at startup
* Use httptest.ResponseRecorder to make the test more lightweight
* Fixes
* Do not initialize from configmap at startup
* Add configmap.DefaultingWatcher that allows watched ConfigMaps to be defaulted in code.
* Add a test where the real K8s CM is deleted.
* Remove unused cmName.
* WatchWithDefault after start panics.
* cfgs -> defaults
* Initialize defaults in NewInformedWatcherFromFactory.
* Remove unneeded error in panic.
* Moving reconcile/testing from serving to pkg.
* add clock.
* Update clock cw.
* move testing/configmap.go to configmap/
* wire in a setable context.
* need to export example key.
* 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
* Few changes to the configmap package
- New* methods return concrete types
- defaultImpl is now InformedWatcher
- fixedImpl is now StaticWatcher
- Included a new ManualWatcher that mimics the InformedWatcher
in behaviour. ie. allows updates - making this a true 'mock'
* Include note about embedding the ManualWatcher in the InformedWatcher
* Update static_watcher.go
Fix some godoc