Commit Graph

51 Commits

Author SHA1 Message Date
Izabela Gomes 53f04b373c
Make minimum TLS version configurable for webhooks (#2721)
* make minimum tls version configurable

* change default min TLS version to 1.3

* change opencensus tls min version to 1.3

* Update env var name

Co-authored-by: Dave Protasowski <dprotaso@gmail.com>

* use webhook options to configure min tls version

* add unit tests for webhook tlsMinVersion option

* Update webhook/env.go

Co-authored-by: Dave Protasowski <dprotaso@gmail.com>

* address feeback

---------

Co-authored-by: Dave Protasowski <dprotaso@gmail.com>
2023-04-14 15:45:51 +00:00
kmahapatra 511b3941d4
potential fix for flakey tlsBackoff (#2702) 2023-03-10 20:46:25 +00:00
kmahapatra 2f55fe00c5
Fix potential slowloris attack (#2682) 2023-02-15 23:47:51 +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 242a3d777f
Fix nil pointer deref in drain when it's reset (#2645)
* fix nil pointer in the drainer when it's reset

* fix linter
2022-11-22 18:56:41 +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
Dave Protasowski 766f70d9cb
fix double close of channel (#2574) 2022-08-17 23:38:48 +00:00
Dave Protasowski d02dcd0b03
allow drainer to be reset (#2572)
* allow drainer to be reset

* ensure Reset can be called multiple times

* add comment explaining the use of the channel

* bump tolerance as it flaked in actions

* update godoc

* fix linting and comments
2022-08-15 21:52:48 +00:00
Evan Anderson ea3c8cb8c9
Fix timeout test on darwin and log dial destination on timeout. (#2510)
* Fix timeout test on darwin and log dial destination on timeout.

* Fix both linux and darwin tests. \o/
2022-05-03 15:26:05 +00:00
Matt Moore 6ec9c1a62f
Fix linting (#2506) 2022-05-02 01:49:56 +00:00
Chris Suszynski 45c37c266b
🐛 `TestDialWithBackoff` work without special environment (#2402)
* Making TestDialWithBackoff work without special environment

* Use listen to force a connection timeout (#1)

* Don't parallelize tests to avoid free port conflicts

Co-authored-by: Evan Anderson <evan.k.anderson@gmail.com>
2022-04-25 21:57:54 +00:00
Kenjiro Nakayama ca82d2bbb2
Add `NewProxyAutoTLSTransport` and `DialTLSWithBackOff` to support TLS proxy (#2479)
* Add `NewProxyAutoTLSTransport` and `DialTLSWithBackOff` to support TLS proxy

Part of: https://github.com/knative/serving/issues/12503
PoC: https://github.com/knative/serving/pull/12815

This patch `NewProxyAutoTLSTransport` which is `NewProxyAutoTransport + TLS config.
Current proxy does not support TLS but it needs for https://github.com/knative/serving/issues/12503.

`DialTLSWithBackOff` is also `DialWithBackOff` + TLS config. It needs
`newH2Transport` which handles HTTP2 with TLS.

* Fix lint

* Fix review comments
2022-04-11 05:32:20 +00:00
Pierangelo Di Pilato a850b9e047
Use t.Setenv instead of os.Setenv in tests (#2454)
Go 1.17 introduced a new handy API for setting env vars scoped for
a single test so we can avoid the hard to read set and reset env
loops.

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-03-10 10:00:48 -08:00
Nader Ziada 6ff7fb8170
add array of user agents for healthcheck in drainer (#2331) 2021-10-29 07:54:51 -07:00
Markus Thömmes 8c88fa2764
Revert "Remove the unused file (#1935)" (#2213)
* Revert "Remove the unused file (#1935)"

This reverts commit e45bbefd1d.

* Add deprecation notice

* Ignore deprecation error of the alias
2021-08-18 03:57:08 -07:00
Scott Nichols 3a2ae6db70
resolve cluster domain using env CLUSTER_DOMAIN as a fallback (#2092) 2021-04-09 13:38:51 -07:00
Victor Agababov 8a8de5fc8c
Move IsKProbe to drainer, since it's the only place it's used (#2038)
* Move IsKProbe to drainer, since it's the only place it's used

And hide it, since no need to export it, if nobody's going to use it.

* more
2021-02-24 19:53:47 -08:00
Victor Agababov 7b5bcc3c0f
Use the constant for UserAgent (#2028)
rather than inline string.
2021-02-18 13:58:03 -08:00
Julian Friedman 6045ed4996
Allow setting DisableCompression in NewAutoTransport (#2007)
Go's http client helpfully adds an "Accept-Encoding: gzip" header if not
already present, and unzips the response if it did so. While this is
often the right thing to do, it is not the right thing to do if we're
reverse proxying since (a) it means we add a header to the request the
client didn't actually ask for (b) it means we end up uncompressing
things in the proxy, which e.g. for activator/QP is not what we want.
2021-02-03 09:17:06 -08:00
Grace Gao 93874f0ea7
Drainer supports customized kubelet probe check (#1977)
* drainer support customized kubelet probe check

* address comment

* address comment
2021-01-07 13:19:36 -08:00
Victor Agababov beabf446d6
Remove the pkg/network/prober since it's moved to networking (#1941)
and all the dependencies are now updated
2020-12-04 17:32:09 -08:00
Victor Agababov e45bbefd1d
Remove the unused file (#1935)
Everyone is actually using the aliased option
2020-12-02 16:53:09 -08:00
Victor Agababov 0fccc54273
Use the same dial with backoff for H2C as we do for HTTP/1.1 (#1915)
Also remove the constant that is not used anywhere.
2020-11-17 14:14:52 -08:00
runzexia ab1a398f66
drainer support kprobe (#1906)
* drainer support kprobe

Signed-off-by: runzexia <root@junwuhui.cn>

* servekprobe

Signed-off-by: runzexia <root@junwuhui.cn>

* use const in test & fix errror log

Signed-off-by: runzexia <root@junwuhui.cn>
2020-11-16 18:02:52 -08:00
Markus Thömmes 565516e224
Add errorlint and fix all existing issues (#1855) 2020-10-29 01:14:35 -07:00
Matt Moore b8a7aae928
Add a list of known-heavy things, check a few places. (#1860) 2020-10-27 16:38:34 -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
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Julian Friedman 6a12c75962
Use http.Transport.Clone in preference to copy-pasting defaults (#1722)
* Use http.Transport.Clone in preference to copy-pasting defaults

Since go 1.13 http.Transport has a Clone method which means we can
inherit and override the defaults rather than re-stating them. This also
makes it clear that we're overriding the http.DefaultTransport default
for ForceAttemptHTTP2, which we are.

* Enable disableKeepAlives
2020-09-21 15:36:36 -07:00
Victor Agababov c46a186449
Various nits around the pkg (#1721) 2020-09-20 14:04:45 -07:00
Victor Agababov ddf2cbe3c1
Various nits around the code (#1719)
* Various nits around the code

* stagger
2020-09-18 16:22:45 -07:00
Victor Agababov f21f66204a
Add a method to set possible maxidle params on the transport. (#1557)
This method is not used anywhere outside pkg right now, so it's a safe change.
This will permit activator to set desired maxidle params and cache more connection for better performance
2020-07-24 14:10:57 -07:00
Victor Agababov bfb6ce8050
Harden the drain tests more (#1525)
* Harden the drain tests more

- introduce synthetic timer that gives us the capability to actually trigger events in the drain itself
- unfortunately we still need time.After calls in the test due to the timing for go routines to finish (they race the default: case and lose).

* comment

* more things

* pfpf

* dudud
2020-07-20 15:50:35 -07:00
Victor Agababov 601c9ff383
Harden and reaarange the test for drain handler (#1521) 2020-07-19 15:15:34 -07:00
Matt Moore e193c4be24
Implement a new shared "Drainer" handler. (#1517)
* Implement a new shared "Drainer" handler.

This implements a new `http.Handler` called `Drainer`, which is intended to wrap some inner `http.Handler` business logic with a new outer handler that can respond to Kubelet probes (successfully until told to "Drain()").

This takes over the webhook's relatively new probe handling and lame duck logic with one key difference.  Previously the webhook waited for a fixed period after SIGTERM before exitting, but the new logic waits for this same grace period AFTER THE LAST REQUEST.  So if the handler keeps getting (non-probe) requests, the timer will continually reset, and once it stops receiving requests for the configured grace period, "Drain()" will return and the webhook will exit.

The goal of this work is to try to better cope with what we believe to be high tail latencies of the API server seeing that a webhook replica is shutting down.

Related: https://github.com/knative/pkg/issues/1509

* Switch to RWLock
2020-07-17 21:25:34 -07:00
Matt Moore 67e9bcf967
Bump the drain timeout (#1501) 2020-07-15 13:08:33 -07:00
Julian Friedman 3aca29a4b4
Remove unused parameter (#1499)
Pretty confusing that the connTimeout parameter isn't actually respected, better to remove it
2020-07-15 10:47:33 -07:00
Victor Agababov 6826f2137c
Reconcile the settings with net/http (#1419)
No need to diverge from the timeout setting.
Also note that maxidle conns are also different from the upstream
2020-06-17 10:50:25 -07:00
Victor Agababov 4419e613c1
Add a constant with default shutdown wait time (#1338)
We have in situ constants, which are not always consistent.
2020-05-15 10:47:01 -07:00
Markus Thömmes c75d324f8b
Code hygiene: Remove unused, use common constructs. (#1320) 2020-05-13 22:20:58 -07:00
Matt Moore b52862b1b3
Implement the K8s lifecycle in webhook. (#1318)
* Implement the K8s lifecycle in webhook.

The webhook never properly implemented the Kubernetes SIGTERM/SIGKILL
lifecycle, and doesn't even really support readiness probes today.  This
change enables folks to use a block like this on their webhook container:

```yaml
        readinessProbe: &probe
          periodSeconds: 1
          httpGet:
            scheme: HTTPS
            port: 8443
            httpHeaders:
            - name: k-kubelet-probe
              value: "webhook"
        livenessProbe: *probe
```

With this, the webhook won't report as `Ready` until a probe has succeeded,
and when the SIGTERM is received, we will start failing probes for a grace
period (so our Endpoint drops) before shutting down the webhook's HTTP Server.

This was uncovered by running the webhook across 10 replicas in Serving with
the "Goose" (https://github.com/knative/pkg/pull/1316) enabled for the e2e
tests.  The failure mode I saw was conversion webhook requests failing across
random tests.

This also moves the Serving probe-detection function into PKG.

* Increase the log level when we start to fail probes

* Wait for go routines to terminate on all paths.
2020-05-09 16:44:45 -07:00
Nghia Tran 2fee85652e
Add elapsed wait time in timeout message. (#1274)
* Add elapsed wait time in timeout message.

* Update network/transports_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update network/transports.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

Co-authored-by: Victor Agababov <vagababov@gmail.com>
2020-05-01 18:46:43 -07:00
Nghia Tran d980c08659
Expose NewBackoffDialer to allow customizing backoff configuration. (#1270) 2020-04-30 17:59:42 -07:00
Nghia Tran 3d369cddd5
Expose the `dialWithBackOff` util. (#1267) 2020-04-30 12:01:42 -07:00
Markus Thömmes 1b903ad8cc
Fix malformed license headers. (#1258) 2020-04-29 08:38:42 -07:00
Victor Agababov 5ba6c1d101
Change %v to %w in errors and other nits (#1252)
* Change %v to %w in errors and other nits
Other are things I noticed when fixing the main %v->%w conversion

* fold
2020-04-27 15:04:51 -07:00
Nghia Tran 79d67498c2 Clean up other test to use suggestions of #984 (#986)
* Clean up other test to use suggestions of #984

* Properly capitalize error message.
2020-01-09 15:55:55 -08:00
Nghia Tran bd9fe634a9 Add WithPath option to set the probe path. (#984)
* Add WithPath option to set the probe path.

* Fix PR feedbacks.

* Remove unused struct fields.

* Fix test error message.
2020-01-09 14:16:55 -08:00
Victor Agababov 37bd04dc3e Move generic packages from serving to pkg. (#927)
* Move generic packages from serving to pkg.

I was asked to move this to do some re-use in Eventing.

/cc @chizh
/assign mattmoor @tcnghia

* fix the compile error
2019-12-06 17:57:40 -08:00