YARN-8879. Kerberos principal is needed when submitting a submarine job. Contributed by Zac Zhou.

This commit is contained in:
Sunil G 2018-10-16 22:17:51 +05:30
parent 0c2914e582
commit 753f149fd3
2 changed files with 9 additions and 4 deletions

View File

@ -245,15 +245,12 @@ public static void validateAndResolveService(Service service,
public static void validateKerberosPrincipal(
KerberosPrincipal kerberosPrincipal) throws IOException {
try {
if (!StringUtils.isEmpty(kerberosPrincipal.getPrincipalName())) {
if (!kerberosPrincipal.getPrincipalName().contains("/")) {
throw new IllegalArgumentException(String.format(
RestApiErrorMessages.ERROR_KERBEROS_PRINCIPAL_NAME_FORMAT,
kerberosPrincipal.getPrincipalName()));
}
} catch (NullPointerException e) {
throw new IllegalArgumentException(
RestApiErrorMessages.ERROR_KERBEROS_PRINCIPAL_MISSING);
}
if (!StringUtils.isEmpty(kerberosPrincipal.getKeytab())) {
try {

View File

@ -652,6 +652,14 @@ public void testKerberosPrincipalNameFormat() throws IOException {
} catch (IllegalArgumentException e) {
Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
}
kp.setPrincipalName(null);
kp.setKeytab(null);
try {
ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
} catch (NullPointerException e) {
Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
}
}
@Test