Skip to content

Commit 3bed95f

Browse files
committed
Revert "HBASE-29473 Obtain target cluster's token for cross clusters job (#7198)"
Compatibility issue, see JIRA This reverts commit 22ba3bf. Signed-off-by: Andrew Purtell <apurtell@apache.org>
1 parent d698d40 commit 3bed95f

File tree

4 files changed

+40
-186
lines changed

4 files changed

+40
-186
lines changed

hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ public static void configureIncrementalLoadMap(Job job, TableDescriptor tableDes
811811
* @see #REMOTE_CLUSTER_ZOOKEEPER_CLIENT_PORT_CONF_KEY
812812
* @see #REMOTE_CLUSTER_ZOOKEEPER_ZNODE_PARENT_CONF_KEY
813813
*/
814-
public static void configureRemoteCluster(Job job, Configuration clusterConf) throws IOException {
814+
public static void configureRemoteCluster(Job job, Configuration clusterConf) {
815815
Configuration conf = job.getConfiguration();
816816

817817
if (!conf.getBoolean(LOCALITY_SENSITIVE_CONF_KEY, DEFAULT_LOCALITY_SENSITIVE)) {
@@ -828,8 +828,6 @@ public static void configureRemoteCluster(Job job, Configuration clusterConf) th
828828
conf.setInt(REMOTE_CLUSTER_ZOOKEEPER_CLIENT_PORT_CONF_KEY, clientPort);
829829
conf.set(REMOTE_CLUSTER_ZOOKEEPER_ZNODE_PARENT_CONF_KEY, parent);
830830

831-
TableMapReduceUtil.initCredentialsForCluster(job, clusterConf);
832-
833831
LOG.info("ZK configs for remote cluster of bulkload is configured: " + quorum + ":" + clientPort
834832
+ "/" + parent);
835833
}

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2WithSecurity.java

Lines changed: 0 additions & 132 deletions
This file was deleted.

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@
2929
import org.apache.hadoop.hbase.HBaseClassTestRule;
3030
import org.apache.hadoop.hbase.HBaseTestingUtility;
3131
import org.apache.hadoop.hbase.client.Scan;
32+
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
33+
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
34+
import org.apache.hadoop.hbase.security.access.AccessController;
35+
import org.apache.hadoop.hbase.security.access.PermissionStorage;
36+
import org.apache.hadoop.hbase.security.access.SecureTestUtil;
3237
import org.apache.hadoop.hbase.security.provider.SaslClientAuthenticationProviders;
3338
import org.apache.hadoop.hbase.security.token.AuthenticationTokenIdentifier;
39+
import org.apache.hadoop.hbase.security.token.TokenProvider;
40+
import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil;
3441
import org.apache.hadoop.hbase.testclassification.MapReduceTests;
3542
import org.apache.hadoop.hbase.testclassification.MediumTests;
3643
import org.apache.hadoop.hbase.util.Bytes;
@@ -41,6 +48,7 @@
4148
import org.apache.hadoop.minikdc.MiniKdc;
4249
import org.apache.hadoop.security.Credentials;
4350
import org.apache.hadoop.security.UserGroupInformation;
51+
import org.apache.hadoop.security.authentication.util.KerberosName;
4452
import org.apache.hadoop.security.token.Token;
4553
import org.apache.hadoop.security.token.TokenIdentifier;
4654
import org.junit.After;
@@ -126,6 +134,33 @@ public void testInitTableMapperJob4() throws Exception {
126134
assertEquals("Table", job.getConfiguration().get(TableInputFormat.INPUT_TABLE));
127135
}
128136

137+
private static Closeable startSecureMiniCluster(HBaseTestingUtility util, MiniKdc kdc,
138+
String principal) throws Exception {
139+
Configuration conf = util.getConfiguration();
140+
141+
SecureTestUtil.enableSecurity(conf);
142+
VisibilityTestUtil.enableVisiblityLabels(conf);
143+
SecureTestUtil.verifyConfiguration(conf);
144+
145+
conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
146+
AccessController.class.getName() + ',' + TokenProvider.class.getName());
147+
148+
HBaseKerberosUtils.setSecuredConfiguration(conf, principal + '@' + kdc.getRealm(),
149+
HTTP_PRINCIPAL + '@' + kdc.getRealm());
150+
151+
KerberosName.resetDefaultRealm();
152+
153+
util.startMiniCluster();
154+
try {
155+
util.waitUntilAllRegionsAssigned(PermissionStorage.ACL_TABLE_NAME);
156+
} catch (Exception e) {
157+
util.shutdownMiniCluster();
158+
throw e;
159+
}
160+
161+
return util::shutdownMiniCluster;
162+
}
163+
129164
@Test
130165
public void testInitCredentialsForCluster1() throws Exception {
131166
HBaseTestingUtility util1 = new HBaseTestingUtility();
@@ -164,9 +199,8 @@ public void testInitCredentialsForCluster2() throws Exception {
164199
kdc.createPrincipal(keytab, userPrincipal, HTTP_PRINCIPAL);
165200
loginUserFromKeytab(userPrincipal + '@' + kdc.getRealm(), keytab.getAbsolutePath());
166201

167-
try (
168-
Closeable util1Closeable = util1.startSecureMiniCluster(kdc, userPrincipal, HTTP_PRINCIPAL);
169-
Closeable util2Closeable = util2.startSecureMiniCluster(kdc, userPrincipal, HTTP_PRINCIPAL)) {
202+
try (Closeable util1Closeable = startSecureMiniCluster(util1, kdc, userPrincipal);
203+
Closeable util2Closeable = startSecureMiniCluster(util2, kdc, userPrincipal)) {
170204
try {
171205
Configuration conf1 = util1.getConfiguration();
172206
Job job = Job.getInstance(conf1);
@@ -199,8 +233,7 @@ public void testInitCredentialsForCluster3() throws Exception {
199233
kdc.createPrincipal(keytab, userPrincipal, HTTP_PRINCIPAL);
200234
loginUserFromKeytab(userPrincipal + '@' + kdc.getRealm(), keytab.getAbsolutePath());
201235

202-
try (
203-
Closeable util1Closeable = util1.startSecureMiniCluster(kdc, userPrincipal, HTTP_PRINCIPAL)) {
236+
try (Closeable util1Closeable = startSecureMiniCluster(util1, kdc, userPrincipal)) {
204237
try {
205238
HBaseTestingUtility util2 = new HBaseTestingUtility();
206239
// Assume util2 is insecure cluster
@@ -236,8 +269,7 @@ public void testInitCredentialsForCluster4() throws Exception {
236269
kdc.createPrincipal(keytab, userPrincipal, HTTP_PRINCIPAL);
237270
loginUserFromKeytab(userPrincipal + '@' + kdc.getRealm(), keytab.getAbsolutePath());
238271

239-
try (
240-
Closeable util2Closeable = util2.startSecureMiniCluster(kdc, userPrincipal, HTTP_PRINCIPAL)) {
272+
try (Closeable util2Closeable = startSecureMiniCluster(util2, kdc, userPrincipal)) {
241273
try {
242274
Configuration conf1 = util1.getConfiguration();
243275
Job job = Job.getInstance(conf1);

hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static org.junit.Assert.fail;
2323

2424
import edu.umd.cs.findbugs.annotations.Nullable;
25-
import java.io.Closeable;
2625
import java.io.File;
2726
import java.io.IOException;
2827
import java.io.OutputStream;
@@ -89,7 +88,6 @@
8988
import org.apache.hadoop.hbase.client.TableDescriptor;
9089
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
9190
import org.apache.hadoop.hbase.client.TableState;
92-
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
9391
import org.apache.hadoop.hbase.fs.HFileSystem;
9492
import org.apache.hadoop.hbase.io.compress.Compression;
9593
import org.apache.hadoop.hbase.io.compress.Compression.Algorithm;
@@ -122,12 +120,7 @@
122120
import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;
123121
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
124122
import org.apache.hadoop.hbase.security.User;
125-
import org.apache.hadoop.hbase.security.access.AccessController;
126-
import org.apache.hadoop.hbase.security.access.PermissionStorage;
127-
import org.apache.hadoop.hbase.security.access.SecureTestUtil;
128-
import org.apache.hadoop.hbase.security.token.TokenProvider;
129123
import org.apache.hadoop.hbase.security.visibility.VisibilityLabelsCache;
130-
import org.apache.hadoop.hbase.security.visibility.VisibilityTestUtil;
131124
import org.apache.hadoop.hbase.util.Bytes;
132125
import org.apache.hadoop.hbase.util.CommonFSUtils;
133126
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -156,7 +149,6 @@
156149
import org.apache.hadoop.mapred.JobConf;
157150
import org.apache.hadoop.mapred.MiniMRCluster;
158151
import org.apache.hadoop.minikdc.MiniKdc;
159-
import org.apache.hadoop.security.authentication.util.KerberosName;
160152
import org.apache.yetus.audience.InterfaceAudience;
161153
import org.apache.zookeeper.WatchedEvent;
162154
import org.apache.zookeeper.ZooKeeper;
@@ -399,42 +391,6 @@ public static void closeRegionAndWAL(final HRegion r) throws IOException {
399391
r.getWAL().close();
400392
}
401393

402-
/**
403-
* Start mini secure cluster with given kdc and principals.
404-
* @param kdc Mini kdc server
405-
* @param servicePrincipal Service principal without realm.
406-
* @param spnegoPrincipal Spnego principal without realm.
407-
* @return Handler to shutdown the cluster
408-
*/
409-
public Closeable startSecureMiniCluster(MiniKdc kdc, String servicePrincipal,
410-
String spnegoPrincipal) throws Exception {
411-
Configuration conf = getConfiguration();
412-
413-
SecureTestUtil.enableSecurity(conf);
414-
VisibilityTestUtil.enableVisiblityLabels(conf);
415-
SecureTestUtil.verifyConfiguration(conf);
416-
417-
// Reset the static default realm forcibly for hadoop-2.0.
418-
// It has no impact but not required for hadoop-3.0.
419-
KerberosName.resetDefaultRealm();
420-
421-
conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
422-
AccessController.class.getName() + ',' + TokenProvider.class.getName());
423-
424-
HBaseKerberosUtils.setSecuredConfiguration(conf, servicePrincipal + '@' + kdc.getRealm(),
425-
spnegoPrincipal + '@' + kdc.getRealm());
426-
427-
startMiniCluster();
428-
try {
429-
waitUntilAllRegionsAssigned(PermissionStorage.ACL_TABLE_NAME);
430-
} catch (Exception e) {
431-
shutdownMiniCluster();
432-
throw e;
433-
}
434-
435-
return this::shutdownMiniCluster;
436-
}
437-
438394
/**
439395
* Returns this classes's instance of {@link Configuration}. Be careful how you use the returned
440396
* Configuration since {@link Connection} instances can be shared. The Map of Connections is keyed

0 commit comments

Comments
 (0)