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

Migrate pkg/kubelet/server to structured logging #99838

Merged
merged 1 commit into from Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 20 additions & 6 deletions pkg/kubelet/server/server.go
Expand Up @@ -25,6 +25,7 @@ import (
"net/http"
"net/http/pprof"
"net/url"
"os"
"reflect"
goruntime "runtime"
"strconv"
Expand Down Expand Up @@ -159,9 +160,13 @@ func ListenAndServeKubeletServer(
// Passing empty strings as the cert and key files means no
// cert/keys are specified and GetCertificate in the TLSConfig
// should be called instead.
klog.Fatal(s.ListenAndServeTLS(tlsOptions.CertFile, tlsOptions.KeyFile))
} else {
klog.Fatal(s.ListenAndServe())
if err := s.ListenAndServeTLS(tlsOptions.CertFile, tlsOptions.KeyFile); err != nil {
klog.ErrorS(err, "Failed to listen and serve")
os.Exit(1)
}
} else if err := s.ListenAndServe(); err != nil {
klog.ErrorS(err, "Failed to listen and serve")
os.Exit(1)
}
}

Expand All @@ -175,7 +180,11 @@ func ListenAndServeKubeletReadOnlyServer(host HostInterface, resourceAnalyzer st
Handler: &s,
MaxHeaderBytes: 1 << 20,
}
klog.Fatal(server.ListenAndServe())

if err := server.ListenAndServe(); err != nil {
klog.ErrorS(err, "Failed to listen and serve")
os.Exit(1)
}
}

// ListenAndServePodResources initializes a gRPC server to serve the PodResources service
Expand All @@ -185,9 +194,14 @@ func ListenAndServePodResources(socket string, podsProvider podresources.PodsPro
podresourcesapi.RegisterPodResourcesListerServer(server, podresources.NewV1PodResourcesServer(podsProvider, devicesProvider, cpusProvider))
l, err := util.CreateListener(socket)
if err != nil {
klog.Fatalf("Failed to create listener for podResources endpoint: %v", err)
klog.ErrorS(err, "Failed to create listener for podResources endpoint")
adisky marked this conversation as resolved.
Show resolved Hide resolved
os.Exit(1)
}

if err := server.Serve(l); err != nil {
klog.ErrorS(err, "Failed to serve")
os.Exit(1)
}
klog.Fatal(server.Serve(l))
}

// AuthInterface contains all methods required by the auth filters
Expand Down