Commit Graph

39 Commits

Author SHA1 Message Date
Weston Haught 43f4f824e3
use quotes for checksum strings (#1472) 2020-07-09 17:33:19 -07:00
Victor Agababov 76b65072de
Improve manual watcher a bit (#1435)
- remove redundant checks (iterating nil/empty slice works)
- fix comments
- remove duplicate test
- map scale size fix.
2020-06-22 14:39:26 -07:00
Matt Moore 7df8fc5d77
Implement the first wave of per-reconciler leaderelection. (#1301)
* Implement the first wave of per-reconciler leaderelection.

Detailed design: https://docs.google.com/document/d/1i_QHjQO2T3SNv49xjZLWlivcc0UvZN1Tbw2NKxThkyM/edit#
Issue: https://github.com/knative/pkg/issues/1181

* Feedback from vagababov

* Feedback from yanweiguo

* Drop IsLeaderFor from the LeaderAware interface.

* Moar vagababov nits

* dprotaso feedback

* Add issue comment, error return

* Incorporate dprotaso test feedback
2020-06-18 19:07:25 -07:00
Jon Donovan dbd32a77f4
Normalize newlines in webhook example checksum. (#1404)
* Normalize newlines in webhook example checksum.

* Support windows newlines.

* Remove unnecessary non-capturing group.
2020-06-15 15:45:24 -07:00
Julian Friedman aec2008e66
Allow hashgen to process multiple files (#1398) 2020-06-14 16:25:23 -07:00
Victor Agababov b7125260dc
Remove the trailing \n (#1381)
* fix the space issue

* merge shenanigans

* nit and tests
2020-06-05 10:07:18 -07:00
Julian Friedman 7b4093b435
Use annotation rather than label for configmap checksum (#1380) 2020-06-05 04:26:17 -07:00
Markus Thömmes b0dc3661a7
Use a hexadecimal representation for the example checksum. (#1374) 2020-06-03 08:33:18 -07:00
Markus Thömmes f45b641fc2
Check example-checksum label for consistency in ConfigMap webhook. (#1366)
* 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.
2020-06-02 10:48:17 -07:00
Julian Friedman 6eb9fa1546
Add AsQuantity to configmap parser (#1362) 2020-05-28 10:23:01 -07:00
Markus Thömmes 4f178c83ca
Make onAfterStore synchronous to the update itself. (#1349)
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.
2020-05-25 10:35:48 -07:00
Markus Thömmes 60f4ae1dbe
Use config map parsing lib and enhance it further. (#1335)
* Use config map parsing lib and enhance it further.

* Unexport test struct values.

* Migrate tracing config too.

* Use sample-rate.
2020-05-18 10:42:06 -07:00
Markus Thömmes a43a1b10f2
Add a library to parse config map values. (#1329)
* Add a library to parse config map values.

* Add AsString and comments.

* Add ParseFunc type.
2020-05-14 09:17:00 -07:00
Markus Thömmes 1b903ad8cc
Fix malformed license headers. (#1258) 2020-04-29 08:38:42 -07:00
Victor Agababov f384223ab1
Make a proper check when checking for spaces. (#1206)
Mostly this covers tabs, but also other strange things, like carriage return :-)
2020-04-08 13:31:02 -07:00
Slavomir Kaslev bc4401a91c
Fix TestInformedWatcher sporadic failing on testgrid (#1035)
See

  https://prow.knative.dev/view/gcs/knative-prow/logs/ci-knative-pkg-continuous/1224064360993787904
  https://prow.knative.dev/view/gcs/knative-prow/logs/ci-knative-pkg-continuous/1221890045716205568
  https://prow.knative.dev/view/gcs/knative-prow/logs/ci-knative-pkg-continuous/1220078144313102336

for more info.
2020-02-04 08:02:30 -08:00
Antoine Cotten 5e3431e561 Filter tracked sharedmain ConfigMaps based on optional label selector (#973)
* 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.
2020-01-13 06:53:04 -08:00
Victor Agababov 587055b113 Fix an annoying nit (#964)
Allocate as many as you're asked -- not just 1.

/assign mattmoor
2019-12-26 16:36:30 -08:00
Nima Kaviani d90ec6a015 add config validation as admission controller (#636) 2019-09-22 07:23:10 -07:00
Matthias Wessendorf dcfc14495f Remove deprecated NewFixedWatcher (#699) 2019-09-19 14:38:01 -07:00
Victor Agababov 73daad6e47 Ignore idempotent updates and other cleanups (#598)
* 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
2019-08-26 07:04:14 -07:00
Martin Gencur 366ab85660 Profiling support (#562)
* 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
2019-08-22 08:17:33 -07:00
Matt Moore 6785699dc3 Revert "Remove reflection from generic store code. (#583)" (#585)
This reverts commit d6f38dd906.
2019-08-20 19:17:32 -07:00
Markus Thömmes d6f38dd906 Remove reflection from generic store code. (#583) 2019-08-20 10:38:31 -07:00
Victor Agababov 12ee58e32c Fix licence to have spaces and comment to match the function (#580) 2019-08-17 16:18:34 -07:00
Victor Agababov 4f3cebba76 This prints better log when CM is loaded. (#548)
Now we just print a struct, which is unparseable.
With this change in hand each field will have a name.

/assign @mattmoor
2019-07-29 15:23:42 -07:00
Victor Agababov 74c5d67ea0 Fix the issues pointed out by staticcheck (#541)
* Fix the issues pointed out by staticcheck

* review fix
2019-07-23 13:13:36 -07:00
mattmoor-sockpuppet 1864f499dc golang format tools (#497)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign @mattmoor
2019-06-27 07:37:08 -07:00
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 35a6f90d16 Sprinkle more ClearAll around to enabled -count=N (#485) 2019-06-23 19:24:02 -07:00
Markus Thömmes b35531d473 Move ExampleKey constant to 'official' package. (#481) 2019-06-23 08:08:57 -07:00
Adriano Cunha c0132d9dde Update OWNERS to use OWNERS_ALIASES (#422) 2019-05-29 20:04:33 -07:00
mattmoor-sockpuppet 34792a92ce golang format tools (#419)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
2019-05-18 10:35:26 -07:00
Adam Harwayne 5548112eb7 Defaulting watcher (#415)
* 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.
2019-05-16 07:09:18 -07:00
Scott Nichols 418e675f88 Moving reconcile/testing from serving to pkg. (#387)
* 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.
2019-04-17 08:19:28 -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 1f153817b2 Extend the resync period for `configmap`. (#115)
Fixes: https://github.com/knative/pkg/issues/114
2018-10-07 04:26:25 -07:00
Dave Protasowski 8fc80deb20 Few changes to the configmap package (#59)
* 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
2018-09-12 07:42:16 -07:00
Matt Moore f8e84c0d02
Copy `pkg/configmap` over from `knative/serving`. (#11) 2018-07-25 14:56:29 -07:00