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

Improve internal kubernetes error logging #2000

Merged
merged 1 commit into from
May 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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