@@ -26,7 +26,6 @@ import (
2626 "github.com/google/uuid"
2727 "github.com/gorilla/handlers"
2828 "github.com/pkg/errors"
29- "github.com/sirupsen/logrus"
3029
3130 v1 "k8s.io/api/core/v1"
3231 apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -36,6 +35,7 @@ import (
3635 "k8s.io/apimachinery/pkg/util/validation"
3736 "k8s.io/apimachinery/pkg/util/version"
3837 clientset "k8s.io/client-go/kubernetes"
38+ "k8s.io/klog/v2"
3939)
4040
4141const (
@@ -222,16 +222,16 @@ func ExecuteWithTimeout(timeout time.Duration, envs []string, binary string, arg
222222 case <- time .After (timeout ):
223223 if cmd .Process != nil {
224224 if err := cmd .Process .Kill (); err != nil {
225- logrus . Warnf ("Problem killing process pid=%v: %s" , cmd .Process .Pid , err )
225+ klog . Warningf ("Problem killing process pid=%v: %s" , cmd .Process .Pid , err )
226226 }
227227
228228 }
229- return "" , fmt .Errorf ("Timeout executing: %v %v, output %s, stderr, %s, error %v" ,
229+ return "" , fmt .Errorf ("timeout executing: %v %v, output %s, stderr, %s, error %v" ,
230230 binary , args , output .String (), stderr .String (), err )
231231 }
232232
233233 if err != nil {
234- return "" , fmt .Errorf ("Failed to execute: %v %v, output %s, stderr, %s, error %v" ,
234+ return "" , fmt .Errorf ("failed to execute: %v %v, output %s, stderr, %s, error %v" ,
235235 binary , args , output .String (), stderr .String (), err )
236236 }
237237 return output .String (), nil
@@ -256,7 +256,7 @@ func TimestampAfterTimeout(ts string, timeout time.Duration) bool {
256256 now := time .Now ()
257257 t , err := time .Parse (time .RFC3339 , ts )
258258 if err != nil {
259- logrus .Errorf ("Cannot parse time %v" , ts )
259+ klog .Errorf ("Cannot parse time %v" , ts )
260260 return false
261261 }
262262 deadline := t .Add (timeout )
@@ -266,7 +266,7 @@ func TimestampAfterTimeout(ts string, timeout time.Duration) bool {
266266func TimestampWithinLimit (latest time.Time , ts string , limit time.Duration ) bool {
267267 t , err := time .Parse (time .RFC3339 , ts )
268268 if err != nil {
269- logrus .Errorf ("Cannot parse time %v" , ts )
269+ klog .Errorf ("Cannot parse time %v" , ts )
270270 return false
271271 }
272272 deadline := t .Add (limit )
@@ -329,7 +329,7 @@ func RegisterShutdownChannel(done chan struct{}) {
329329 signal .Notify (sigs , syscall .SIGINT , syscall .SIGTERM )
330330 go func () {
331331 sig := <- sigs
332- logrus .Infof ("Receive %v to exit" , sig )
332+ klog . V ( 2 ) .Infof ("Receive %v to exit" , sig )
333333 close (done )
334334 }()
335335}
@@ -367,14 +367,14 @@ func GetSortedKeysFromMap(maps interface{}) []string {
367367func AutoCorrectName (name string , maxLength int ) string {
368368 newName := strings .ToLower (name )
369369 if len (name ) > maxLength {
370- logrus . Warnf ("Name %v is too long, auto-correct to fit %v characters" , name , maxLength )
370+ klog . Warningf ("Name %v is too long, auto-correct to fit %v characters" , name , maxLength )
371371 checksum := GetStringChecksum (name )
372372 newNameSuffix := "-" + checksum [:8 ]
373373 newNamePrefix := strings .TrimRight (newName [:maxLength - len (newNameSuffix )], "-" )
374374 newName = newNamePrefix + newNameSuffix
375375 }
376376 if newName != name {
377- logrus . Warnf ("Name auto-corrected from %v to %v" , name , newName )
377+ klog . Warningf ("Name auto-corrected from %v to %v" , name , newName )
378378 }
379379 return newName
380380}
0 commit comments