Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

component-base: move v/vmodule/log-flush-frequency into LoggingConfiguration #106090

Merged
merged 3 commits into from Nov 4, 2021

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Nov 2, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

These three options are the ones from logs.AddFlags which are not deprecated.
Therefore it makes sense to make them available also via the configuration file
support in the one command which currently supports that (kubelet).

Which issue(s) this PR fixes:

Fixes #99265

Special notes for your reviewer:

Long-term, all commands should use LoggingConfiguration, either with a
configuration file (as in kubelet) or via flags (kube-scheduler,
kube-apiserver, kube-controller-manager).

Short-term, both approaches have to be supported. As the majority of the
commands only use logs.AddFlags, that function by default continues to register
the flags and only leaves that to Options.AddFlags when explicitly requested.

A drive-by bug fix is done for log flushing: the periodic flushing called
klog.Flush and therefore missed explicit flushing of the newer logr
backend. This bug was never present in any release Kubernetes and therefore the
fix is not submitted in a separate PR.

Does this PR introduce a user-facing change?

In kubelet, log verbosity and flush frequency can also be configured via the configuration file and not just via command line flags. In other commands (kube-apiserver, kube-controller-manager), the flags are listed in the "Logs flags" group and not under "Global" or "Misc". The type for `-vmodule` was made a bit more descriptive (`pattern=N,...` instead of `moduleSpec`).

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/issues/2845

/cc @serathius

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/apiserver area/kubelet kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 2, 2021
@pohly
Copy link
Contributor Author

pohly commented Nov 2, 2021

I ran the comparison script from #105076 (comment).

It shows the following changes in command line usage and no unexpected changes in other commands:

cmd/kube-apiserver: log-flush-frequency v vmodule klog deprecated modified:
    *** /dev/fd/63	2021-11-02 14:33:22.693847001 +0100
    --- /dev/fd/62	2021-11-02 14:33:22.693847001 +0100
    ***************
    *** 287,297 ****
    --- 287,300 ----
      
            --experimental-logging-sanitization    [Experimental] When enabled prevents logging of fields tagged as sensitive (passwords, keys, tokens).
                                                   Runtime log sanitization may introduce significant computation overhead and therefore should not be enabled in production.
    +       --log-flush-frequency duration         Maximum number of seconds between log flushes (default 5s)
            --log-json-info-buffer-size quantity   [Experimental] In JSON format with split output streams, the info messages can be buffered for a while to increase performance. The default value of zero bytes disables buffering. The size can be specified as number of bytes (512), multiples of 1000 (1K), multiples of 1024 (2Ki), or powers of those (3M, 4G, 5Mi, 6Gi).
            --log-json-split-stream                [Experimental] In JSON format, write error messages to stderr and info messages to stdout. The default is to write a single stream to stdout.
            --logging-format string                Sets the log format. Permitted formats: "json", "text".
                                                   Non-default formats don't honor these flags: --add-dir-header, --alsologtostderr, --log-backtrace-at, --log-dir, --log-file, --log-file-max-size, --logtostderr, --one-output, --skip-headers, --skip-log-headers, --stderrthreshold, --vmodule.
                                                   Non-default choices are currently alpha and subject to change without warning. (default "text")
    +   -v, --v Level                              number for the log level verbosity
    +       --vmodule pattern=N,...                comma-separated list of pattern=N settings for file-filtered logging (only works for text log format)
      
      Traces flags:
      
    ***************
    *** 328,339 ****
            --log-dir string                   If non-empty, write log files in this directory (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file string                  If non-empty, use this log file (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file-max-size uint           Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    -       --log-flush-frequency duration     Maximum number of seconds between log flushes (default 5s)
            --logtostderr                      log to standard error instead of files (default true) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --one-output                       If true, only write logs to their native severity level (vs also writing to each lower severity level) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --skip-headers                     If true, avoid header prefixes in the log messages (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --skip-log-headers                 If true, avoid headers when opening log files (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --stderrthreshold severity         logs at or above this threshold go to stderr (default 2) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    -   -v, --v Level                          number for the log level verbosity
            --version version[=true]           Print version information and quit
    -       --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging
    --- 331,339 ----

cmd/kube-controller-manager: log-flush-frequency v vmodule klog deprecated modified:
    *** /dev/fd/63	2021-11-02 14:33:22.717846901 +0100
    --- /dev/fd/62	2021-11-02 14:33:22.717846901 +0100
    ***************
    *** 335,345 ****
    --- 335,348 ----
      
            --experimental-logging-sanitization    [Experimental] When enabled prevents logging of fields tagged as sensitive (passwords, keys, tokens).
                                                   Runtime log sanitization may introduce significant computation overhead and therefore should not be enabled in production.
    +       --log-flush-frequency duration         Maximum number of seconds between log flushes (default 5s)
            --log-json-info-buffer-size quantity   [Experimental] In JSON format with split output streams, the info messages can be buffered for a while to increase performance. The default value of zero bytes disables buffering. The size can be specified as number of bytes (512), multiples of 1000 (1K), multiples of 1024 (2Ki), or powers of those (3M, 4G, 5Mi, 6Gi).
            --log-json-split-stream                [Experimental] In JSON format, write error messages to stderr and info messages to stdout. The default is to write a single stream to stdout.
            --logging-format string                Sets the log format. Permitted formats: "json", "text".
                                                   Non-default formats don't honor these flags: --add-dir-header, --alsologtostderr, --log-backtrace-at, --log-dir, --log-file, --log-file-max-size, --logtostderr, --one-output, --skip-headers, --skip-log-headers, --stderrthreshold, --vmodule.
                                                   Non-default choices are currently alpha and subject to change without warning. (default "text")
    +   -v, --v Level                              number for the log level verbosity
    +       --vmodule pattern=N,...                comma-separated list of pattern=N settings for file-filtered logging (only works for text log format)
      
      Misc flags:
      
    ***************
    *** 355,366 ****
            --log-dir string                   If non-empty, write log files in this directory (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file string                  If non-empty, use this log file (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file-max-size uint           Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    -       --log-flush-frequency duration     Maximum number of seconds between log flushes (default 5s)
            --logtostderr                      log to standard error instead of files (default true) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --one-output                       If true, only write logs to their native severity level (vs also writing to each lower severity level) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --skip-headers                     If true, avoid header prefixes in the log messages (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --skip-log-headers                 If true, avoid headers when opening log files (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --stderrthreshold severity         logs at or above this threshold go to stderr (default 2) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    -   -v, --v Level                          number for the log level verbosity
            --version version[=true]           Print version information and quit
    -       --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging
    --- 358,366 ----

cmd/kubelet: log-flush-frequency v vmodule klog deprecated modified:
    *** /dev/fd/63	2021-11-02 14:33:22.785846616 +0100
    --- /dev/fd/62	2021-11-02 14:33:22.785846616 +0100
    ***************
    *** 234,240 ****
            --log-dir string                                           If non-empty, write log files in this directory (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file string                                          If non-empty, use this log file (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file-max-size uint                                   Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    !       --log-flush-frequency duration                             Maximum number of seconds between log flushes (default 5s)
            --log-json-info-buffer-size quantity                       [Experimental] In JSON format with split output streams, the info messages can be buffered for a while to increase performance. The default value of zero bytes disables buffering. The size can be specified as number of bytes (512), multiples of 1000 (1K), multiples of 1024 (2Ki), or powers of those (3M, 4G, 5Mi, 6Gi). (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --log-json-split-stream                                    [Experimental] In JSON format, write error messages to stderr and info messages to stdout. The default is to write a single stream to stdout. (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --logging-format string                                    Sets the log format. Permitted formats: "json", "text".
    --- 234,240 ----
            --log-dir string                                           If non-empty, write log files in this directory (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file string                                          If non-empty, use this log file (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file-max-size uint                                   Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    !       --log-flush-frequency duration                             Maximum number of seconds between log flushes (default 5s) (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --log-json-info-buffer-size quantity                       [Experimental] In JSON format with split output streams, the info messages can be buffered for a while to increase performance. The default value of zero bytes disables buffering. The size can be specified as number of bytes (512), multiples of 1000 (1K), multiples of 1024 (2Ki), or powers of those (3M, 4G, 5Mi, 6Gi). (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --log-json-split-stream                                    [Experimental] In JSON format, write error messages to stderr and info messages to stdout. The default is to write a single stream to stdout. (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --logging-format string                                    Sets the log format. Permitted formats: "json", "text".
    ***************
    *** 312,319 ****
            --tls-private-key-file string                              File containing x509 private key matching --tls-cert-file. (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --topology-manager-policy string                           Topology Manager policy to use. Possible values: 'none', 'best-effort', 'restricted', 'single-numa-node'. (default "none") (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --topology-manager-scope string                            Scope to which topology hints applied. Topology Manager collects hints from Hint Providers and applies them to defined scope to ensure the pod admission. Possible values: 'container', 'pod'. (default "container") (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
    !   -v, --v Level                                                  number for the log level verbosity
            --version version[=true]                                   Print version information and quit
    !       --vmodule moduleSpec                                       comma-separated list of pattern=N settings for file-filtered logging
            --volume-plugin-dir string                                 The full path of the directory in which to search for additional third party volume plugins (default "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/") (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --volume-stats-agg-period duration                         Specifies interval for kubelet to calculate and cache the volume disk usage for all pods and volumes.  To disable volume calculations, set to a negative number. (default 1m0s) (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
    --- 312,319 ----
            --tls-private-key-file string                              File containing x509 private key matching --tls-cert-file. (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --topology-manager-policy string                           Topology Manager policy to use. Possible values: 'none', 'best-effort', 'restricted', 'single-numa-node'. (default "none") (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --topology-manager-scope string                            Scope to which topology hints applied. Topology Manager collects hints from Hint Providers and applies them to defined scope to ensure the pod admission. Possible values: 'container', 'pod'. (default "container") (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
    !   -v, --v Level                                                  number for the log level verbosity (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --version version[=true]                                   Print version information and quit
    !       --vmodule pattern=N,...                                    comma-separated list of pattern=N settings for file-filtered logging (only works for text log format) (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --volume-plugin-dir string                                 The full path of the directory in which to search for additional third party volume plugins (default "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/") (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)
            --volume-stats-agg-period duration                         Specifies interval for kubelet to calculate and cache the volume disk usage for all pods and volumes.  To disable volume calculations, set to a negative number. (default 1m0s) (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)

cmd/kube-scheduler: log-flush-frequency v vmodule klog deprecated modified:
    *** /dev/fd/63	2021-11-02 14:33:22.853846330 +0100
    --- /dev/fd/62	2021-11-02 14:33:22.853846330 +0100
    ***************
    *** 190,200 ****
    --- 190,203 ----
      
            --experimental-logging-sanitization    [Experimental] When enabled prevents logging of fields tagged as sensitive (passwords, keys, tokens).
                                                   Runtime log sanitization may introduce significant computation overhead and therefore should not be enabled in production.
    +       --log-flush-frequency duration         Maximum number of seconds between log flushes (default 5s)
            --log-json-info-buffer-size quantity   [Experimental] In JSON format with split output streams, the info messages can be buffered for a while to increase performance. The default value of zero bytes disables buffering. The size can be specified as number of bytes (512), multiples of 1000 (1K), multiples of 1024 (2Ki), or powers of those (3M, 4G, 5Mi, 6Gi).
            --log-json-split-stream                [Experimental] In JSON format, write error messages to stderr and info messages to stdout. The default is to write a single stream to stdout.
            --logging-format string                Sets the log format. Permitted formats: "json", "text".
                                                   Non-default formats don't honor these flags: --add-dir-header, --alsologtostderr, --log-backtrace-at, --log-dir, --log-file, --log-file-max-size, --logtostderr, --one-output, --skip-headers, --skip-log-headers, --stderrthreshold, --vmodule.
                                                   Non-default choices are currently alpha and subject to change without warning. (default "text")
    +   -v, --v Level                              number for the log level verbosity
    +       --vmodule pattern=N,...                comma-separated list of pattern=N settings for file-filtered logging (only works for text log format)
      
      Global flags:
      
    ***************
    *** 205,216 ****
            --log-dir string                   If non-empty, write log files in this directory (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file string                  If non-empty, use this log file (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --log-file-max-size uint           Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    -       --log-flush-frequency duration     Maximum number of seconds between log flushes (default 5s)
            --logtostderr                      log to standard error instead of files (default true) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --one-output                       If true, only write logs to their native severity level (vs also writing to each lower severity level) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --skip-headers                     If true, avoid header prefixes in the log messages (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --skip-log-headers                 If true, avoid headers when opening log files (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --stderrthreshold severity         logs at or above this threshold go to stderr (default 2) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
    -   -v, --v Level                          number for the log level verbosity
            --version version[=true]           Print version information and quit
    -       --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging
    --- 208,216 ----

staging/src/k8s.io/component-base/logs/example/cmd: log-flush-frequency v vmodule klog deprecated modified:
    *** /dev/fd/63	2021-11-02 14:33:23.841842193 +0100
    --- /dev/fd/62	2021-11-02 14:33:23.841842193 +0100
    ***************
    *** 23,26 ****
            --skip-log-headers                     If true, avoid headers when opening log files (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --stderrthreshold severity             logs at or above this threshold go to stderr (default 2) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
        -v, --v Level                              number for the log level verbosity
    !       --vmodule moduleSpec                   comma-separated list of pattern=N settings for file-filtered logging
    --- 23,26 ----
            --skip-log-headers                     If true, avoid headers when opening log files (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
            --stderrthreshold severity             logs at or above this threshold go to stderr (default 2) (DEPRECATED: will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components)
        -v, --v Level                              number for the log level verbosity
    !       --vmodule pattern=N,...                comma-separated list of pattern=N settings for file-filtered logging (only works for text log format)

@@ -122,4 +122,7 @@ func RecommendedLoggingConfiguration(obj *LoggingConfiguration) {
// by reflect.DeepEqual in some tests.
_ = obj.Options.JSON.InfoBufferSize.String()
}
if obj.FlushFrequency == 0*time.Second {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if obj.FlushFrequency == 0*time.Second {
if obj.FlushFrequency == 0 {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is time.Second required here? I think it obscures the check if value was not provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and also addressed the unit test failures for kubelet config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is time.Second required here?

No. I thought I had to provide a time.Duration value for the comparison, but the 0 constant works just as well.

@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@serathius
Copy link
Contributor

serathius commented Nov 2, 2021

Overall LGTM, one question about introduction of SkipLoggingConfigurationFlags. What will happen if new components starts using LoggingConfiguration.AddFlags, but forgets to pass SkipLoggingConfigurationFlags? Will it:

  • panic?
  • reregister flags duplicating info in --help, but they will work as intended?
  • break configuration?

Would be good to confirm which case will happen to make sure we avoid hard to debug issues in future.

@pohly
Copy link
Contributor Author

pohly commented Nov 2, 2021

Overall LGTM, one question about introduction of SkipLoggingConfigurationFlags. What will happen if new components starts using LoggingConfiguration.AddFlags, but forgets to pass SkipLoggingConfigurationFlags?

It depends.

Will it:

* panic?

Yes, if using the same flag set. I saw that in kubelet.

* reregister flags duplicating info in --help, but they will work as intended?

For example, kube-controller-manager uses different flag sets. --help then shows the flag twice. I did not check whether that then still works. Let me have a look...

No, that doesn't work. -v=5 sets the level in klog directly (via the global flag), but the LoggingConfiguration.Verbosity value remains at the default 0, so when Apply is called, it resets the verbosity to 0.

* break configuration?

You refer to kubelet here, right? kubelet panics, so we don't need to worry about that.

@serathius
Copy link
Contributor

serathius commented Nov 2, 2021

For example, kube-controller-manager uses different flag sets. --help then shows the flag twice. I did not check whether that then still works. Let me have a look...

No, that doesn't work. -v=5 sets the level in klog directly (via the global flag), but the LoggingConfiguration.Verbosity value remains at the default 0, so when Apply is called, it resets the verbosity to 0.

We should make sure we panic in this case, so the problem is easy to notice.

@pohly
Copy link
Contributor Author

pohly commented Nov 3, 2021

/label api-review

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label Nov 3, 2021
@pohly
Copy link
Contributor Author

pohly commented Nov 3, 2021

/test pull-kubernetes-e2e-windows-gce

Unrelated to this PR, I just want to see whether it collects kubelet logs on Windows nodes (relevant for some other PR).

@k8s-ci-robot
Copy link
Contributor

@pohly: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-e2e-windows-gce 2590703 link false /test pull-kubernetes-e2e-windows-gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@wgahnagl
Copy link
Contributor

wgahnagl commented Nov 3, 2021

/triage accepted
/priority soon

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Nov 3, 2021
@k8s-ci-robot
Copy link
Contributor

@wgahnagl: The label(s) priority/soon cannot be applied, because the repository doesn't have them.

In response to this:

/triage accepted
/priority soon

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 3, 2021
@wgahnagl wgahnagl moved this from Triage to Needs Reviewer in SIG Node PR Triage Nov 3, 2021
@pohly
Copy link
Contributor Author

pohly commented Nov 4, 2021

/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 4, 2021
@serathius
Copy link
Contributor

/cc @thockin

@thockin
Copy link
Member

thockin commented Nov 4, 2021

/approve

@thockin
Copy link
Member

thockin commented Nov 4, 2021

/retest

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pohly, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2021
@k8s-ci-robot k8s-ci-robot merged commit dc93951 into kubernetes:master Nov 4, 2021
SIG Node PR Triage automation moved this from Needs Reviewer to Done Nov 4, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Nov 4, 2021
acumino added a commit to acumino/gardener that referenced this pull request Feb 8, 2022
acumino added a commit to acumino/gardener that referenced this pull request Feb 11, 2022
acumino added a commit to acumino/gardener that referenced this pull request Feb 11, 2022
timebertt added a commit to gardener/gardener that referenced this pull request Feb 14, 2022
* Bump k8s.io/* to v0.23.3 in go.mod

* [automated] make revendor

* [automated] make generate

* Bump c-r to v0.11.0 in go.mod

* [automated] make revendor

* Bump controller-tools to v0.8.0 in go.mod

* [automated] make revendor

* Adapt change for Logger changed to Struct

From v1.0.0 log.Logger has been changed to struct from Interface. Logger struct has field `LogSink` interface which is same as old `Logger` interface

* Adapt changes fo NullLogger

* Adapt chnage in Handler API

ref kubernetes/kubernetes#105979

* Adapt ResolverConfig field changed from a string to *string

ref kubernetes/kunernetes#104624

* Adapt changes for, In kubelet, log verbosity and flush frequency can also be configured via the configuration

ref kubernetes/kubernetes#106090

* [automated] make generate

* Avoid shallow copies of webhook

ref kubernetes-sigs/controller-runtime#1667

* Add back apiserver logging flags

* Rebase

Co-authored-by: Tim Ebert <timebertt@gmail.com>
krgostev pushed a commit to krgostev/gardener that referenced this pull request Apr 21, 2022
* Bump k8s.io/* to v0.23.3 in go.mod

* [automated] make revendor

* [automated] make generate

* Bump c-r to v0.11.0 in go.mod

* [automated] make revendor

* Bump controller-tools to v0.8.0 in go.mod

* [automated] make revendor

* Adapt change for Logger changed to Struct

From v1.0.0 log.Logger has been changed to struct from Interface. Logger struct has field `LogSink` interface which is same as old `Logger` interface

* Adapt changes fo NullLogger

* Adapt chnage in Handler API

ref kubernetes/kubernetes#105979

* Adapt ResolverConfig field changed from a string to *string

ref kubernetes/kunernetes#104624

* Adapt changes for, In kubelet, log verbosity and flush frequency can also be configured via the configuration

ref kubernetes/kubernetes#106090

* [automated] make generate

* Avoid shallow copies of webhook

ref kubernetes-sigs/controller-runtime#1667

* Add back apiserver logging flags

* Rebase

Co-authored-by: Tim Ebert <timebertt@gmail.com>
krgostev pushed a commit to krgostev/gardener that referenced this pull request Jul 5, 2022
* Bump k8s.io/* to v0.23.3 in go.mod

* [automated] make revendor

* [automated] make generate

* Bump c-r to v0.11.0 in go.mod

* [automated] make revendor

* Bump controller-tools to v0.8.0 in go.mod

* [automated] make revendor

* Adapt change for Logger changed to Struct

From v1.0.0 log.Logger has been changed to struct from Interface. Logger struct has field `LogSink` interface which is same as old `Logger` interface

* Adapt changes fo NullLogger

* Adapt chnage in Handler API

ref kubernetes/kubernetes#105979

* Adapt ResolverConfig field changed from a string to *string

ref kubernetes/kunernetes#104624

* Adapt changes for, In kubelet, log verbosity and flush frequency can also be configured via the configuration

ref kubernetes/kubernetes#106090

* [automated] make generate

* Avoid shallow copies of webhook

ref kubernetes-sigs/controller-runtime#1667

* Add back apiserver logging flags

* Rebase

Co-authored-by: Tim Ebert <timebertt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Projects
Development

Successfully merging this pull request may close these issues.

Move not-deprecated klog flags to Logs flag group
7 participants