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

logcheck update and golangci-lint integration #108159

Merged
merged 3 commits into from Mar 25, 2022

Commits on Mar 24, 2022

  1. kube-scheduler: finish conversion to structured logging

    Thanks to support for multi-line string values we can now also convert
    these remaining klog.Info calls without making the output unreadable
    in text format.
    
    The debug log messages intentionally don't get changed to ensure that
    developers looking for it still find it.
    
    The output now looks like this:
    
    I0322 11:44:46.715093  458409 configfile.go:96] "Using component config" config=<
    	apiVersion: kubescheduler.config.k8s.io/v1beta2
    	clientConnection:
    	  acceptContentTypes: ""
    	  burst: 100
    	  contentType: application/vnd.kubernetes.protobuf
    	  kubeconfig: /var/run/kubernetes/scheduler.kubeconfig
    	  qps: 50
    	enableContentionProfiling: true
     ...
    	  schedulerName: default-scheduler
     >
    
    I0322 11:45:08.695649  458409 comparer.go:42] "Cache comparer started"
    I0322 11:45:08.695718  458409 comparer.go:67] "Cache comparer finished"
    I0322 11:45:08.695820  458409 dumper.go:52] "Dump of cached NodeInfo" nodes=<
    	Node name: 127.0.0.1
    	Deleted: false
    	Requested Resources: &{MilliCPU:0 Memory:0 EphemeralStorage:0 AllowedPodNumber:0 ScalarResources:map[]}
    	Allocatable Resources:&{MilliCPU:36000 Memory:67019448320 EphemeralStorage:181555660500 AllowedPodNumber:110 ScalarResources:map[hugepages-1Gi:0 hugepages-2Mi:0]}
    	Scheduled Pods(number: 0):
     >
    I0322 11:45:08.695873  458409 dumper.go:62] "Dump of scheduling queue" pods=<
    	name: coredns-6874cd75d4-fv6hv, namespace: kube-system, uid: f1df106f-7fd9-460d-8403-333df61b2751, phase: Pending, nominated node:
     >
    pohly committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    0f4d066 View commit details
    Browse the repository at this point in the history
  2. enhance and fix log calls

    Some of these changes are cosmetic (repeatedly calling klog.V instead of
    reusing the result), others address real issues:
    
    - Logging a message only above a certain verbosity threshold without
      recording that verbosity level (if klog.V().Enabled() { klog.Info... }):
      this matters when using a logging backend which records the verbosity
      level.
    
    - Passing a format string with parameters to a logging function that
      doesn't do string formatting.
    
    All of these locations where found by the enhanced logcheck tool from
    kubernetes/klog#297.
    
    In some cases it reports false positives, but those can be suppressed with
    source code comments.
    pohly committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    edffc70 View commit details
    Browse the repository at this point in the history
  3. hack: integrate logcheck into golangci-lint

    Running logcheck as part of golangci-lint has several advantages:
    - faster checking because finding files and parsing is shared
      with other linters
    - gets rid of the complex and buggy
      hack/verify-structured-logging.sh (kubernetes#106746)
    - support for // nolint:logcheck
    - works with Go 1.18
    pohly committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    17e3c55 View commit details
    Browse the repository at this point in the history