Skip to content

Commit 0b15e37

Browse files
committed
Add tldr sections to proposal
1 parent 0c389f9 commit 0b15e37

File tree

1 file changed

+72
-26
lines changed
  • keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components

1 file changed

+72
-26
lines changed

keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components/README.md

Lines changed: 72 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,20 @@ best practices.
113113

114114
## Proposal
115115

116-
I propose that Kubernetes core components (kube-apiserver, kube-scheduler,
117-
kube-controller-manager, kubelet) should drop flags that extend
118-
logging over events streams or klog specific features. This change should be
116+
I propose to remove klog specific feature flags in Kubernetes core components
117+
(kube-apiserver, kube-scheduler, kube-controller-manager, kubelet) and set them
118+
to agreed good defaults. From klog flags we would remove all flags besides "-v"
119+
and "-vmodule". With removal of flags to route logs based on type we want to
120+
change the default routing that will work as better default. Changing the
121+
defaults will be done in via multi release process, that will introduce some
122+
temporary flags that will be removed at the same time as other klog flags.
123+
124+
### Removed klog flags
125+
126+
To addopt 12 factor app standard for logging we would drop all flags that extend
127+
logging over events streams. This change should be
119128
scoped to only those components and not affect broader klog community.
120129

121-
With removal of output stream manipulation flags we need to provide a set of sane
122-
defaults and convention that will prevent logging formats implementations to
123-
diverge and reintroduce their own flags. As logs should be treated as event
124-
streams I would propose that we separate two main streams "info" and "error"
125-
based on log method called. As error logs should usually be treated with higher
126-
priority, having two streams prevents single pipeline from being clogged down
127-
(for example [kubernetes/klog#209](https://github.com/kubernetes/klog/issues/209)). For
128-
logging formats writing to standard streams, we should follow UNIX standard
129-
of mapping "info" logs to stdout and "error" logs to stderr.
130-
131130
Flags that should be deprecated:
132131

133132
* --log-dir, --log-file, --log-flush-frequency - responsible for writing to
@@ -138,13 +137,14 @@ Flags that should be deprecated:
138137
writing to journal.
139138
* --logtostderr, --alsologtostderr, --one-output, --stderrthreshold -
140139
responsible enabling/disabling writing to stderr (vs file).
141-
Motivation: Not needed if writing to files is removed.
140+
Motivation: Routing logs can be easily implemented by any log processors like:
141+
Fluentd, Fluentbit, Logstash.
142142
* --log-file-max-size, --skip-log-headers - responsible configuration of file
143143
rotation.
144144
Motivation: Not needed if writing to files is removed.
145145
* --add-dir-header, --skip-headers - klog format specific flags .
146146
Motivation: don't apply to other log formats
147-
* --log-backtrace-at - an legacy glog feature.
147+
* --log-backtrace-at - A legacy glog feature.
148148
Motivation: No trace of anyone using this feature.
149149

150150
Flag deprecation should comply with standard k8s policy and require 3 releases before removal.
@@ -154,9 +154,63 @@ This leaves that two flags that should be implemented by all log formats
154154
* -v - control global log verbosity of Info logs
155155
* --vmodule - control log verbosity of Info logs on per file level
156156

157-
Those flags were chosen as they have direct effect of which logs are written,
157+
Those flags were chosen as they have effect of which logs are written,
158158
directly impacting log volume and component performance.
159159

160+
### Logging defaults
161+
162+
With removal of configuration alternatives we need to make sure that defaults
163+
make sense. List of logging features implemented by klog and proposed actions:
164+
* Routing logs based on type/verbosity - Should be reconsidered.
165+
* Writing logs to file - Feature removed.
166+
* Log file rotation based on file size - Feature removed.
167+
* Configuration of log headers - Use the current defaults.
168+
* Adding stacktrace - Feature removed.
169+
170+
For log routing I propose to adopt UNIX convention of writing info logs to
171+
stdout and errors to stderr. For log headers I propose to use the current
172+
default.
173+
174+
#### Split stdout and stderr
175+
176+
As logs should be treated as event streams I would propose that we separate two
177+
main streams "info" and "error" based on log method called. As error logs should
178+
usually be treated with higher priority, having two streams prevents single
179+
pipeline from being clogged down (for example
180+
[kubernetes/klog#209](https://github.com/kubernetes/klog/issues/209)).
181+
For logging formats writing to standard streams, we should follow UNIX standard
182+
of mapping "info" logs to stdout and "error" logs to stderr.
183+
184+
Splitting stdout from stderr would be a breaking change in both klog and
185+
kubernetes components. To avoid that I propose to introduce new logging flag
186+
`--logtostdout` in klog that will allow writing info logs to stdout. This flag
187+
will be used avoid introducing breaking change in klog. For Kubernetes components
188+
we would use this flag to start testing this change and delay enabling this flag
189+
by default by one release when we will hit Beta. As any other klog flag it
190+
should be deprecated when this effort hits GA.
191+
192+
With this flag we can follow multi release plan to user impact (each point
193+
should be done in separate release):
194+
1. Introduce the flag in disabled state and start using it in tests.
195+
1. Announce flag availability and encourage users to adopt it.
196+
1. Enable flag by default and deprecate it (allows users to flip back to previous behavior)
197+
1. Remove the flag following the deprecation policy.
198+
199+
#### Logging headers
200+
201+
Default logging headers configuration results in klog writing information about
202+
log type (error/info), timestamp when log was created and code line responsible
203+
for generation it. All this information is useful and should be utilized by
204+
modern logging solutions. Log type is useful for log filtering when looking for
205+
an issue. Log generation timestamp is useful to preserve ordering of logs and
206+
should be always preferred over time of injection which can be much later.
207+
Source code location is important to identify how log line was generated.
208+
209+
Example:
210+
```
211+
I0605 22:03:07.224378 3228948 logger.go:59] "Log using InfoS" key="value"
212+
```
213+
160214
### User Stories
161215

162216
#### Writing logs to files
@@ -217,14 +271,6 @@ architecture.
217271

218272
## Design Details
219273

220-
Splitting stdout from stderr would be a breaking change in both klog and
221-
kubernetes components. To avoid that I propose to introduce new logging flag
222-
`--logtostdout` in klog that will allow writing info logs to stdout. This flag
223-
will be used avoid introducing breaking change in klog. For Kubernetes components
224-
we would use this flag to start testing this change and delay enabling this flag
225-
by default by one release when we will hit Beta. As any other klog flag it
226-
should be deprecated when this effort hits GA.
227-
228274
### Test Plan
229275

230276
Go-runner is already used for scalability tests. We should ensure that we cover
@@ -246,11 +292,11 @@ all existing klog features.
246292
- Go-runner project is well maintained and documented
247293
- Documentation on migrating off klog flags is publicly available
248294
- Kubernetes klog flags are marked as deprecated
249-
- Split stdout and stderr logs in Kubernetes components by default
295+
- Enable --logtostdout in Kubernetes components by default
250296

251297
#### GA
252298

253-
- Kubernetes klog flags are removed
299+
- Kubernetes klog specific flags are removed (including --logtostdout)
254300

255301
### Upgrade / Downgrade Strategy
256302

0 commit comments

Comments
 (0)