Commit Graph

67 Commits

Author SHA1 Message Date
Dave Protasowski 8532ae0645
update OWNERS files to use teams with active members (#2672)
* update OWNERS files to use teams with active members

* add eventing-wg leads as approvers to /apis
2023-02-06 16:58:45 +00:00
Dave Protasowski 44d1d7d978
Go1.19 changes (#2631)
* run goimports

* ignore linter errors for now

* fix boilerplate
2022-11-03 22:34:05 +00:00
Dave Protasowski 3d24b8416b
fix lint warnings (#2589)
* resolve deprecation warnings

* drop use of ioutil

* fix license

* run hack/update-codegen.sh
2022-09-12 18:15:45 +00:00
Pierangelo Di Pilato 3c4dec9b9f
Take pointer to map in AsOptionalMap for consistency (#2460)
* Take pointer to map in AsOptionalMap for consistency

- Other `As*` functions take pointers.
- It avoids having to initialize the map passed to the function

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>

* Remove double pointer

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>

* AsOptionalMap -> CollectMapEntriesWithPrefix

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-03-14 09:45:18 -07:00
Pierangelo Di Pilato fe26417344
Allow overriding lease name for a reconciler (#2435)
Add a `map-lease-prefix` prefix for config keys for
`config-leader-election` that is a map from a generated lease prefix
to a new prefix:

```yaml
map-lease-prefix.<component>.<package>.<reconciler_type_name>: <new_prefix>
map-lease-prefix.<component-x>.<package-x>.<reconciler_type_name-x>: <new_prefix>
```

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-02-28 11:55:09 -08:00
Pierangelo Di Pilato 7f59158fb3
Add ConfigMap parsing for int16 (#2365)
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
2021-11-29 06:10:04 -08:00
jwcesign a94f5f07b3
Trim the space in configmap/registriesSkippingTagResolving's url. (#2231)
* Trim space of confguration registriesSkippingTagResolving's url, delete
head's and tail's space

* Add test case for trim spaces
2021-08-24 05:08:23 -07:00
Matt Moore 3bed4dcf17
Make the configmap update logging Debugf (#2226) 2021-08-22 13:30:34 -07:00
Markus Thömmes 980a33719a
Fix revive related linting issues (#2131) 2021-05-26 01:10:28 -07:00
Evan Anderson 728bc4ad4e
Update OWNERS_ALIASES to match autogen in community (#2078) 2021-04-08 07:42:51 -07:00
Victor Agababov b558677ab0
Use TB interface, rather than T pointer when doing test stuff (#2064)
* Use TB interface, rather than T pointer when doing test stuff

this will permit passing testing.B everywhere too!

/assign @markusthoemmes @dprotaso

* rm-todo
2021-03-23 13:29:17 -07:00
Christie Wilson 2bc944bb68
Fix race: Make informed watcher start wait for Add event 🏎️ (#2036)
* Fix race: Make informed watcher start wait for Add event 🏎️

When using the informed watcher to watch a config map, previously add
events were being processed in a goroutine with no syncrhonization
making it so that code may try to access the values backed by the
configmaps before they are initialized.

This commit makes it so that the Start method of the informer will wait
for the add event to occur at least once for all config maps it is
watching.

This commit also undoes the workaround added in #1929 which was working
around the race condition identified in #1907 (and in
https://github.com/tektoncd/pipeline/issues/3720). This means that if
the synchronization was removed, the impacted test would start flaking
again. If we wanted it to reliably fail in that case, we could introduce
a sleep in the callback but that doesn't seem worth it.

I also tested this change by manually patching the changes into my
clone of tektoncd/pipeline and following the repro steps at
https://github.com/tektoncd/pipeline/issues/2815#issuecomment-733207368
Before the change I can reproduce the issue, and after the change, I
can't! :D

Fixes #1960

* Make synced callback and named wait group private 🕵️

These utility objects don't really make sense to expose as part of the
informed watcher package and are only used by the informed watcher.
Writing tests for unexported code makes me a bit :( but hopefully these
will get moved to some other package one day. And there's really no
reason to expose these to users of knative/pkg at the moment.
2021-03-02 11:58:15 -08:00
Matt Moore e2d6b4f845
Try splitting configmap package (#1851) 2020-12-22 13:58:04 -08:00
Markus Thömmes 7226f4f447
Unify usage of YAML libraries (#1971)
* Replace ghodss/yaml with sigs.k8s.io/yaml

* Replace unnecessary usage of gopkg.in/yaml too
2020-12-17 07:24:02 -08:00
Dave Protasowski f164e757b1
fixes TestInformedWatcher flake (#1929)
* fixes TestInformedWatcher flake

* use wait pkg
2020-11-26 10:40:35 -08:00
Markus Thömmes 565516e224
Add errorlint and fix all existing issues (#1855) 2020-10-29 01:14:35 -07:00
runzexia 20310686ae
configmap parse int (#1777)
* configmap parse int

Signed-off-by: RyderXia <ryder.xia@sap.com>

* Update configmap/parse.go

Co-authored-by: Markus Thömmes <markusthoemmes@me.com>

Co-authored-by: Markus Thömmes <markusthoemmes@me.com>
2020-10-28 04:58:34 -07:00
Markus Thömmes 385c8b9c0e
Fix nolint warnings and adhere to best practices (#1823) 2020-10-20 09:33:59 -07:00
Julian Friedman 08db0e8fd7
Add suggested fix when checksums dont match (#1812) 2020-10-15 06:15:57 -07:00
Francesco Guardiani 9e655c6b02
Port tracing setup code to pkg (#1807)
* Port setup code to pkg

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Moved prebuilt setups in config

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Removed maybe useless code

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Removed hardcoded configs and renamed defaultConfig() to NoopConfig()

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Applied suggestions

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Applied suggestions

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-10-14 11:45:31 -07:00
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Victor Agababov 236c084e37
Fix the racy test. (#1753)
The problem is that the original test presumed the 2 other backgound calls have
finished already.
Which is not really true always.
E.g. here: https://github.com/knative/pkg/pull/1746/checks?check_run_id=1179720602

Also other nits around the file
2020-09-28 22:20:28 -07:00
Markus Thömmes e4ecf702a3
Apply gosec checks to the codebase, except tests. (#1725)
* Apply gosec checks to the codebase, except tests.

* Fix YAML whitespace.

* Tune back file mode change and add a comment.
2020-09-22 08:55:40 -07:00
Zbynek Roubalik 2d4efecc6b
bump to k8s 1.18 (#1428)
* bump to k8s 1.18.8

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* plumbing ctx through

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* add more ctx plumbing

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* ctx WithCancel()

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-09-11 07:54:00 -07:00
Victor Agababov 34838c4559
Remove all ClearAll calls from pkg UTs (#1654)
We need this in order to deprecate the function.
Serving is already free of those.
2020-08-27 13:13:07 -07:00
Victor Agababov 2465d13e72
Switch bool parsing to the real parser (#1651)
* Switch bool parsing to the real parser

We parse junk as false, but that's not really corect

* fix comment

* 2
2020-08-25 18:35:06 -07:00
Dave Protasowski 20e1d27cd6
add helper to parse namespaced names (#1600)
* add helper to parse namespaced names

* address feedback

* drop comment & re-order checks

* address vagababov feedback

* add optional method and include note about namespace being required
2020-08-10 15:00:05 -07:00
Yanwei Guo 2ca3559ae9
delete (#1589) 2020-08-07 09:29:29 -07:00
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