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

(cherry picked from commit 753f149fd3)
This commit is contained in:
Sunil G 2018-10-16 22:17:51 +05:30
parent 7b06383163
commit a439aa79dc
2 changed files with 9 additions and 4 deletions

View File

@ -245,15 +245,12 @@ public class ServiceApiUtil {
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 class TestServiceApiUtil extends ServiceTestUtils {
} 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