Skip to content

Commit

Permalink
merge log-client-go-auth (kubernetes#129336)
Browse files Browse the repository at this point in the history
  • Loading branch information
pohly committed Dec 20, 2024
2 parents a4495ed + a392191 commit 4d1a4d8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

func init() {
if err := rest.RegisterAuthProviderPlugin("azure", newAzureAuthProvider); err != nil {
//nolint:logcheck // Should not happen.
klog.Fatalf("Failed to register azure auth plugin: %v", err)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func (r *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return r.base.RoundTrip(req)
}

ctx := req.Context()
creds, err := r.a.getCreds()
if err != nil {
return nil, fmt.Errorf("getting credentials: %v", err)
Expand All @@ -356,7 +357,7 @@ func (r *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
}
if res.StatusCode == http.StatusUnauthorized {
if err := r.a.maybeRefreshCreds(creds); err != nil {
klog.Errorf("refreshing credentials: %v", err)
klog.FromContext(ctx).Error(err, "Refreshing credentials failed")
}
}
return res, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func incrementCallsMetric(err error) {
metrics.ExecPluginCalls.Increment(failureExitCode, pluginNotFoundError)

default: // We don't know about this error type.
//nolint:logcheck // This looks like debug output which shouldn't occur in practice.
klog.V(2).InfoS("unexpected exec plugin return error type", "type", reflect.TypeOf(err).String(), "err", err)
metrics.ExecPluginCalls.Increment(failureExitCode, clientInternalError)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

func init() {
if err := rest.RegisterAuthProviderPlugin("gcp", newGCPAuthProvider); err != nil {
//nolint:logcheck // Should not happen.
klog.Fatalf("Failed to register gcp auth plugin: %v", err)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (

func init() {
if err := restclient.RegisterAuthProviderPlugin("oidc", newOIDCAuthProvider); err != nil {
//nolint:logcheck // Should not happen.
klog.Fatalf("Failed to register oidc auth plugin: %v", err)
}
}
Expand Down Expand Up @@ -125,6 +126,7 @@ func newOIDCAuthProvider(clusterAddress string, cfg map[string]string, persister
}

if len(cfg[cfgExtraScopes]) > 0 {
//nolint:logcheck // Should not happen.
klog.V(2).Infof("%s auth provider field depricated, refresh request don't send scopes",
cfgExtraScopes)
}
Expand Down

0 comments on commit 4d1a4d8

Please sign in to comment.