Commit Graph

136 Commits

Author SHA1 Message Date
Dave Protasowski 16de760af1
split off pprof server that accepts a configmap (#3210) 2025-07-07 03:10:59 +00:00
Dave Protasowski ff153ade25
[controller/observability] adjust metrics reporting for the two lane queue (#3206)
* adjust metrics reporting for the two lane queue

* wire in unfinished work metrics loop
2025-07-06 14:17:59 +00:00
Dave Protasowski e959f44282
[controller] OTel instrumentation (#3201)
* add workqueue metrics interface

* incorporate k8s client-go tool metrics - request latency & result

* drop custom stats reporter

* address linter

* fix boilerplate

* add some bounds checks

* Simplify int parsing and attribute handling

- use strconv.Atoi
- don't set status code attribute if we can't parse it

* add comment
2025-07-04 15:11:57 +00:00
Dave Protasowski 9f3f014388
wire zap into the client-go logger (#3205)
* wire zap into the client-go logger

* fix import & vendor
2025-07-04 14:21:57 +00:00
Dave Protasowski 68cdb02d48
shutdown must be called explicitly since pprof listen is part of the errgroup (#3203) 2025-07-02 18:04:55 +00:00
Dave Protasowski 434d22145d
When shutting down the OTel providers have a ten second timeout. (#3199)
I noticed a misconfigured metrics URL would prevent the process
from quiting because it was trying to flush metrics forever.
2025-06-30 16:58:52 +00:00
Dave Protasowski 7681e80bae
handle no views in the context (#3196) 2025-06-27 00:58:06 +00:00
Dave Protasowski 5abfb107f2
[injection/sharedmain] OTel Support (#3190)
* 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
2025-06-27 00:18:06 +00:00
Dave Protasowski a37a847cd3
drop use of code-generator/generate-groups.sh (#3136)
* drop use of code-generator/generate-groups.sh

* fix script

* single injection invocation
2025-01-17 17:58:04 +00:00
Dave Protasowski ee1db869c7
Update linter config and address lint warnings/failures (#3068)
* fix whitespace linter

* fix usestdlibvars

* fix staticheck

* ignore spancheck warning

* fix linter perfsprint

* fix nolintlint feedback

* fix nilerr lint checks

* fix misspell

* fix mirror lint

* fix intrange linter

* fix gofumpt linter

* fix gosec linter - ignore warning since default min tls version is 1.3

* fix gocritic linter

* fix whitespace

* fix fatcontext linter

* fix errorlint

* fix errname linter

* fix copyloopvar (go1.22) linter

* fix bodyclose linter

* update linter config

* add script to format code

* fix unit test
2024-06-25 14:49:36 +00:00
Dave Protasowski 8535fcc248
gofumpt the repo (#3067)
* gofumpt the repo

* don't prefix numbers with 0 - otherwise they're octal
2024-06-25 07:27:07 +00:00
Prashant Rewar fef5da99bd
Replace all usages of deprecated wait.PollImmediate with wait.PollUntilContextTimeout (#3004)
Signed-off-by: Prashant Rewar <108176843+prashantrewar@users.noreply.github.com>
2024-04-02 14:44:03 +00:00
zhouhaibing089 03bf3de6e2
webhook: add options to disable resource_namespace tag in metrics (#2931)
* 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.
2024-04-01 19:02:21 +00:00
Dave Protasowski 5671699f23
drop the dynamic type (#2750) 2023-05-31 07:39:36 +00:00
Dave Protasowski 52ff2acf87
drop dynamic client wrappers (#2744) 2023-05-19 20:05:15 +00:00
Chmouel Boudjnah bd3cf5174f
Printf log message with the right type when showing port (#2709)
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>
2023-03-29 14:15:01 +00:00
Stavros Kontopoulos 4a80605786
Add health checks (#2671)
* add health checks

* updates

* make probes more flexible

* simplify

* minor

* internal only

* fixes
2023-02-15 23:38:50 +00:00
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
Jonathan Innis 6ce976ce92
Default observability config if nil (#2614) 2022-10-25 20:08:56 +00:00
Kenny Leung b812affa38
Support fetching observability from ctx. (#2610)
* add option to load observability config from ctx

Signed-off-by: Kenny Leung <kleung@chainguard.dev>

* comments and tests

Signed-off-by: Kenny Leung <kleung@chainguard.dev>

* undo

Signed-off-by: Kenny Leung <kleung@chainguard.dev>

* move observability setup logic into function to match logger

Signed-off-by: Kenny Leung <kleung@chainguard.dev>

* fix arg

Signed-off-by: Kenny Leung <kleung@chainguard.dev>

Signed-off-by: Kenny Leung <kleung@chainguard.dev>
2022-10-14 16:45:53 +00:00
Sascha Schwarze 5f66ecf267
Allow configuration of threads-per-controller (#2567) 2022-09-14 15:47:04 +00:00
Matt Moore af54d7330b
Support fetching configs from `ctx`. (#2505)
* 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
2022-05-03 15:25:57 +00:00
Nghia Tran 3a4cc56708
Add configmap informer factory (#2466) 2022-03-15 17:29:59 -07:00
Dave Protasowski 80c511aa34
Wait for reconciler/controllers to return prior to exiting the process (#2437) 2022-02-22 13:12:04 -08:00
Matthias Wessendorf 671e46d0cc
💫 we must use `flags` instead of `pflags`, since this is not working. It seems like pflag.* adds the var to its own flag set, not the one package flag uses, and it doesn't expose the internal flag.Var externally - hence this fix. (#2414)
Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
2022-02-01 08:28:38 -08:00
Dave Protasowski 785eb637f6
switch to klog/v2 (#2386) 2022-01-11 13:02:14 -08:00
Pierangelo Di Pilato d82be484e4
Disable controllers using a command-line flag (#2339)
* 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>
2021-11-16 13:30:53 -08:00
Matt Moore 819d556cda
Allow configuring bounded staleness for dynamic injection. (#2323)
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)`
2021-10-25 08:17:38 -07:00
Dave Protasowski fa2f8f1955
drop fake dynamic client workaround (#2310)
the upstream changes have merged
2021-10-13 08:28:48 -07:00
Matt Moore 9c7fd8e14f
Introduce `NewContext`, deprecate `NewImplFull`. (#2222)
* 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.
2021-08-21 14:00:34 -07:00
Matt Moore 7b5ecbc0e4
Sketch out an alternate way of injecting clients/informers (#2210)
* 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.
2021-08-18 06:52:08 -07:00
Ben Moss 7d1b0f19ef
Add ability to filter objects on injection controller promotion (#2180)
Currently we enqueue every object with no way to filter, which causes
problems for eventing's source controller which reconciles duck CRDs.
2021-07-13 10:55:50 -07:00
Markus Thömmes a1bc850346
Print proper warning logs from API warnings (#2168) 2021-06-24 05:13:45 -07:00
Dave Protasowski eaa823c765
bump k8s to v1.20.7 (#2145)
* 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
2021-06-10 06:56:43 -07:00
Dave Protasowski 47dfdcfaed
consolidate k8s flags to an environment package (#2133)
* 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
2021-05-28 13:30:30 -07:00
Markus Thömmes 4a09d5ef1a
Simplify loading of local kubeconfig in sharedmain (#2079) 2021-04-06 09:48:39 -07:00
Markus Thömmes bbe0bb3eb1
Implement getter machinery to generically fetch all injected clients (#2054) 2021-03-10 09:35:25 -08:00
qibobo 1bbf0a6436
add LabelSelector to InformerFactory so that the informers only list and watch resources with the given labels (#1940)
* 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
2021-01-19 08:21:23 -08:00
Dave Protasowski 75d66b5894
preserve the stable webhook logger names we had before (#1994)
* preserve the stable webhook logger names we had before

* pr feedback
2021-01-18 11:25:21 -08:00
Matt Moore e2d6b4f845
Try splitting configmap package (#1851) 2020-12-22 13:58:04 -08:00
Gallardot 6d905b3f84
expose loggingconfig last error (#1373) 2020-10-29 05:22:34 -07:00
Markus Thömmes 565516e224
Add errorlint and fix all existing issues (#1855) 2020-10-29 01:14:35 -07:00
Markus Thömmes 19995cd8e1
Simplify defaulting and force-default kubeconfig location in tests (#1822) 2020-10-20 07:37:58 -07:00
Scott Nichols fc447086b7
Remove re-definition of kubeconfig from pkg/test (#1820)
* pull flags from injection

* lint

* trim T interface, use flagset
2020-10-19 16:30:58 -07:00
Josh Soref b39d5da935
Spelling (#1797)
* spelling: adopted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: aliased

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: apierrs

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: assignment

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: available

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: coexistence

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: commit

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: conversions

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: creates

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: custom

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: determine

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: different

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: distribution

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: duplicate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: editing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: endpoint

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: environment

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: generate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: implementation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: identified

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ignore

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: indicates

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interface

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interleaved

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: labels

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: label

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: mimic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: namespaced

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: necessary

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: organization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: populatable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: prometheus

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: refer

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: reference

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: repetitive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: response

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: something

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: specable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: spoofing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: synchronized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: this

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trailing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unsupported

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: validation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* chore: reviewdog go header boilerplate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-10-18 14:22:57 -07:00
Scott Nichols 5a5f68637e
use k8s.interface (#1808)
* use k8s.interface

* start to remove test client

* don't use test/KubeClient
2020-10-14 09:51:31 -07:00
Julian Friedman bcdd7509c0
Use default no-op logger for maxprocs (#1801)
Set uses a no-op logger by default, so no need to explicitly pass one.
2020-10-13 01:39:30 -07:00
Victor Agababov a04d64c180
Shush autogomaxproc. (#1800)
* 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
2020-10-12 19:13:30 -07:00
Victor Agababov e3b4e9c229
Step I: move memstats to metrics (#1799)
step II: update deps (serving and eventing)
step: III: remove from shared main

For https://github.com/knative/serving/issues/9787
2020-10-12 15:14:17 -07:00