* sharedmain changes
* go mod
* vendor
* address PR feedback
* bump semconv to v1.34.0
* drop globalviews in favour of sharedmain option
Given Views in OTel are overrides for end-users this should really be a
sharedmain option instead of a dedicated package. In OpenCensus views
were required but in OTel they are not
* PR feedback
* panic if we drift semconv version from the SDK
* fix testing import
* bump runtime instrumentation
* gofumpt file
* don't set enabled=false on init since the profiling Handler already does it
* webhook: add options to disable resource_namespace tag in metrics
To add some context, historically, `resource_name` was removed from this
tag list due to its high potential of causing high metrics cardinality.
See [knative/pkg#1464][1] for more information.
While that's great, but it might not be sufficient for large scale use
cases where namespaces can be super dynamic (with generateName, too) or
grows fase enough. There is an issue report from
[tektoncd/pipeline#3171][2] which talks about this.
This proposal makes it possible to disable `resource_namespace` tag via
an option function. The default behavior is not changed, so no user
impact if any of existing users rely on this tag. There is no API
contract change either due to the beauty of variadic functions.
Now downstream projects can consume this by override `StatsReporter` in
webhook context options with their own preference. As a caveat here, if
downstream project does choose to override `StatsReporter`, the default
`ReportMetrics` function shouldn't be called by default as they may now
have a different set of tag keys to report. As such, this function is
only called if the default `StatsReporter` is used.
[1]: https://github.com/knative/pkg/pull/1464
[2]: https://github.com/tektoncd/pipeline/issues/3171
* webhook: add StatsReporterOptions in webhook.Options
There are two ways to customize StatsReporter:
1. Use a whole new StatsReporter implementation.
1. Or pass Option funcs to customize the default StatsReporter.
Option 1 is less practical at this time due to the metrics registration
conflict. `webhook.RegisterMetrics()` is called regardless which
StatsReporter implementation is used (which is a problem by itself). The
second option is more practical since it works well without dealing with
metrics conflicts.
The `webhook.Option` in particular allows people to discard certain
metrics tags.
This will show up like this in the log
13:35:17 Probes server listening on port %!s(int=8080)
with proper type casted it will look a bit better !
Signed-off-by: Chmouel Boudjnah <chmouel@chmouel.com>
* Support fetching configs from `ctx`.
This enables callers of `sharedmain` to infuse `ctx` with a `logging.Config` or `leaderelection.Config` instead of relying on the API server for it.
* Move context methods into appropriate packages, drop stutter
* Disable controllers using a flag
This patch allows disabling controllers when using a new `Main` function
called `MainNamed` which takes a list of `NamedControllerConstructor`.
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Apply reviews
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Add comments, split filter and conversion
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* Allocate len(ctors)
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
* to disable -> disabling
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
Unfortunately the lister interfaces didn't plumb through `ctx` so
this is slightly more complex than I'd have liked. Instead of
threading the `resourceVersion` (bounded-staleness) through `ctx`
it is stored on the lister implementation.
It is seeded with `injection.WithResourceVersion` (ideally this
would have been all we needed, w/o state), and this state can be
updated by calling `SetResourceVersion`.
The stored `resourceVersion` is passed via `FooOptions` to `Get`
and `List` calls.
Fixes: a long-standing `TODO(mattmoor)`
* Introduce `NewContext`, deprecate `NewImplFull`.
Our generated `NewImpl` methods have long taken `context.Context`, but despite many iterations the forms we expose from our `controller` package never have. This change contains several elements:
1. Expose a new `NewContext` method that takes `context.Context` in addition to the current `NewImplFull` signature.
2. Call `NewContext` instead of the deprecated `NewImpl` from our generated controller code.
3. Call `NewContext` from all our webhook reconcilers.
* Add a Tracker to controller.Impl to cut down on downstream boilerplate.
* This commit contains the actual changes to support dynamic client injection.
* Incorporate n3wscott review nits
* This includes the code-generation for the dynamic client-based injection.
This also includes a number of manually created files of the form `*_expansion.go`, which are needed to satisfy some of the Kubernetes manual type "expansions". At present, these are all simply `panic("NYI")`, but may become more than that in the future.
* bump k8s deps to v1.20.7
* fix migrator test pkg
* dynamicclient now expects List types to be declare either via a scheme or manually
* fix error message comparison
* drop excess vendor licenses
* Using the injection fake dynamic client will preserve pre-1.20 behaviour
This is accomplished by preprocessing the scheme/fixtures and declaring
a custom scheme were we map our types & lists to unstructured.* types
* revert webhook factory changes
* ensure objects to the dynamic client are unstructured
* seed the default dynamic client with k8s scheme
* include duckv1 types in default fake dynamic client scheme
* use default k8s scheme
looks like eventing adds to this scheme but we should import the correct one vs the one from the fake package
* drop duckv1 from default scheme
* set APIVersion/Kind if empty
* refactor ToUnstructured helper to a new package
* consolidate k8s flags to an environment package
* add copyright
* fix comment style
* use go1.16 in workflows so downstream tests work
* Deprecate GetRESTConfig and do not remove
* update copyright date
* add filtered InformerFactory and informers which only list and watch resources with the given labels
* rename to RegisterFilteredInformers
* generated files
* typo
* update per comments
* rename file
* rm old files
* Shush autogomaxproc.
I am not as sure about this change, but those logs are not following the standard formt
and given we need to inject the logger in init() makes this next to impossible.
Corollary, is that we set cpu limits on all our binaries, except QP, so it only mattered there
since otherwise the package logs nothing.
* m