Skip to content

Commit 2728821

Browse files
authored
HBASE-26212 Expose configuration to enable/disable AuthUtil (#3619)
In some situations, a caller may know that it is properly managing the Kerberos ticket to talk to HBase. In these situations, it's possible that AuthUtil still tries to do renewals, but just fails repeatedly to do so. Give a configuration flag for such clients to be able to tell AuthUtil to simply stop trying. Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 6ad7eb8 commit 2728821

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public void newDead(ServerName sn) {
171171

172172
private void spawnRenewalChore(final UserGroupInformation user) {
173173
ChoreService service = getChoreService();
174-
service.scheduleChore(AuthUtil.getAuthRenewalChore(user));
174+
service.scheduleChore(AuthUtil.getAuthRenewalChore(user, conf));
175175
}
176176

177177
/**

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ replicaSelectorClass, META_TABLE_NAME, getChoreService(), () -> {
374374

375375
private void spawnRenewalChore(final UserGroupInformation user) {
376376
ChoreService service = getChoreService();
377-
service.scheduleChore(AuthUtil.getAuthRenewalChore(user));
377+
service.scheduleChore(AuthUtil.getAuthRenewalChore(user, conf));
378378
}
379379

380380
/**

hbase-common/src/main/java/org/apache/hadoop/hbase/AuthUtil.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ public final class AuthUtil {
9090
/** Client principal */
9191
public static final String HBASE_CLIENT_KERBEROS_PRINCIPAL = "hbase.client.keytab.principal";
9292

93+
/** Configuration to automatically try to renew keytab-based logins */
94+
public static final String HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_KEY = "hbase.client.keytab.automatic.renewal";
95+
public static final boolean HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_DEFAULT = true;
96+
9397
private AuthUtil() {
9498
super();
9599
}
@@ -189,8 +193,8 @@ private static User loginClientAsService(Configuration conf) throws IOException
189193
* @return a ScheduledChore for renewals.
190194
*/
191195
@InterfaceAudience.Private
192-
public static ScheduledChore getAuthRenewalChore(final UserGroupInformation user) {
193-
if (!user.hasKerberosCredentials()) {
196+
public static ScheduledChore getAuthRenewalChore(final UserGroupInformation user, Configuration conf) {
197+
if (!user.hasKerberosCredentials() || !isAuthRenewalChoreEnabled(conf)) {
194198
return null;
195199
}
196200

@@ -221,8 +225,11 @@ protected void chore() {
221225
*/
222226
@Deprecated
223227
public static ScheduledChore getAuthChore(Configuration conf) throws IOException {
228+
if (!isAuthRenewalChoreEnabled(conf)) {
229+
return null;
230+
}
224231
User user = loginClientAsService(conf);
225-
return getAuthRenewalChore(user.getUGI());
232+
return getAuthRenewalChore(user.getUGI(), conf);
226233
}
227234

228235
private static Stoppable createDummyStoppable() {
@@ -271,4 +278,13 @@ public static String getGroupName(String aclKey) {
271278
public static String toGroupEntry(String name) {
272279
return GROUP_PREFIX + name;
273280
}
281+
282+
/**
283+
* Returns true if the chore to automatically renew Kerberos tickets (from
284+
* keytabs) should be started. The default is true.
285+
*/
286+
static boolean isAuthRenewalChoreEnabled(Configuration conf) {
287+
return conf.getBoolean(HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_KEY,
288+
HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_DEFAULT);
289+
}
274290
}

0 commit comments

Comments
 (0)