YARN-2449. Fixed the bug that TimelineAuthenticationFilterInitializer is not automatically added when hadoop.http.filter.initializers is not configured. Contributed by Varun Vasudev.
(cherry picked from commit 4bd0194e6b
)
This commit is contained in:
parent
f237dee156
commit
77a4b014e6
|
@ -231,6 +231,10 @@ Release 2.6.0 - UNRELEASED
|
||||||
|
|
||||||
YARN-2405. NPE in FairSchedulerAppsBlock. (Tsuyoshi Ozawa via kasha)
|
YARN-2405. NPE in FairSchedulerAppsBlock. (Tsuyoshi Ozawa via kasha)
|
||||||
|
|
||||||
|
YARN-2449. Fixed the bug that TimelineAuthenticationFilterInitializer
|
||||||
|
is not automatically added when hadoop.http.filter.initializers is not
|
||||||
|
configured. (Varun Vasudev via zjshen)
|
||||||
|
|
||||||
Release 2.5.1 - UNRELEASED
|
Release 2.5.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -197,6 +197,7 @@ public class ApplicationHistoryServer extends CompositeService {
|
||||||
// the customized filter will be loaded by the timeline server to do Kerberos
|
// the customized filter will be loaded by the timeline server to do Kerberos
|
||||||
// + DT authentication.
|
// + DT authentication.
|
||||||
String initializers = conf.get("hadoop.http.filter.initializers");
|
String initializers = conf.get("hadoop.http.filter.initializers");
|
||||||
|
boolean modifiedInitialiers = false;
|
||||||
|
|
||||||
initializers =
|
initializers =
|
||||||
initializers == null || initializers.length() == 0 ? "" : initializers;
|
initializers == null || initializers.length() == 0 ? "" : initializers;
|
||||||
|
@ -206,6 +207,7 @@ public class ApplicationHistoryServer extends CompositeService {
|
||||||
initializers =
|
initializers =
|
||||||
TimelineAuthenticationFilterInitializer.class.getName() + ","
|
TimelineAuthenticationFilterInitializer.class.getName() + ","
|
||||||
+ initializers;
|
+ initializers;
|
||||||
|
modifiedInitialiers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] parts = initializers.split(",");
|
String[] parts = initializers.split(",");
|
||||||
|
@ -214,13 +216,14 @@ public class ApplicationHistoryServer extends CompositeService {
|
||||||
filterInitializer = filterInitializer.trim();
|
filterInitializer = filterInitializer.trim();
|
||||||
if (filterInitializer.equals(AuthenticationFilterInitializer.class
|
if (filterInitializer.equals(AuthenticationFilterInitializer.class
|
||||||
.getName())) {
|
.getName())) {
|
||||||
|
modifiedInitialiers = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
target.add(filterInitializer);
|
target.add(filterInitializer);
|
||||||
}
|
}
|
||||||
String actualInitializers =
|
String actualInitializers =
|
||||||
org.apache.commons.lang.StringUtils.join(target, ",");
|
org.apache.commons.lang.StringUtils.join(target, ",");
|
||||||
if (!actualInitializers.equals(initializers)) {
|
if (modifiedInitialiers) {
|
||||||
conf.set("hadoop.http.filter.initializers", actualInitializers);
|
conf.set("hadoop.http.filter.initializers", actualInitializers);
|
||||||
}
|
}
|
||||||
String bindAddress = WebAppUtils.getWebAppBindURL(conf,
|
String bindAddress = WebAppUtils.getWebAppBindURL(conf,
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.http.lib.StaticUserWebFilter;
|
||||||
import org.apache.hadoop.security.AuthenticationFilterInitializer;
|
import org.apache.hadoop.security.AuthenticationFilterInitializer;
|
||||||
import org.apache.hadoop.service.Service.STATE;
|
import org.apache.hadoop.service.Service.STATE;
|
||||||
import org.apache.hadoop.util.ExitUtil;
|
import org.apache.hadoop.util.ExitUtil;
|
||||||
|
@ -33,6 +34,9 @@ import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class TestApplicationHistoryServer {
|
public class TestApplicationHistoryServer {
|
||||||
|
|
||||||
ApplicationHistoryServer historyServer = null;
|
ApplicationHistoryServer historyServer = null;
|
||||||
|
@ -75,23 +79,32 @@ public class TestApplicationHistoryServer {
|
||||||
@Test(timeout = 50000)
|
@Test(timeout = 50000)
|
||||||
public void testFilteOverrides() throws Exception {
|
public void testFilteOverrides() throws Exception {
|
||||||
|
|
||||||
String[] filterInitializers =
|
HashMap<String, String> driver = new HashMap<String, String>();
|
||||||
{
|
driver.put("", TimelineAuthenticationFilterInitializer.class.getName());
|
||||||
AuthenticationFilterInitializer.class.getName(),
|
driver.put(StaticUserWebFilter.class.getName(),
|
||||||
TimelineAuthenticationFilterInitializer.class.getName(),
|
TimelineAuthenticationFilterInitializer.class.getName() + ","
|
||||||
AuthenticationFilterInitializer.class.getName() + ","
|
+ StaticUserWebFilter.class.getName());
|
||||||
+ TimelineAuthenticationFilterInitializer.class.getName(),
|
driver.put(AuthenticationFilterInitializer.class.getName(),
|
||||||
AuthenticationFilterInitializer.class.getName() + ", "
|
TimelineAuthenticationFilterInitializer.class.getName());
|
||||||
+ TimelineAuthenticationFilterInitializer.class.getName() };
|
driver.put(TimelineAuthenticationFilterInitializer.class.getName(),
|
||||||
for (String filterInitializer : filterInitializers) {
|
TimelineAuthenticationFilterInitializer.class.getName());
|
||||||
|
driver.put(AuthenticationFilterInitializer.class.getName() + ","
|
||||||
|
+ TimelineAuthenticationFilterInitializer.class.getName(),
|
||||||
|
TimelineAuthenticationFilterInitializer.class.getName());
|
||||||
|
driver.put(AuthenticationFilterInitializer.class.getName() + ", "
|
||||||
|
+ TimelineAuthenticationFilterInitializer.class.getName(),
|
||||||
|
TimelineAuthenticationFilterInitializer.class.getName());
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : driver.entrySet()) {
|
||||||
|
String filterInitializer = entry.getKey();
|
||||||
|
String expectedValue = entry.getValue();
|
||||||
historyServer = new ApplicationHistoryServer();
|
historyServer = new ApplicationHistoryServer();
|
||||||
Configuration config = new YarnConfiguration();
|
Configuration config = new YarnConfiguration();
|
||||||
config.set("hadoop.http.filter.initializers", filterInitializer);
|
config.set("hadoop.http.filter.initializers", filterInitializer);
|
||||||
historyServer.init(config);
|
historyServer.init(config);
|
||||||
historyServer.start();
|
historyServer.start();
|
||||||
Configuration tmp = historyServer.getConfig();
|
Configuration tmp = historyServer.getConfig();
|
||||||
assertEquals(TimelineAuthenticationFilterInitializer.class.getName(),
|
assertEquals(expectedValue, tmp.get("hadoop.http.filter.initializers"));
|
||||||
tmp.get("hadoop.http.filter.initializers"));
|
|
||||||
historyServer.stop();
|
historyServer.stop();
|
||||||
AHSWebApp.resetInstance();
|
AHSWebApp.resetInstance();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue