Commit Graph

38 Commits

Author SHA1 Message Date
Paweł Banaszewski e21a3f224f Added simple tests and changed lazyVerb String method to the same as httplog uses
Kubernetes-commit: b31339231314ae8a72481cfda45539e35097450a
2022-11-07 17:13:26 +00:00
Tim Allclair bd7c7f52c2 Consolidate AuditContext
Kubernetes-commit: f1d684b7b60b39b7dc1eb4156307c593f0ba74e1
2022-07-12 11:53:57 -07:00
Maciej Wyrzuc bfac2bc2b9 do not print status stack in case of timeout from timeout handler
Kubernetes-commit: 886648b820c10011350e7435a3105fd7d329c3c5
2022-09-10 10:13:11 +00:00
Artur Żyliński e34c622d49 Add audit-id to storage traces
Refactor GetAuditIDTruncated to use context instead of request

Kubernetes-commit: b1e12b01b6c578da3eb593805b48e9d4a69efe54
2022-06-20 17:09:32 +02:00
Patrick Ohly ec795ae204 avoid klog Info calls without verbosity
In the following code pattern, the log message will get logged with v=0 in JSON
output although conceptually it has a higher verbosity:

   if klog.V(5).Enabled() {
       klog.Info("hello world")
   }

Having the actual verbosity in the JSON output is relevant, for example for
filtering out only the important info messages. The solution is to use
klog.V(5).Info or something similar.

Whether the outer if is necessary at all depends on how complex the parameters
are. The return value of klog.V can be captured in a variable and be used
multiple times to avoid the overhead for that function call and to avoid
repeating the verbosity level.

Kubernetes-commit: 9eaa2dc554e0c3d4485d4c916dfdbc2f517db2e0
2021-12-11 12:10:21 +01:00
Ben Luddy 681941e62b Don't bypass ResponseWriter wrappers for apiserver healthz errors.
The effective layering of ResponseWriters is today, from outside to
inside, httplog(timeout(audit(metrics(original)))). From
6e3fd91e1aa3259d7bd67e0a65693e346ade347d, calls to http.Error in the
apiserver's root healthz handler use an unwrapped ResponseWriter --
effectively timeout(audit(metrics(original))) -- to avoid logging
stack traces for those requests.

From 0d50c969c587c8a6c16e0962118305ac652c5a6b, the same call to
http.Error receives a completely-unwrapped ResponseWriter. This has
the effect of bypassing not only the httplog wrapper, but also
timeout, audit, and metrics. The timeout wrapper defends against
the (disallowed) use of underyling ResponseWriter after the completion
of its request's ServeHTTP call. Since that defensive behavior is
being bypassed, it's possible for the root healthz handler to panic
when health probes time out.

Instead of continuing to use a wrapper-aware means of disabling stack
traces, this commit adds a new function to httplog that allows
customization of the stack trace logging predicate on a per-request
basis.

Kubernetes-commit: ff849fe8b688606d5173d5ee0213a96cffae23c0
2021-12-14 16:23:36 -05:00
Marcel Zięba 35731724b9 Fix race condition in logging when request times out
Kubernetes-commit: 269431c9c894d70a4412bb79d96822d842725cb0
2021-10-18 14:48:47 +00:00
Abu Kashem a1d74a4e54 remove httplog filter from handler chain when klog.v < 3
Kubernetes-commit: b05d805fd3337d3e3ea6a195883a4eb9c66a7b8a
2021-08-24 14:29:49 -04:00
Abu Kashem 6013da2b94 apiserver: wrap ResponseWriter using abstraction
Kubernetes-commit: 0d50c969c587c8a6c16e0962118305ac652c5a6b
2021-09-20 11:21:56 -04:00
Abu Kashem cafef859a7 apiserver: add key/value pair to httplog
Kubernetes-commit: bdedd2a4c16487e075db45e778c9e47ddd57448f
2021-08-19 17:07:24 -04:00
Daniel Smith a08d7d5ddf Make logged verbs match metric-reported verbs
Kubernetes-commit: 54fde5d119f8bb55aec18cb5aef01b6ea58dfea0
2021-06-16 17:08:54 -07:00
AbdulBasitAlvi da18259e5b hotfix(staging_apiserver_pkg_httplog): restore depth to log calls
/kind bug

This PR adds depth to logging which was removed when migrating to structured logging in the file

Ref #102353

```release-note
NONE
```

```docs

```

Kubernetes-commit: 5d4c1162b944ff34374313103d0555ac0b334a1d
2021-05-30 01:42:54 +02:00
Marcel Zięba 489e43cad9 Add logging of filters to api calls logs
Kubernetes-commit: 7e01b7260ac5cc20c1fc236cae220857726dc330
2021-05-17 11:52:33 +00:00
Chok Yip Lau f0cd8bd9bf Fix staticcheck on vendor/k8s.io/apiserver/pkg/server/httplog
Kubernetes-commit: eaaa803d48e8d78e5ad6d49324169e9d775ed7bc
2021-01-08 17:57:20 -05:00
Abu Kashem bb69e234a6 apiserver: improve correlation by using the audit ID
- when we forward the request to the aggregated server, set the audit
  ID in the new request header. This allows audit logs from aggregated
  apiservers to be correlated with the kube-apiserver.
- use the audit ID in the current tracer
- use the audit ID in httplog
- when a request panics, log an error with the audit ID.

Kubernetes-commit: b607ca1bf3e1cf6152c446ea61ac7fdd9014e1f1
2021-03-02 19:27:43 -05:00
Abu Kashem 1e7338b1ea use request received timestamp in httplog
Kubernetes-commit: 71199664be6d26e435a78566818379ff43110352
2021-03-02 18:05:51 -05:00
Marek Siarkowicz 5587d5c607 Improve performance of http access logs
Fixes:
* Don't call LogArgs if log will not be written due low verbosity
* Create separate slice for hijacked to avoid append on main path
* Shorten log message as this log is to common to be verbose

name           old time/op    new time/op    delta
WithLogging-4    4.95µs ± 3%    3.52µs ± 1%  -28.80%  (p=0.000 n=10+8)

name           old alloc/op   new alloc/op   delta
WithLogging-4    2.93kB ± 0%    1.22kB ± 0%  -58.45%  (p=0.000 n=10+9)

name           old allocs/op  new allocs/op  delta
WithLogging-4      32.0 ± 0%      20.0 ± 0%  -37.50%  (p=0.000 n=10+10)

Kubernetes-commit: 303e1c19225149868d735b5c876d8ca9d3e1b5c9
2020-06-23 13:56:01 +02:00
AkashSarda e0d29c69be Migrate API server logs to Structured logging framewrok
Kubernetes-commit: af60e7b34d59d635740880a03e7e2587ec9ba041
2020-06-17 21:06:35 +00:00
Davanum Srinivas 5879417a28 switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Daniel Smith 09aa6a7555 make request logs greppable
Kubernetes-commit: e4a18dee73547e29eb1572af6da29364d64df2ab
2020-01-14 10:19:35 -08:00
Jianfei Bai f9ce5c1c1d Move added info and status stack trace to the end of line.
Kubernetes-commit: 5743cffd5d54e280a3dcaba8e690590a2167f71d
2019-12-13 10:53:04 +08:00
Dr. Stefan Schimanski c4286f7b60 apiserver: store httplog in context
Kubernetes-commit: e848eaa566b750ad5e5fd26a64eecfc883f936f3
2019-06-14 13:09:13 +02:00
Ted Yu 4af313ef61 Use map to check whether stack trace is needed
Signed-off-by: Ted Yu <yute@vmware.com>

Kubernetes-commit: 85fc0898556d5c0c4b80920bac62842bfc97d763
2019-05-08 14:31:47 -07:00
Davanum Srinivas 2710b17b80 Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
xuzhonghu ea67b81061 use request.UserAgent()
Kubernetes-commit: 82003bd9acfd15011a205d938f622d9a9efcaf31
2018-07-03 16:56:15 +08:00
Zhonghu Xu 42319038f6 simplify httplog.LogOf
Kubernetes-commit: 1c5a0218ed6c1b283eb6d99d54a865d2ec99ec4b
2018-07-02 11:47:42 +08:00
Avesh Agarwal cc0f17a725 Fix to avoid REST API calls at log level 2.
Kubernetes-commit: 6a5c248bbb6a06a0c171f7171d3583cd006350db
2017-02-03 12:47:03 -05:00
Kubernetes Publisher 627fa76a8b sync: initially remove files BUILD */BUILD BUILD.bazel */BUILD.bazel 2018-03-15 09:38:17 +00:00
Jeff Grafton 1ab12b2dc8 Autogenerated: hack/update-bazel.sh
Kubernetes-commit: ef56a8d6bb3800ab7803713eafc4191e8202ad6e
2018-02-16 13:43:01 -08:00
Jeff Grafton c8a97ee31a Autogenerate BUILD files
Kubernetes-commit: efee0704c60a2ee3049268a41535aaee7f661f6c
2017-12-23 13:06:26 -08:00
Jeff Grafton f4dbe23125 update BUILD files
Kubernetes-commit: aee5f457dbfd70c2d15c33e392dce6a3ca710116
2017-10-12 13:52:10 -07:00
Jeff Grafton 6c539a43c6 Use buildozer to delete licenses() rules except under third_party/
Kubernetes-commit: a7f49c906df816123e7d4ccbd4cebab411519465
2017-08-29 13:15:24 +00:00
Jeff Grafton 6caa2933ae Use buildozer to remove deprecated automanaged tags
Kubernetes-commit: 33276f06be5e872bf53ca62a095fcf0a6b6c11a8
2017-08-29 13:15:24 +00:00
Jeff Grafton 44942b068a Run hack/update-bazel.sh to generate BUILD files
Kubernetes-commit: 3579017b865ddbc5449d6bba87346f086e4b93ff
2017-08-29 13:13:51 +00:00
deads2k 0ee5e1006e remove dead log handler and increase verbosity
Kubernetes-commit: 9e263af7dacafe590cc585f0c37123310a2a9a4f
2017-08-29 13:13:06 +00:00
Mike Danese 2aab760a2a autogenerated
Kubernetes-commit: a05c3c0efdc5822049e34b1a5a1ee259c5fb1906
2017-04-15 20:35:23 +00:00
Dr. Stefan Schimanski 855c38d53e genericapiserver: fix imports 2017-01-19 10:27:27 -05:00
Dr. Stefan Schimanski dc90e9a003 genericapiserver: move packages
Towards a sane k8s.io/apiserver package structure.
2017-01-19 10:27:27 -05:00