@@ -23,7 +23,7 @@ import (
2323 "net/http"
2424 "time"
2525
26- "github.com/golang/glog "
26+ "k8s.io/klog "
2727
2828 "github.com/kubernetes-csi/livenessprobe/pkg/connection"
2929)
@@ -43,32 +43,32 @@ var (
4343
4444func runProbe (ctx context.Context , csiConn connection.CSIConnection ) error {
4545 // Get CSI driver name.
46- glog .Infof ("Calling CSI driver to discover driver name." )
46+ klog .Infof ("Calling CSI driver to discover driver name." )
4747 csiDriverName , err := csiConn .GetDriverName (ctx )
4848 if err != nil {
4949 return err
5050 }
51- glog .Infof ("CSI driver name: %q" , csiDriverName )
51+ klog .Infof ("CSI driver name: %q" , csiDriverName )
5252 // Sending Probe request
53- glog .Infof ("Sending probe request to CSI driver." )
53+ klog .Infof ("Sending probe request to CSI driver." )
5454 err = csiConn .LivenessProbe (ctx )
5555 return err
5656}
5757
5858func getCSIConnection () (connection.CSIConnection , error ) {
5959 // Connect to CSI.
60- glog .Infof ("Attempting to open a gRPC connection with: %s" , * csiAddress )
60+ klog .Infof ("Attempting to open a gRPC connection with: %s" , * csiAddress )
6161 csiConn , err := connection .NewConnection (* csiAddress , * connectionTimeout )
6262 return csiConn , err
6363}
6464
6565func checkHealth (w http.ResponseWriter , req * http.Request ) {
66- glog .Infof ("Request: %s from: %s\n " , req .URL .Path , req .RemoteAddr )
66+ klog .Infof ("Request: %s from: %s\n " , req .URL .Path , req .RemoteAddr )
6767 csiConn , err := getCSIConnection ()
6868 if err != nil {
6969 w .WriteHeader (http .StatusInternalServerError )
7070 w .Write ([]byte (err .Error ()))
71- glog .Errorf ("Failed to get connection to CSI with error: %v." , err )
71+ klog .Errorf ("Failed to get connection to CSI with error: %v." , err )
7272 return
7373 }
7474 defer csiConn .Close ()
@@ -77,23 +77,24 @@ func checkHealth(w http.ResponseWriter, req *http.Request) {
7777 if err := runProbe (ctx , csiConn ); err != nil {
7878 w .WriteHeader (http .StatusInternalServerError )
7979 w .Write ([]byte (err .Error ()))
80- glog .Errorf ("Health check failed with: %v." , err )
80+ klog .Errorf ("Health check failed with: %v." , err )
8181 } else {
8282 w .WriteHeader (http .StatusOK )
8383 w .Write ([]byte (`ok` ))
84- glog .Infof ("Health check succeeded." )
84+ klog .Infof ("Health check succeeded." )
8585 }
8686}
8787
8888func main () {
89+ klog .InitFlags (nil )
8990 flag .Set ("logtostderr" , "true" )
9091 flag .Parse ()
9192
9293 addr := net .JoinHostPort ("0.0.0.0" , * healthzPort )
9394 http .HandleFunc ("/healthz" , checkHealth )
94- glog .Infof ("Serving requests to /healthz on: %s" , addr )
95+ klog .Infof ("Serving requests to /healthz on: %s" , addr )
9596 err := http .ListenAndServe (addr , nil )
9697 if err != nil {
97- glog .Fatalf ("failed to start http server with error: %v" , err )
98+ klog .Fatalf ("failed to start http server with error: %v" , err )
9899 }
99100}
0 commit comments