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

Commit

Permalink
Merge pull request #2000 from 2opremio/improve-internal-k8s-logging
Browse files Browse the repository at this point in the history
Improve internal kubernetes error logging
  • Loading branch information
2opremio authored May 1, 2019
2 parents 7fc70a8 + 4c0ce35 commit f5df2fe
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 f5df2fe

Please sign in to comment.