Commit Graph

95 Commits

Author SHA1 Message Date
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
Pierangelo Di Pilato 1a4c99a865
Allow override QPS and Burst via flag (#1778)
* Allow override QPS and Burst via flag.

Add `--kube-api-qps` and `--kube-api-burst` command-line flags
to control client QPS and Burst respectively.

The default value is set to 0 to keep backward compatibility.

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>

* Inline validation functions

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2020-10-07 10:06:21 -07:00
Scott Nichols 46761ba7c3
Put EnableInjectionOrDie back on the main path (#1772)
* put EnableInjectionOrDie back on the main path

* nil check pointer type

* move enable injeciton out of sharedmain

* lint

* nit picking fmt....

* add documentation

* feedback cleanup

* injection.GetRESTConfig

* redirect code that moved:
2020-10-06 16:58:20 -07:00
Victor Agababov 247841408e
Apply the cleanup to the pkg (#1776)
* Apply the cleanup to the pkg

This is probably the final iteration of my cleanup application.

* codegen

* one more try
2020-10-05 21:41:20 -07:00
Zhongduo Lin (Jimmy) ea7374e811
Delay start of informers in sharedmain (#1767)
The EnableInjectionOrDie starts informers immedidately in a go
routine, which changes the order of informer start and controller
setup. As a result setting resync period to informer handler will
be ignored as the informer is already started. Though this will
likely affect more components, changing the EnableInjectionOrDie
function will break the API, so this is a temporary solution to
fix all the controllers depending on sharedmain.
2020-10-03 10:57:33 -07:00
Victor Agababov 1e373a9e5d
take 2 (#1755) 2020-09-29 14:10:29 -07:00
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Victor Agababov ec3e2dd4bd
Inject the pod name into logger when provided in the envvars (#1714)
Deployments that are H(P)A need to provide the pod name envvar via downward api.
Activator and QP are already doing this.
2020-09-17 14:47:45 -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
Markus Thömmes d21012af55
Deprecate --master flag in favor of --server. (#1693)
* Deprecate --master flag in favor of --server.

* Actually just drop the flag altogether.
2020-09-09 09:57:50 -07:00
chen zhengwei 2fee224e95
Fix some comments in main.go (#1685) 2020-09-03 20:57:31 -07:00
Scott Nichols 2335e4d84a
Adding an easy entry method next to sharedmain to allow for utilities to leverage injection without being a controller. (#1658) 2020-08-28 13:08:07 -07:00
Adam Harwayne 530eac8757
Inject the config into the context. (#1610) 2020-08-11 16:18:05 -07:00
Julian Friedman 095ff27da6
Automatically set GOMAXPROCS using automaxprocs library (#1585) 2020-08-10 02:00:30 -07:00
Matt Moore 6f19c52bf1
[master] Format markdown (#1547)
Produced via:
  `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)`
/assign n3wscott vagababov
/cc n3wscott vagababov
2020-07-23 08:00:57 -07:00
Scott Nichols ae9c3f7fa8
Refactor the genreconciler code to pull state out (#1544)
* Refactor the genreconciler code to pull state out

* don't generate the stubs

* fix indent
2020-07-22 23:02:57 -07:00
Ville Aikas 1127f59d7b
kube already gives us this, do not double log http (#1542) 2020-07-22 10:13:57 -07:00
Victor Agababov acd3f31714
nits (#1529) 2020-07-20 18:44:35 -07:00
Matt Moore 931d1210f1
Enable components to get debug logging from our rest transports. (#1515) 2020-07-17 13:54:33 -07:00
Matt Moore a9ea699c70
Make MainWithConfig respect user-provided overrides. (#1513) 2020-07-17 10:09:34 -07:00
Matt Moore a81727701f
Enable leader election by default. (#1476)
* Enable HA by default.

This consolidates the core of sharedmain around the new leaderelection logic, which will now be **enabled by default**.

This can now be disabled with `--disable-ha` or by passing `sharedmain.WithHADisabled(ctx)` to `sharedmain.MainWithConfig`.

* vagababov comments, build failure

* Open an issue for enabledComponents removal.

* Move the configmap watcher startup.

This race was uncovered by the chaos duck on knative/serving!  When we have enabled a feature flag, e.g. multi-container, and the webhook pods are restarted, there is a brief window where the webhook is up and healthy before the configmaps have synchronized and the new webhook pod realizes the feature is enabled.

* Drop the import alias
2020-07-13 12:43:18 -07:00
Matt Moore 27389b2fa0
Enable use of StatefulSet in sharedmain. (#1451)
This change allows for (just webhook for now) controllers going through sharedmain to opt into Yanwei's logic by setting several environment variables.

I was able to pull this change in downstream and change the webhook to use a StatefulSet with the following environment:
```
+        # These settings are used for statefulset-based
+        # leader selection.
+        - name: CONTROLLER_ORDINAL
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.name
+        - name: STATEFUL_SERVICE_NAME
+          value: "webhook"
```

Running the above with 10 replicas and 10 buckets worked as intended (keys were evenly distributed across the replicas).
2020-06-27 09:29:28 -07:00
Weston Haught bce16cf786
remove krshapedlogic tag, this is default now (#1442) 2020-06-26 11:28:28 -07:00
Matt Moore b6a13e2894
Implement the third wave of per-reconciler leaderelection. (#1303)
This lets downstream components enable leaderelection on `WebhookMain*`-based components.

Detailed design: https://docs.google.com/document/d/1i_QHjQO2T3SNv49xjZLWlivcc0UvZN1Tbw2NKxThkyM/edit#
Issue: https://github.com/knative/pkg/issues/1181
2020-06-19 11:26:25 -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
Weston Haught d5043a4332
Groom conditions LastTransitionTime in postprocess (#1403)
* Groom conditions time

* unit test

* unit test fix

* make readme accurate
2020-06-18 11:46:25 -07:00
Weston Haught b559da3646
Generate common logic for krshaped resources (#1311)
* generate krshaped logic

* add logic to the tag

* Update injection/README.md

Co-authored-by: Matt Moore <mattmoor@vmware.com>

* move var to reconciler

Co-authored-by: Matt Moore <mattmoor@vmware.com>
2020-05-08 10:00:45 -07:00
Victor Agababov 66f1d63f10
Fix logging around pkg (#1310)
- use more performant functions (mostly remove formatters were possible)
- move zap.Error() to the call site, rather than creating a new sugared logger with a key attached (not cheap)
- fix *w usages where the key was not provided.
2020-05-07 15:00:45 -07:00
Markus Thömmes 22b9613719
Inject config into controller context. (#1253)
This makes the config used to start all the clients available on the context starting the controllers. That enables us to use that config to create secondary clients in the controllers with the same config.
2020-04-28 06:35:51 -07:00
Matt Moore 7b6e21a57a
Change StartAll to take context. (#1247)
* Change StartAll to take context.

This has bugged me since we started using `ctx`, which containers a `stopCh` of sorts as `Done()`.  This is somewhat for consistency, but by using `ctx` explicitly we enable ourselves to take advantage of more contextual information.

I did a quick scan of call sites and the good news is that the `sharedmain` change should be the place through which the vast majority of calls occur, however, the one outlier here is the KPA which calls this manually.  I will stage a PR to manually import pkg into serving to fix this once this lands.

* Add a Run shim for back-compat
2020-04-25 16:21:49 -07:00
Matt Moore 3b7a675e73
Revert "Use loggers when emitting count messages (#1239)" (#1248)
This reverts commit c13917eb25.
2020-04-25 15:48:50 -07:00
Matt Moore 2d0c254ac6
Incorporate component name into ComponentConfig. (#1246) 2020-04-25 10:15:49 -07:00
Matthew Broomfield c13917eb25
Use loggers when emitting count messages (#1239)
Fixes #1225
2020-04-24 10:55:50 -07:00
Markus Thömmes 8aa4090a02
Release leader election lock as soon as we exit. (#1229) 2020-04-21 13:44:35 -07:00
Kenjiro Nakayama 08b31df9e6
Retry to get logging configmap when failed (#1189)
* Retry to get logging configmap when failed

When deploying pods with Istio sidecar, it takes a few seconds until
network is configured. In fact, Serving's system pods always fail when
Istio sidecar is enbled.

To fix it, this patch changes to retry to get logging configmap for 5
seconds.

* Add IsNotFound error check

* Remove if error condition
2020-04-04 11:17:18 -07:00
Matt Moore e2ee5bed78
Start the webhook before informers sync. (#1180)
* Start the webhook before informers sync.

Some webhooks (e.g. conversion) are required to list resources, so by delaying those until after informers have synced, we create a deadlock when they run in the same process.  This change has two key parts:
1. Start the webhook immediately when our process starts, and issue a callback from sharedmain when the informers have synced.
2. Block `Admit` calls until informers have synced (all conversions are exempt), unless they have been designated by implementing `webhook.StatelessAdmissionController`.

Our built-in admission controllers (defaulting, validation, configmap validation) have all been marked as stateless, the main case where we want to block `Admit` calls is when we require the informer to have synchronized to populate indices for Bindings.

* Add missing err declaration
2020-03-30 18:14:50 -07:00
Matt Moore 1893541a0f
Scope the webhook secret informers to the system namespace. (#1158) 2020-03-12 18:29:29 -07:00
Knative Prow Robot acb0b0386b
Fix crash looping when leader election config doesn't exist (#1142) 2020-03-05 12:50:25 -08:00
Knative Prow Robot 312b1be35c
Format markdown (#1139)
Produced via:
  `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github)`
/assign n3wscott vagababov
/cc n3wscott vagababov
2020-03-04 10:55:54 -08:00
Andrew Su 340837e654
Fix typos (#1138)
- implementor -> implementer
- implemnted -> implemented
- "Codify" the kind tag.
2020-03-03 09:59:53 -08:00
Paul Morie ca35cb8791
add leader election support to sharedmain (#1019)
* Add leader election config and to sharedmain

* Add new dependencies

* Extract method for RunLeaderElected

* Make leader election config constructor validate

* Rename leader election files

* Always start profiling server whether component has LE lock or not

* Fix entering unreachable section when leader election is disabled

* Address PR feedback
2020-02-26 14:40:50 -08:00
Evan Anderson 7af3fab62c
Roll forward #1045 (#1109)
* Revert "Add support for client TLS to pkg/metrics (#1045)"

This reverts commit 945b556708.

* Roll forward "Add support for client TLS to pkg/metrics (#1045)"

Adds support for client TLS certs for opencensus export

* Switch sharedmain to only pass a getter rather than an all-namespace lister.

* Add a TODO about using a cached copy if this generates undue load

* Update deps per build failure.

* Refactor per @anniefu suggestion
2020-02-25 11:42:51 -08:00