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

Switch to log4j logger #1751

Merged
merged 1 commit into from
Apr 7, 2022
Merged

Conversation

peternied
Copy link
Member

Description

In OpenSearch 1.3.0 we removed an explicit dependency on log4j
#1563 this caused the
log4j-slf4j-impl-X.XX.X.jar file no longer to be included in the plugin.
When the plugin started up the default no-op logger was used instead.
This prevented the security plugin from logging anything, yikes.

When looking at the other opensearch plugins, none of them use slf4.
Rather than continue using a seperate logging process, moving to the
standard log4j Logger/LogManager.

Tested this change on 2.0.0-alpha distribution and logging works as
expected.

Issues Resolved

Testing

Downloaded the min versions of opensearch 2.0.0-alpha1, then build the plugin, verified that the log output included lines like [2022-04-07T18:07:42,441][INFO ][o.o.s.OpenSearchSecurityPlugin] [dev-dsk-petern-1e-d7e6bfc0.us-east-1.amazon.com] 0 OpenSearch Security modules loaded so far: [] that were previously not present

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

In OpenSearch 1.3.0 we removed an explicit dependency on log4j
opensearch-project#1563 this caused the
log4j-slf4j-impl-X.XX.X.jar file no longer to be included in the plugin.
When the plugin started up the default no-op logger was used instead.
This prevented the security plugin from logging anything, yikes.

When looking at the other opensearch plugins, none of them use slf4.
Rather than continue using a seperate logging process, moving to the
standard log4j Logger/LogManager.

Tested this change on 2.0.0-alpha distribution and logging works as
expected.

Signed-off-by: Peter Nied <petern@amazon.com>
@peternied peternied requested a review from a team April 7, 2022 18:15
@peternied peternied self-assigned this Apr 7, 2022
@peternied peternied added the bug Something isn't working label Apr 7, 2022
@peternied
Copy link
Member Author

@cliu123 This seems like a bad bug to keep in the 1.3.X release line, what do you think about backporting this change?

@cliu123
Copy link
Member

cliu123 commented Apr 7, 2022

@cliu123 This seems like a bad bug to keep in the 1.3.X release line, what do you think about backporting this change?

Is this basically reverting the commit? If that's the case, @davidlago has more context on the commit being reverted. Would you plesae provide the context of the original commit?

@davidlago
Copy link

#1563 removed the explicit dependency and lets core provide it instead. SLF4J provides that layer of abstraction, and the thrust behind that PR was to get us off of declaring it as an explicit dependency so that if new bugs/issues are found, only core needs to update the jar they provide and we should be all set.

I agree that this should be backported to the 1.x line. @peternied is this something we can fix without adding back the dependency? (i.e. figure out why the jar is not being picked up from core and address that instead?)

@codecov-commenter
Copy link

codecov-commenter commented Apr 7, 2022

Codecov Report

Merging #1751 (2e3cd91) into main (2744081) will increase coverage by 0.02%.
The diff coverage is 93.06%.

@@             Coverage Diff              @@
##               main    #1751      +/-   ##
============================================
+ Coverage     60.40%   60.42%   +0.02%     
- Complexity     3196     3197       +1     
============================================
  Files           253      253              
  Lines         18093    18093              
  Branches       3245     3245              
============================================
+ Hits          10929    10933       +4     
+ Misses         5583     5579       -4     
  Partials       1581     1581              
Impacted Files Coverage Δ
...byoidc/HTTPJwtKeyByOpenIdConnectAuthenticator.java 94.11% <ø> (ø)
...ic/auth/http/kerberos/HTTPSpnegoAuthenticator.java 0.00% <0.00%> (ø)
...ensearch/security/auditlog/config/AuditConfig.java 98.85% <ø> (ø)
...pensearch/security/securityconf/ConfigModelV6.java 0.00% <0.00%> (ø)
...ssl/transport/SecuritySSLTransportInterceptor.java 0.00% <0.00%> (ø)
...va/org/opensearch/security/support/HTTPHelper.java 84.61% <ø> (ø)
...search/security/configuration/DlsFlsValveImpl.java 59.25% <33.33%> (ø)
...ic/auth/http/jwt/AbstractHTTPJwtAuthenticator.java 55.81% <100.00%> (ø)
...mazon/dlic/auth/http/jwt/HTTPJwtAuthenticator.java 84.90% <100.00%> (ø)
...azon/dlic/auth/http/jwt/keybyoidc/JwtVerifier.java 85.71% <100.00%> (ø)
... and 89 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2744081...2e3cd91. Read the comment docs.

@peternied
Copy link
Member Author

@peternied is this something we can fix without adding back the dependency? (i.e. figure out why the jar is not being picked up from core and address that instead?)

Yes the dependency can stay out as the library is available from OpenSearch's classpath.

@peternied peternied merged commit 54a920b into opensearch-project:main Apr 7, 2022
@peternied peternied deleted the logger branch April 7, 2022 21:57
@peternied peternied added backport 1.x backport to 1.x branch backport 1.3 backport to 1.3 branch labels Apr 8, 2022
@opensearch-trigger-bot
Copy link
Contributor

The backport to 1.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.x 1.x
# Navigate to the new working tree
cd .worktrees/backport-1.x
# Create a new branch
git switch --create backport/backport-1751-to-1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 54a920b20bd520f25aef328c1bb4997b325f46ce
# Push it to GitHub
git push --set-upstream origin backport/backport-1751-to-1.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.x

Then, create a pull request where the base branch is 1.x and the compare/head branch is backport/backport-1751-to-1.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 1.3 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.3 1.3
# Navigate to the new working tree
cd .worktrees/backport-1.3
# Create a new branch
git switch --create backport/backport-1751-to-1.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 54a920b20bd520f25aef328c1bb4997b325f46ce
# Push it to GitHub
git push --set-upstream origin backport/backport-1751-to-1.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.3

Then, create a pull request where the base branch is 1.3 and the compare/head branch is backport/backport-1751-to-1.3.

@peternied peternied mentioned this pull request Apr 8, 2022
2 tasks
@peternied
Copy link
Member Author

Created #1753 to backport this change

DarshitChanpura pushed a commit to DarshitChanpura/security that referenced this pull request Apr 25, 2022
In OpenSearch 1.3.0 we removed an explicit dependency on log4j
opensearch-project#1563 this caused the
log4j-slf4j-impl-X.XX.X.jar file no longer to be included in the plugin.
When the plugin started up the default no-op logger was used instead.
This prevented the security plugin from logging anything, yikes.

When looking at the other opensearch plugins, none of them use slf4.
Rather than continue using a seperate logging process, moving to the
standard log4j Logger/LogManager.

Tested this change on 2.0.0-alpha distribution and logging works as
expected.

Signed-off-by: Peter Nied <petern@amazon.com>
(cherry picked from commit 54a920b)
DarshitChanpura pushed a commit to DarshitChanpura/security that referenced this pull request Apr 25, 2022
In OpenSearch 1.3.0 we removed an explicit dependency on log4j
opensearch-project#1563 this caused the
log4j-slf4j-impl-X.XX.X.jar file no longer to be included in the plugin.
When the plugin started up the default no-op logger was used instead.
This prevented the security plugin from logging anything, yikes.

When looking at the other opensearch plugins, none of them use slf4.
Rather than continue using a seperate logging process, moving to the
standard log4j Logger/LogManager.

Tested this change on 2.0.0-alpha distribution and logging works as
expected.

Signed-off-by: Peter Nied <petern@amazon.com>
(cherry picked from commit 54a920b)
DarshitChanpura added a commit that referenced this pull request Apr 28, 2022
* Switch to log4j logger (#1751)

In OpenSearch 1.3.0 we removed an explicit dependency on log4j
#1563 this caused the
log4j-slf4j-impl-X.XX.X.jar file no longer to be included in the plugin.
When the plugin started up the default no-op logger was used instead.
This prevented the security plugin from logging anything, yikes.

When looking at the other opensearch plugins, none of them use slf4.
Rather than continue using a seperate logging process, moving to the
standard log4j Logger/LogManager.

Tested this change on 2.0.0-alpha distribution and logging works as
expected.

Signed-off-by: Peter Nied <petern@amazon.com>
(cherry picked from commit 54a920b)

* Fix 2 files that missed the update

Signed-off-by: Peter Nied <petern@amazon.com>

* Adds logger to missed files

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

Co-authored-by: Peter Nied <petern@amazon.com>
wuychn pushed a commit to ochprince/security that referenced this pull request Mar 16, 2023
In OpenSearch 1.3.0 we removed an explicit dependency on log4j
opensearch-project#1563 this caused the
log4j-slf4j-impl-X.XX.X.jar file no longer to be included in the plugin.
When the plugin started up the default no-op logger was used instead.
This prevented the security plugin from logging anything, yikes.

When looking at the other opensearch plugins, none of them use slf4.
Rather than continue using a seperate logging process, moving to the
standard log4j Logger/LogManager.

Tested this change on 2.0.0-alpha distribution and logging works as
expected.

Signed-off-by: Peter Nied <petern@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.x backport to 1.x branch backport 1.3 backport to 1.3 branch bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Unable to configure debug/trace logging for security plugins
4 participants