-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-18094. Disable S3A auditing by default. #3916
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
Merged
steveloughran
merged 3 commits into
apache:trunk
from
steveloughran:s3/HADOOP-18091-audit-leak
Jan 24, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,18 @@ and inside the AWS S3 SDK, immediately before the request is executed. | |
| The full architecture is covered in [Auditing Architecture](auditing_architecture.html); | ||
| this document covers its use. | ||
|
|
||
| ## Important: Auditing is disabled by default | ||
|
|
||
| Due to a memory leak from the use of `ThreadLocal` fields, this auditing feature leaks memory as S3A filesystem | ||
| instances are created and deleted. | ||
| This causes problems in long-lived processes which either do not re-use filesystem | ||
| instances, or attempt to delete all instances belonging to specific users. | ||
| See [HADOOP-18091](https://issues.apache.org/jira/browse/HADOOP-18091) _S3A auditing leaks memory through ThreadLocal references_. | ||
|
|
||
| To avoid these memory leaks, auditing is disabled by default. | ||
|
|
||
| To turn auditing on, set `fs.s3a.audit.enabled` to `true`. | ||
|
|
||
| ## Auditing workflow | ||
|
|
||
| 1. An _Auditor Service_ can be instantiated for each S3A FileSystem instance, | ||
|
|
@@ -63,27 +75,43 @@ ideally even identifying the process/job generating load. | |
|
|
||
| ## Using Auditing | ||
|
|
||
| The Logging Auditor is enabled by default; it annotates the S3 logs. | ||
| Auditing is disabled by default. | ||
| When auditing enabled, a Logging Auditor will annotate the S3 logs through a custom | ||
| HTTP Referrer header in requests made to S3. | ||
| Other auditor classes may be used instead. | ||
|
|
||
| ### Auditor Options | ||
|
|
||
| | Option | Meaning | Default Value | | ||
| |--------|---------|---------------| | ||
| | `fs.s3a.audit.enabled` | Is auditing enabled | `false` | | ||
| | `fs.s3a.audit.service.classname` | Auditor classname | `org.apache.hadoop.fs.s3a.audit.impl.LoggingAuditor` | | ||
| | `fs.s3a.audit.request.handlers` | List of extra subclasses of AWS SDK RequestHandler2 to include in handler chain | `""` | | ||
| | `fs.s3a.audit.referrer.enabled` | Logging auditor to publish the audit information in the HTTP Referrer header | `true` | | ||
| | `fs.s3a.audit.referrer.filter` | List of audit fields to filter | `""` | | ||
| | `fs.s3a.audit.reject.out.of.span.operations` | Auditor to reject operations "outside of a span" | `false` | | ||
|
|
||
|
|
||
| ### Disabling Auditing with the No-op Auditor | ||
| ### Disabling Auditing. | ||
|
|
||
| In this release of Hadoop, auditing is disabled. | ||
|
|
||
| The No-op auditor does not perform any logging of audit events. | ||
| This can be explicitly set globally or for specific buckets | ||
|
|
||
| ```xml | ||
| <property> | ||
| <name>fs.s3a.audit.service.classname</name> | ||
| <value>org.apache.hadoop.fs.s3a.audit.impl.NoopAuditor</value> | ||
| <name>fs.s3a.audit.enabled</name> | ||
| <value>false</value> | ||
| </property> | ||
| ``` | ||
|
|
||
| Specific buckets can have auditing disabled, even when it is enabled globally. | ||
|
|
||
| ```xml | ||
| <property> | ||
| <name>fs.s3a.bucket.landsat-pds.audit.enabled</name> | ||
| <value>false</value> | ||
| <description>Do not audit landsat bucket operations</description> | ||
| </property> | ||
| ``` | ||
|
|
||
|
|
@@ -92,13 +120,18 @@ The No-op auditor does not perform any logging of audit events. | |
| The "Logging Auditor" is the default auditor. | ||
| It provides two forms of logging | ||
|
|
||
| 1. Logging of operations in the client via Log4J. | ||
| 1. Logging of operations in the client via the active SLF4J imolementation. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: typo: "implementation" |
||
| 1. Dynamic generation of the HTTP Referrer header for S3 requests. | ||
|
|
||
| The Logging Auditor is enabled by providing its classname in the option | ||
| `fs.s3a.audit.service.classname`. | ||
|
|
||
| ```xml | ||
| <property> | ||
| <name>fs.s3a.audit.enabled</name> | ||
| <value>true</value> | ||
| </property> | ||
|
|
||
| <property> | ||
| <name>fs.s3a.audit.service.classname</name> | ||
| <value>org.apache.hadoop.fs.s3a.audit.impl.LoggingAuditor</value> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...ls/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/audit/ITestAuditManagerDisabled.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.fs.s3a.audit; | ||
|
|
||
| import org.assertj.core.api.Assertions; | ||
| import org.junit.Test; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.s3a.S3AFileSystem; | ||
| import org.apache.hadoop.fs.s3a.audit.impl.NoopAuditManagerS3A; | ||
| import org.apache.hadoop.fs.s3a.performance.AbstractS3ACostTest; | ||
|
|
||
| import static org.apache.hadoop.fs.s3a.audit.AuditTestSupport.NOOP_SPAN; | ||
| import static org.apache.hadoop.fs.s3a.audit.AuditTestSupport.resetAuditOptions; | ||
|
|
||
| /** | ||
| * Verify that by default audit managers are disabled. | ||
| */ | ||
| public class ITestAuditManagerDisabled extends AbstractS3ACostTest { | ||
|
|
||
| public ITestAuditManagerDisabled() { | ||
| super(true); | ||
| } | ||
|
|
||
| @Override | ||
| public Configuration createConfiguration() { | ||
| Configuration conf = super.createConfiguration(); | ||
| resetAuditOptions(conf); | ||
| return conf; | ||
| } | ||
|
|
||
| /** | ||
| * The default auditor is the no-op auditor. | ||
| */ | ||
| @Test | ||
| public void testAuditorDisabled() { | ||
|
|
||
| final S3AFileSystem fs = getFileSystem(); | ||
| final AuditManagerS3A auditManager = fs.getAuditManager(); | ||
|
|
||
| Assertions.assertThat(auditManager) | ||
| .isInstanceOf(NoopAuditManagerS3A.class); | ||
| } | ||
|
|
||
| /** | ||
| * All the audit spans are the no-op span. | ||
| */ | ||
| @Test | ||
| public void testAuditSpansAreAllTheSame() throws Throwable { | ||
|
|
||
| final S3AFileSystem fs = getFileSystem(); | ||
| final AuditSpanS3A span1 = fs.createSpan("span1", null, null); | ||
| final AuditSpanS3A span2 = fs.createSpan("span2", null, null); | ||
| Assertions.assertThat(span1) | ||
| .describedAs("audit span 1") | ||
| .isSameAs(NOOP_SPAN); | ||
| Assertions.assertThat(span2) | ||
| .describedAs("audit span 2") | ||
| .isSameAs(span1); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a mention that servicename=NoopAuditor also disables auditing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't though. it stil leaks memory as the service manager is still instantiated.
which is why i've cut it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, you're right. Just realized, ActiveAuditManager with NoopAuditor would still leak, but NoopAuditManager is the one without the ThreadLocal variable now. Thanks for clearing it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding to the architecture as an FYI point