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

Automatically track subloggers in allLoggers #22038

Merged
merged 11 commits into from
Aug 8, 2023
Merged

Automatically track subloggers in allLoggers #22038

merged 11 commits into from
Aug 8, 2023

Conversation

mpalmi
Copy link
Contributor

@mpalmi mpalmi commented Jul 24, 2023

This PR introduces a new interface called SubloggerAdder for tracking
allLoggers across startup phases.

The interface enables us to register a single SubloggerHook during
initial logger creation and hand off management of allLoggers during
the three phases we need to handle:

  • Before CoreConfig is created, the SubloggerHook
    (AppendToAllLoggers) appends new subloggers to
    ServerCommand.allLoggers.

  • After CoreConfig is created and before NewCore returns, new subloggers
    are added to CoreConfig.AllLoggers. Intermediate state must also be
    kept in sync within NewCore to track new subloggers before we return
    to the server command and register the Core.SubloggerAdder
    implementation.

  • After NewCore returns to the server command, we register Core as the
    implementer of ServerCommand.SubloggerAdder ensuring that all new
    subloggers are appended to Core.allLoggers.

Resolves VAULT-18012 and VAULT-18016

This PR introduces a new interface called `SubloggerAdder` for tracking
allLoggers across startup phases.

The interface enables us to register a single `SubloggerHook` during
initial logger creation and hand off management of `allLoggers` during
the three phases we need to handle:

- Before `CoreConfig` is created, the `SubloggerHook`
  (`AppendToAllLoggers`) appends new subloggers to
  `ServerCommand.allLoggers`.

- After `CoreConfig` is created and before `NewCore` returns, new subloggers
  are added to `CoreConfig.AllLoggers`. Intermediate state must also be
  kept in sync within NewCore to track new subloggers before we return
  to the server command and register the `Core.SubloggerAdder`
  implementation.

- After `NewCore` returns to the server command, we register Core as the
  implementer of `ServerCommand.SubloggerAdder` ensuring that all new
  subloggers are appended to `Core.allLoggers`.
@mpalmi mpalmi requested a review from a team July 24, 2023 20:21
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jul 24, 2023
helper/logging/logger.go Outdated Show resolved Hide resolved
@mpalmi mpalmi requested review from ncabatoff and a team July 24, 2023 20:47
vault/testing.go Outdated Show resolved Hide resolved
@github-actions
Copy link

Build Results:
All builds succeeded! ✅

@github-actions
Copy link

CI Results:
All Go tests succeeded! ✅

@mpalmi mpalmi enabled auto-merge (squash) August 8, 2023 17:34
@mpalmi mpalmi merged commit 4c8cc87 into main Aug 8, 2023
94 of 95 checks passed
@mpalmi mpalmi deleted the sublogger-adder branch August 8, 2023 17:47
hellobontempo pushed a commit that referenced this pull request Aug 18, 2023
* Automatically track subloggers in allLoggers

This PR introduces a new interface called `SubloggerAdder` for tracking
allLoggers across startup phases.

The interface enables us to register a single `SubloggerHook` during
initial logger creation and hand off management of `allLoggers` during
the three phases we need to handle:

- Before `CoreConfig` is created, the `SubloggerHook`
  (`AppendToAllLoggers`) appends new subloggers to
  `ServerCommand.allLoggers`.

- After `CoreConfig` is created and before `NewCore` returns, new subloggers
  are added to `CoreConfig.AllLoggers`. Intermediate state must also be
  kept in sync within NewCore to track new subloggers before we return
  to the server command and register the `Core.SubloggerAdder`
  implementation.

- After `NewCore` returns to the server command, we register Core as the
  implementer of `ServerCommand.SubloggerAdder` ensuring that all new
  subloggers are appended to `Core.allLoggers`.

* Wire up the sublogger hook in NewTestLogger
hghaf099 added a commit that referenced this pull request Nov 3, 2023
hghaf099 added a commit that referenced this pull request Nov 3, 2023
hghaf099 added a commit that referenced this pull request Nov 3, 2023
hghaf099 added a commit that referenced this pull request Nov 3, 2023
hghaf099 added a commit that referenced this pull request Nov 3, 2023
hghaf099 added a commit that referenced this pull request Nov 3, 2023
hghaf099 added a commit that referenced this pull request Nov 3, 2023
)" into release/1.15.x (#24003)

* backport of commit 9d3617e

* use new logger variables in init funcs

---------

Co-authored-by: Hamid Ghaf <83242695+hghaf099@users.noreply.github.com>
Co-authored-by: hamid ghaf <hamid@hashicorp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants