Skip to content

Commit

Permalink
cmd/kube-rbac-proxy/app: use serverconfig.SetupSignalContext to regis…
Browse files Browse the repository at this point in the history
…ter for shutdown signals and use the signal context
  • Loading branch information
liouk committed Jun 1, 2023
1 parent c681496 commit 0c10f9c
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions cmd/kube-rbac-proxy/app/kube-rbac-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"net/http"
"net/http/httputil"
"os"
"os/signal"
"syscall"
"time"

"github.com/oklog/run"
Expand All @@ -46,7 +44,6 @@ import (
"k8s.io/component-base/logs"
"k8s.io/component-base/term"
"k8s.io/component-base/version/verflag"
"k8s.io/klog/v2"

"github.com/brancz/kube-rbac-proxy/cmd/kube-rbac-proxy/app/options"
"github.com/brancz/kube-rbac-proxy/pkg/authn"
Expand Down Expand Up @@ -159,8 +156,7 @@ func Complete(o *options.ProxyRunOptions) (*completedProxyRunOptions, *server.Ku
}

func Run(cfg *server.KubeRBACProxyConfig) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := serverconfig.SetupSignalContext()

var authenticator authenticator.Request
// If OIDC configuration provided, use oidc authenticator
Expand Down Expand Up @@ -223,17 +219,6 @@ func Run(cfg *server.KubeRBACProxyConfig) error {
gr.Add(secureServerRunner(ctx, cfg.KubeRBACProxyInfo.ProxyEndpointsSecureServing, proxyEndpointsMux))
}
}
{
sig := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
<-sig
klog.Info("received interrupt, shutting down")
return nil
}, func(err error) {
close(sig)
})
}

if err := gr.Run(); err != nil {
return fmt.Errorf("failed to run groups: %w", err)
Expand Down

0 comments on commit 0c10f9c

Please sign in to comment.