@@ -104,7 +104,7 @@ public static void getKDCInfoFromConsul() throws Exception {
104104
105105 try {
106106 //obtaining kdcp and kdc_r information
107- services = CommonTest .getKDCServices (1 , SPNEGOConstants .KDC_HOST_FROM_CONSUL );
107+ services = CommonTest .getKDCServices (2 , SPNEGOConstants .KDC_HOST_FROM_CONSUL );
108108 KDC_HOSTNAME = services .get (0 ).getAddress ();
109109 KDC_USER = services .get (0 ).getProperties ().get (SPNEGOConstants .MS_KDC_USER_CONSUL );
110110 KDC_USER_PWD = services .get (0 ).getProperties ().get (SPNEGOConstants .MS_KDC_USER_PASSWORD_CONSUL );
@@ -117,6 +117,33 @@ public static void getKDCInfoFromConsul() throws Exception {
117117 USER_PWD = services .get (0 ).getProperties ().get (SPNEGOConstants .USER_PWD_FROM_CONSUL );
118118 Z_USER_PWD = services .get (0 ).getProperties ().get (SPNEGOConstants .USER0_PWD_FROM_CONSUL );
119119
120+ ConnectionInfo connInfo = new ConnectionInfo (KDC_HOSTNAME , InitClass .KDC_USER , InitClass .KDC_USER_PWD );
121+ Machine kdcMachine = Machine .getMachine (connInfo );
122+
123+ try {
124+ Log .info (c , thisMethod , "Testing connection to KDC: " + KDC_HOST_SHORTNAME );
125+ establishConnectionToKDC (thisMethod , kdcMachine );
126+ } catch (Exception e ) {
127+ String failedKdcShortName = KDC_HOST_SHORTNAME ;
128+ KDC_HOSTNAME = services .get (1 ).getAddress ();
129+ KDC_USER = services .get (1 ).getProperties ().get (SPNEGOConstants .MS_KDC_USER_CONSUL );
130+ KDC_USER_PWD = services .get (1 ).getProperties ().get (SPNEGOConstants .MS_KDC_USER_PASSWORD_CONSUL );
131+ KDC_REALM = services .get (1 ).getProperties ().get (SPNEGOConstants .KDC_REALM_FROM_CONSUL );
132+ KDC_HOST_SHORTNAME = services .get (1 ).getProperties ().get (SPNEGOConstants .KDC_SHORTNAME_FROM_CONSUL );
133+ KRB5_CONF = services .get (1 ).getProperties ().get (SPNEGOConstants .KRB5_CONF_FROM_CONSUL );
134+ Z_USER = services .get (1 ).getProperties ().get (SPNEGOConstants .Z_USER_FROM_CONSUL );
135+ FIRST_USER = services .get (1 ).getProperties ().get (SPNEGOConstants .FIRST_USER_FROM_CONSUL );
136+ SECOND_USER = services .get (1 ).getProperties ().get (SPNEGOConstants .SECOND_USER_FROM_CONSUL );
137+ USER_PWD = services .get (1 ).getProperties ().get (SPNEGOConstants .USER_PWD_FROM_CONSUL );
138+ Z_USER_PWD = services .get (1 ).getProperties ().get (SPNEGOConstants .USER0_PWD_FROM_CONSUL );
139+
140+ Log .info (c , thisMethod , "connection to " + failedKdcShortName + " failed. Attempting failover KDC: " + KDC_HOST_SHORTNAME );
141+
142+ connInfo = new ConnectionInfo (KDC_HOSTNAME , InitClass .KDC_USER , InitClass .KDC_USER_PWD );
143+ kdcMachine = Machine .getMachine (connInfo );
144+ establishConnectionToKDC (thisMethod , kdcMachine );
145+ }
146+
120147 KDCP_VAR = getKDCHostnameMask (KDC_HOSTNAME );
121148
122149 //obtaining kdcs and kdcs_r information
@@ -137,10 +164,6 @@ public static void getKDCInfoFromConsul() throws Exception {
137164 SECOND_USER_KRB5_FQN = SECOND_USER + FQN ;
138165 COMMON_TOKEN_USER = FIRST_USER ;
139166 COMMON_TOKEN_USER_PWD = FIRST_USER_PWD ;
140- ConnectionInfo connInfo = new ConnectionInfo (KDC_HOSTNAME , InitClass .KDC_USER , InitClass .KDC_USER_PWD );
141- Machine kdcMachine = Machine .getMachine (connInfo );
142-
143- establishConnectionToKDC (thisMethod , kdcMachine );
144167
145168 // get canonical and short host name
146169 getServerCanonicalHostName ();
0 commit comments