-
Notifications
You must be signed in to change notification settings - Fork 161
Adds more debug logging to help figure out OIDC/RBAC issues #3308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d329ec2
b82dab2
553aba1
21c8080
3d333d3
5d4f96a
3c26405
d607bb2
c260026
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import ( | |
"github.com/hashicorp/go-multierror" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster" | ||
"github.com/weaveworks/weave-gitops/core/logger" | ||
"github.com/weaveworks/weave-gitops/core/nsaccess" | ||
"github.com/weaveworks/weave-gitops/pkg/featureflags" | ||
"github.com/weaveworks/weave-gitops/pkg/server/auth" | ||
|
@@ -382,6 +383,8 @@ func (cf *clustersManager) updateNamespacesWithClient(ctx context.Context, creat | |
} | ||
} | ||
|
||
cf.log.V(logger.LogLevelDebug).Info("Updated namespaces cache", "namespaces", clusterNamespacesLogValue(cf.clustersNamespaces.namespaces)) | ||
|
||
opsUpdateNamespaces.Inc() | ||
|
||
return result.ErrorOrNil() | ||
|
@@ -589,13 +592,17 @@ func (cf *clustersManager) userNsList(ctx context.Context, user *auth.UserPrinci | |
if err != nil { | ||
// This may not completely fail the request, e.g. if some of the clusters | ||
// are able to respond with their namespaces. So log the error and continue. | ||
cf.log.Error(err, "failed updating namespaces from user client") | ||
cf.log.Error(err, "error updating namespaces from user client", "user", user) | ||
} | ||
} | ||
|
||
cf.UpdateUserNamespaces(ctx, user) | ||
|
||
return cf.GetUserNamespaces(user) | ||
userNamespaces = cf.GetUserNamespaces(user) | ||
|
||
cf.log.V(logger.LogLevelDebug).Info("Updated namespace access cache for user", "userNamespaces", clusterNamespacesLogValue(userNamespaces), "user", user, "ttl", userNamespaceTTL.String()) | ||
|
||
return userNamespaces | ||
} | ||
|
||
func (cf *clustersManager) getOrCreateClient(ctx context.Context, user *auth.UserPrincipal, cluster cluster.Cluster) (client.Client, error) { | ||
|
@@ -633,3 +640,18 @@ func (cf *clustersManager) getOrCreateClient(ctx context.Context, user *auth.Use | |
|
||
return client, nil | ||
} | ||
|
||
// Format the namespaces as a map[clusterName][]namespacesNames | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this scale? What if you have 100+ namespaces? 1000+ ? For clarity, 1000+ is not uncommon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. For the scenarios we've been exploring ~10-15 namespaces its been a real help. But for 1000 I guess some part of your logging system might get grumpy.
I don't know if the structured logging has nested structures in mind.. The count alone would still be useful. |
||
// for logging as a value in a structured log. | ||
func clusterNamespacesLogValue(clusterNamespaces map[string][]v1.Namespace) map[string][]string { | ||
out := map[string][]string{} | ||
for cluster, namespaces := range clusterNamespaces { | ||
namespaceNames := []string{} | ||
for _, n := range namespaces { | ||
namespaceNames = append(namespaceNames, n.Name) | ||
} | ||
out[cluster] = namespaceNames | ||
} | ||
|
||
return out | ||
} |
Uh oh!
There was an error while loading. Please reload this page.