Skip to content

Fix log row which caused panic#4193

Closed
marulkan wants to merge 3 commits intoweaveworks:mainfrom
marulkan:log-row-fix
Closed

Fix log row which caused panic#4193
marulkan wants to merge 3 commits intoweaveworks:mainfrom
marulkan:log-row-fix

Conversation

@marulkan
Copy link
Copy Markdown

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
Copy Markdown
Collaborator

@marulkan Please can you provide more details on this fix

@erikgb
Copy link
Copy Markdown
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).

Comment thread core/server/inventory.go
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
Copy Markdown
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
Copy Markdown
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!

@erikgb erikgb closed this in #4478 Jan 9, 2025
auto-merge was automatically disabled January 9, 2025 21:15

Pull request was closed

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