Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Improve internal kubernetes error logging
Browse files Browse the repository at this point in the history
1. Remove duplicated timestamp keyval
2. Print full path to kubernetes file emitting the error
  • Loading branch information
2opremio committed Apr 30, 2019
1 parent b437ebe commit 4c0ce35
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"os/signal"
"runtime"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -194,8 +195,11 @@ func main() {
// Silence access errors logged internally by client-go
k8slog := log.With(logger,
"type", "internal kubernetes error",
"ts", log.DefaultTimestampUTC,
"caller", log.Caller(5)) // we want to log one level deeper than k8sruntime.HandleError
"kubernetes_caller", log.Valuer(func() interface{} {
_, file, line, _ := runtime.Caller(5) // we want to log one level deeper than k8sruntime.HandleError
idx := strings.Index(file, "/vendor/")
return file[idx+1:] + ":" + strconv.Itoa(line)
}))
logErrorUnlessAccessRelated := func(err error) {
errLower := strings.ToLower(err.Error())
if k8serrors.IsForbidden(err) || k8serrors.IsNotFound(err) ||
Expand Down

0 comments on commit 4c0ce35

Please sign in to comment.