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:
parent
7b06383163
commit
a439aa79dc
|
@ -245,15 +245,12 @@ public class ServiceApiUtil {
|
||||||
|
|
||||||
public static void validateKerberosPrincipal(
|
public static void validateKerberosPrincipal(
|
||||||
KerberosPrincipal kerberosPrincipal) throws IOException {
|
KerberosPrincipal kerberosPrincipal) throws IOException {
|
||||||
try {
|
if (!StringUtils.isEmpty(kerberosPrincipal.getPrincipalName())) {
|
||||||
if (!kerberosPrincipal.getPrincipalName().contains("/")) {
|
if (!kerberosPrincipal.getPrincipalName().contains("/")) {
|
||||||
throw new IllegalArgumentException(String.format(
|
throw new IllegalArgumentException(String.format(
|
||||||
RestApiErrorMessages.ERROR_KERBEROS_PRINCIPAL_NAME_FORMAT,
|
RestApiErrorMessages.ERROR_KERBEROS_PRINCIPAL_NAME_FORMAT,
|
||||||
kerberosPrincipal.getPrincipalName()));
|
kerberosPrincipal.getPrincipalName()));
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
RestApiErrorMessages.ERROR_KERBEROS_PRINCIPAL_MISSING);
|
|
||||||
}
|
}
|
||||||
if (!StringUtils.isEmpty(kerberosPrincipal.getKeytab())) {
|
if (!StringUtils.isEmpty(kerberosPrincipal.getKeytab())) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -652,6 +652,14 @@ public class TestServiceApiUtil extends ServiceTestUtils {
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
|
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
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue