Skip to content

Commit

Permalink
Merge pull request #37 from jynolen/fix/normalize-logs
Browse files Browse the repository at this point in the history
Add Debug log to identify why requests is denied
  • Loading branch information
mlbiam authored Nov 25, 2023
2 parents 085bd40 + b694eae commit c497ed7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 3 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ package main
import (
"fmt"
"os"


"k8s.io/klog/v2"
"github.com/jetstack/kube-oidc-proxy/cmd/app"
"github.com/jetstack/kube-oidc-proxy/pkg/util"
)

func main() {
klog.InitFlags(nil)
stopCh := util.SignalHandler()
cmd := app.NewRunCommand(stopCh)

Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
k8s.io/cli-runtime v0.27.4
k8s.io/client-go v0.27.4
k8s.io/component-base v0.27.4
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/kind v0.20.0
)

Expand Down Expand Up @@ -131,7 +131,6 @@ require (
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kms v0.27.4 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
Expand Down Expand Up @@ -936,10 +935,10 @@ k8s.io/client-go v0.27.4 h1:vj2YTtSJ6J4KxaC88P4pMPEQECWMY8gqPqsTgUKzvjk=
k8s.io/client-go v0.27.4/go.mod h1:ragcly7lUlN0SRPk5/ZkGnDjPknzb37TICq07WhI6Xc=
k8s.io/component-base v0.27.4 h1:Wqc0jMKEDGjKXdae8hBXeskRP//vu1m6ypC+gwErj4c=
k8s.io/component-base v0.27.4/go.mod h1:hoiEETnLc0ioLv6WPeDt8vD34DDeB35MfQnxCARq3kY=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kms v0.27.4 h1:FeT17HfqxZMP7dTq3Gpa9dG05iP3J3wgGtqGh1SUoN0=
k8s.io/kms v0.27.4/go.mod h1:0BY6tkfa+zOP85u8yE7iNNf1Yx7rEZnRQSWLEbsSk+w=
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg=
Expand Down
5 changes: 2 additions & 3 deletions pkg/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/heptiolabs/healthcheck"
"k8s.io/apiserver/pkg/authentication/authenticator"
"k8s.io/klog"
"k8s.io/klog/v2"
)

const (
Expand Down Expand Up @@ -66,8 +66,7 @@ func (h *HealthCheck) Check() error {

h.ready = true

klog.V(4).Infof("OIDC provider initialized, readiness check returned expected error: %s", err)
klog.Info("OIDC provider initialized, proxy ready")
klog.V(4).Info("OIDC provider initialized.")

return nil
}
3 changes: 2 additions & 1 deletion pkg/proxy/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
authuser "k8s.io/apiserver/pkg/authentication/user"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/client-go/transport"
"k8s.io/klog"
"k8s.io/klog/v2"

"github.com/jetstack/kube-oidc-proxy/pkg/proxy/audit"
"github.com/jetstack/kube-oidc-proxy/pkg/proxy/context"
Expand Down Expand Up @@ -38,6 +38,7 @@ func (p *Proxy) withAuthenticateRequest(handler http.Handler) http.Handler {
// Auth request and handle unauthed
info, ok, err := p.oidcRequestAuther.AuthenticateRequest(req)
if err != nil {
klog.V(5).Infof("Authenticated request failed: %s", err)
// Since we have failed OIDC auth, we will try a token review, if enabled.
tokenReviewHandler.ServeHTTP(rw, req)
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"k8s.io/apiserver/plugin/pkg/authenticator/token/oidc"
"k8s.io/client-go/rest"
"k8s.io/client-go/transport"
"k8s.io/klog"
"k8s.io/klog/v2"

"github.com/jetstack/kube-oidc-proxy/cmd/app/options"
"github.com/jetstack/kube-oidc-proxy/pkg/proxy/audit"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/signal"
"syscall"

"k8s.io/klog"
"k8s.io/klog/v2"
)

func SignalHandler() chan struct{} {
Expand Down

0 comments on commit c497ed7

Please sign in to comment.