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

Use native logrus caller lookup. #9044

Merged
merged 2 commits into from
Jul 24, 2024
Merged

Conversation

fasaxc
Copy link
Member

@fasaxc fasaxc commented Jul 22, 2024

Description

Remove our ContextHook in favour of using logrus' built in functionality to look up the file/line of the caller.

I thought this fixed a concurrency bug where the ContextHook wrote to the Data map concurrently with another log reading it (when sharing log contexts between goroutines). However, when I wrote a test to detect that via the race detector, I realised that upstream logrus had fixed that issue a while ago by duplicating the entry before calling hooks.

Related issues/PRs

Todos

  • Tests
  • Documentation
  • Release note

Release Note

Calico now uses the logging framework's built in capability to capture the caller's filename/line number.  This removes a potential source of concurrency bugs.

Reminder for the reviewer

Make sure that this PR has the correct labels and milestone set.

Every PR needs one docs-* label.

  • docs-pr-required: This change requires a change to the documentation that has not been completed yet.
  • docs-completed: This change has all necessary documentation completed.
  • docs-not-required: This change has no user-facing impact and requires no docs.

Every PR needs one release-note-* label.

  • release-note-required: This PR has user-facing changes. Most PRs should have this label.
  • release-note-not-required: This PR has no user-facing changes.

Other optional labels:

  • cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.
  • needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.

@marvin-tigera marvin-tigera added this to the Calico v3.29.0 milestone Jul 22, 2024
@marvin-tigera marvin-tigera added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Jul 22, 2024
@fasaxc fasaxc added the docs-not-required Docs not required for this change label Jul 22, 2024
@marvin-tigera marvin-tigera removed the docs-pr-required Change is not yet documented label Jul 22, 2024
Remove our ContextHook in favour of using logrus' built in functionality
to look up the file/line of the caller.

Fixes that the ContextHook would modify the fields of the entry when it
fired, which could result in concurrent modifications when re-using a
log context in a goroutine.
@fasaxc fasaxc force-pushed the logrus-caller branch 2 times, most recently from b3d8f44 to c8b3496 Compare July 22, 2024 15:49
@fasaxc fasaxc marked this pull request as ready for review July 22, 2024 15:57
@fasaxc fasaxc requested a review from a team as a code owner July 22, 2024 15:57
@fasaxc fasaxc merged commit 7ae1027 into projectcalico:master Jul 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required Docs not required for this change release-note-required Change has user-facing impact (no matter how small)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants