Skip to content
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

Fix log row which caused panic #4193

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

marulkan
Copy link

Closes

What changed?
Log line which cause panic

Why was this change made?
Bugfix

How was this change implemented?

How did you validate the change?
Implemented change in cluster where we had a helmchart which triggered this panic (old PSP cr).

Release notes

Documentation Changes

@casibbald casibbald enabled auto-merge (squash) November 14, 2024 17:53
@casibbald
Copy link
Collaborator

@marulkan Please can you provide more details on this fix

@erikgb
Copy link
Contributor

erikgb commented Jan 3, 2025

@casibbald I am pretty sure this PR is fixing a real issue. If you look at the signature of logr Logger function:

func (l Logger) Error(err error, msg string, keysAndValues ...any)

The last variadic parameter needs to have a pair number arguments (key + value).

@@ -286,7 +286,7 @@ func getObjectsWithChildren(ctx context.Context, defaultNS string, objects []*un
if !ok {
namespaced, err = apiutil.IsObjectNamespaced(&obj, k8sClient.Scheme(), k8sClient.RESTMapper())
if err != nil {
logger.Error(err, "failed to determine if %s is namespace scoped", obj.GetObjectKind().GroupVersionKind().Kind)
logger.Error(err, "failed to determine if %s is namespace scoped", "entry", obj)
Copy link
Contributor

@erikgb erikgb Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Error(err, "failed to determine if %s is namespace scoped", "entry", obj)
logger.Error(err, "failed to determine if object is namespace scoped", "kind", obj.GetObjectKind().GroupVersionKind().Kind)

To avoid logging the full object.

Copy link
Contributor

@erikgb erikgb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marulkan Do you want to fix/rebase/squash this PR, or should I just do it? Please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants