Skip to content

Commit

Permalink
Merge pull request #18615 from Zech-Hein/add-kdc-failover-logic
Browse files Browse the repository at this point in the history
add spnegoFAT.1 kdc failover logic
  • Loading branch information
Zech-Hein authored Sep 18, 2021
2 parents 5b693e5 + ac0a08b commit 9289d72
Showing 1 changed file with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void getKDCInfoFromConsul() throws Exception {

try {
//obtaining kdcp and kdc_r information
services = CommonTest.getKDCServices(1, SPNEGOConstants.KDC_HOST_FROM_CONSUL);
services = CommonTest.getKDCServices(2, SPNEGOConstants.KDC_HOST_FROM_CONSUL);
KDC_HOSTNAME = services.get(0).getAddress();
KDC_USER = services.get(0).getProperties().get(SPNEGOConstants.MS_KDC_USER_CONSUL);
KDC_USER_PWD = services.get(0).getProperties().get(SPNEGOConstants.MS_KDC_USER_PASSWORD_CONSUL);
Expand All @@ -117,6 +117,33 @@ public static void getKDCInfoFromConsul() throws Exception {
USER_PWD = services.get(0).getProperties().get(SPNEGOConstants.USER_PWD_FROM_CONSUL);
Z_USER_PWD = services.get(0).getProperties().get(SPNEGOConstants.USER0_PWD_FROM_CONSUL);

ConnectionInfo connInfo = new ConnectionInfo(KDC_HOSTNAME, InitClass.KDC_USER, InitClass.KDC_USER_PWD);
Machine kdcMachine = Machine.getMachine(connInfo);

try {
Log.info(c, thisMethod, "Testing connection to KDC: " + KDC_HOST_SHORTNAME);
establishConnectionToKDC(thisMethod, kdcMachine);
} catch (Exception e) {
String failedKdcShortName = KDC_HOST_SHORTNAME;
KDC_HOSTNAME = services.get(1).getAddress();
KDC_USER = services.get(1).getProperties().get(SPNEGOConstants.MS_KDC_USER_CONSUL);
KDC_USER_PWD = services.get(1).getProperties().get(SPNEGOConstants.MS_KDC_USER_PASSWORD_CONSUL);
KDC_REALM = services.get(1).getProperties().get(SPNEGOConstants.KDC_REALM_FROM_CONSUL);
KDC_HOST_SHORTNAME = services.get(1).getProperties().get(SPNEGOConstants.KDC_SHORTNAME_FROM_CONSUL);
KRB5_CONF = services.get(1).getProperties().get(SPNEGOConstants.KRB5_CONF_FROM_CONSUL);
Z_USER = services.get(1).getProperties().get(SPNEGOConstants.Z_USER_FROM_CONSUL);
FIRST_USER = services.get(1).getProperties().get(SPNEGOConstants.FIRST_USER_FROM_CONSUL);
SECOND_USER = services.get(1).getProperties().get(SPNEGOConstants.SECOND_USER_FROM_CONSUL);
USER_PWD = services.get(1).getProperties().get(SPNEGOConstants.USER_PWD_FROM_CONSUL);
Z_USER_PWD = services.get(1).getProperties().get(SPNEGOConstants.USER0_PWD_FROM_CONSUL);

Log.info(c, thisMethod, "connection to " + failedKdcShortName + " failed. Attempting failover KDC: " + KDC_HOST_SHORTNAME);

connInfo = new ConnectionInfo(KDC_HOSTNAME, InitClass.KDC_USER, InitClass.KDC_USER_PWD);
kdcMachine = Machine.getMachine(connInfo);
establishConnectionToKDC(thisMethod, kdcMachine);
}

KDCP_VAR = getKDCHostnameMask(KDC_HOSTNAME);

//obtaining kdcs and kdcs_r information
Expand All @@ -137,10 +164,6 @@ public static void getKDCInfoFromConsul() throws Exception {
SECOND_USER_KRB5_FQN = SECOND_USER + FQN;
COMMON_TOKEN_USER = FIRST_USER;
COMMON_TOKEN_USER_PWD = FIRST_USER_PWD;
ConnectionInfo connInfo = new ConnectionInfo(KDC_HOSTNAME, InitClass.KDC_USER, InitClass.KDC_USER_PWD);
Machine kdcMachine = Machine.getMachine(connInfo);

establishConnectionToKDC(thisMethod, kdcMachine);

// get canonical and short host name
getServerCanonicalHostName();
Expand Down

0 comments on commit 9289d72

Please sign in to comment.