Skip to content

Commit beba5f5

Browse files
committed
HADOOP-17511. Regression: Test failure in TestHttpReferrerAuditHeader
Change-Id: Ic6ce36df6a3f6e12ed4ee8b6829460e8e875121b
1 parent c61b26b commit beba5f5

3 files changed

Lines changed: 9 additions & 19 deletions

File tree

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/store/audit/HttpReferrerAuditHeader.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ public final class HttpReferrerAuditHeader {
6464

6565
/**
6666
* Format of path to build: {@value}.
67-
* the params passed in are (context ID, span ID, op)
67+
* the params passed in are (context ID, span ID, op).
68+
* Update
69+
* {@code TestHttpReferrerAuditHeader.SAMPLE_LOG_ENTRY} on changes
6870
*/
69-
public static final String REFERRER_PATH_FORMAT = "hadoop/1/%3$s/%2$s/";
71+
public static final String REFERRER_PATH_FORMAT = "/hadoop/1/%3$s/%2$s/";
7072

7173
private static final Logger LOG =
7274
LoggerFactory.getLogger(HttpReferrerAuditHeader.class);
@@ -185,7 +187,7 @@ public String buildHttpReferrer() {
185187
null);
186188
header = uri.toASCIIString();
187189
} catch (URISyntaxException e) {
188-
WARN_OF_URL_CREATION.warn("Failed to build URI for {}/{}", e);
190+
WARN_OF_URL_CREATION.warn("Failed to build URI for auditor: " + e, e);
189191
header = "";
190192
}
191193
return header;

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/audit/impl/LoggingAuditor.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ public class LoggingAuditor
9090
*/
9191
private final Map<String, String> attributes = new HashMap<>();
9292

93-
/**
94-
* UGI principal at time of creation.
95-
* This is mapped into the common context if it is not already set there
96-
* when a span is created.
97-
*/
98-
private final String principal;
99-
10093
/**
10194
* Should the referrer header be added?
10295
*/
@@ -129,15 +122,12 @@ public LoggingAuditor() {
129122

130123

131124
// add the principal
132-
String p;
133125
try {
134126
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
135-
p = ugi.getUserName();
136-
addAttribute(PARAM_PRINCIPAL, p);
137-
} catch (IOException ignored) {
138-
p = "";
127+
addAttribute(PARAM_PRINCIPAL, ugi.getUserName());
128+
} catch (IOException ex) {
129+
LOG.warn("Auditor unable to determine principal", ex);
139130
}
140-
principal = p;
141131
}
142132

143133
/**
@@ -260,8 +250,6 @@ private LoggingAuditSpan(
260250
// thread at the time of creation.
261251
.withAttribute(PARAM_THREAD0,
262252
currentThreadID())
263-
// principal when the auditor was created.
264-
.withAttribute(PARAM_PRINCIPAL, principal)
265253
.withAttribute(PARAM_TIMESTAMP, Long.toString(getTimestamp()))
266254
.withEvaluated(context.getEvaluatedEntries())
267255
.withFilter(filters)

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/audit/TestHttpReferrerAuditHeader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void testHeaderFiltering() throws Throwable {
202202
+ " 794"
203203
+ " 55"
204204
+ " 17"
205-
+ " \"https://audit.example.org/op_create/"
205+
+ " \"https://audit.example.org/hadoop/1/op_create/"
206206
+ "e8ede3c7-8506-4a43-8268-fe8fcbb510a4-00000278/"
207207
+ "?op=op_create"
208208
+ "&p1=fork-0001/test/testParseBrokenCSVFile"

0 commit comments

Comments
 (0)