Skip to content

Commit 33b3bbe

Browse files
committed
HBASE-27204 BlockingRpcClient will hang for 20 seconds when SASL is enabled after finishing negotiation (#4642)
Revert "HBASE-24579: Failed SASL authentication does not result in an exception on client side (#1921)" This reverts commit bd79c40. When Kerberos authentication succeeds, on the server side, after receiving the final SASL token from the client, we simply wait for the client to continue by sending the connection header. After HBASE-24579, on the client side, an additional readStatus() was added, which mistakenly assumes that after negotiation has completed a status code will be sent. However when authentication has succeeded the server will not send one. As a result the client will hang and only throw an exception when the configured read timeout is reached, which is 20 seconds by default. We cannot unilaterally send the expected additional status code from the server side because older clients will not expect it. The first call will fail because the client finds unexpected bytes in the stream ahead of the call response. Fabricating a call response also does not seem a viable strategy for backwards compatibility. The HBASE-24579 change needs to be reconsidered given the difficult backwards compatibility challenges here. Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org> Conflicts: hbase-client/src/test/java/org/apache/hadoop/hbase/security/TestHBaseSaslRpcClient.java
1 parent 0df2cc3 commit 33b3bbe

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/security/HBaseSaslRpcClient.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ public boolean saslConnect(InputStream inS, OutputStream outS) throws IOExceptio
145145
}
146146
}
147147

148-
try {
149-
readStatus(inStream);
150-
} catch (IOException e) {
151-
if (e instanceof RemoteException) {
152-
LOG.debug("Sasl connection failed: ", e);
153-
throw e;
154-
}
155-
}
156148
if (LOG.isDebugEnabled()) {
157149
LOG.debug("SASL client context established. Negotiated QoP: "
158150
+ saslClient.getNegotiatedProperty(Sasl.QOP));

hbase-client/src/test/java/org/apache/hadoop/hbase/security/TestHBaseSaslRpcClient.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@
5050
import org.apache.hadoop.hbase.util.Bytes;
5151
import org.apache.hadoop.io.DataInputBuffer;
5252
import org.apache.hadoop.io.DataOutputBuffer;
53-
import org.apache.hadoop.io.WritableUtils;
5453
import org.apache.hadoop.security.token.Token;
5554
import org.apache.hadoop.security.token.TokenIdentifier;
5655
import org.apache.log4j.Level;
5756
import org.apache.log4j.Logger;
58-
import org.junit.Assert;
5957
import org.junit.BeforeClass;
6058
import org.junit.ClassRule;
6159
import org.junit.Rule;
@@ -313,32 +311,4 @@ private HBaseSaslRpcClient createSaslRpcClientSimple(String principal, String pa
313311
private Token<? extends TokenIdentifier> createTokenMock() {
314312
return mock(Token.class);
315313
}
316-
317-
@Test(expected = IOException.class)
318-
public void testFailedEvaluateResponse() throws IOException {
319-
// prep mockin the SaslClient
320-
SimpleSaslClientAuthenticationProvider mockProvider =
321-
Mockito.mock(SimpleSaslClientAuthenticationProvider.class);
322-
SaslClient mockClient = Mockito.mock(SaslClient.class);
323-
Assert.assertNotNull(mockProvider);
324-
Assert.assertNotNull(mockClient);
325-
Mockito.when(mockProvider.createClient(Mockito.any(), Mockito.any(), Mockito.any(),
326-
Mockito.any(), Mockito.anyBoolean(), Mockito.any())).thenReturn(mockClient);
327-
HBaseSaslRpcClient rpcClient = new HBaseSaslRpcClient(HBaseConfiguration.create(), mockProvider,
328-
createTokenMock(), Mockito.mock(InetAddress.class), Mockito.mock(SecurityInfo.class), false);
329-
330-
// simulate getting an error from a failed saslServer.evaluateResponse
331-
DataOutputBuffer errorBuffer = new DataOutputBuffer();
332-
errorBuffer.writeInt(SaslStatus.ERROR.state);
333-
WritableUtils.writeString(errorBuffer, IOException.class.getName());
334-
WritableUtils.writeString(errorBuffer, "Invalid Token");
335-
336-
DataInputBuffer in = new DataInputBuffer();
337-
in.reset(errorBuffer.getData(), 0, errorBuffer.getLength());
338-
DataOutputBuffer out = new DataOutputBuffer();
339-
340-
// simulate that authentication exchange has completed quickly after sending the token
341-
Mockito.when(mockClient.isComplete()).thenReturn(true);
342-
rpcClient.saslConnect(in, out);
343-
}
344314
}

0 commit comments

Comments
 (0)