aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-09-04 17:04:47 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-09-04 17:08:02 +0200
commitdca8a74a0a96739912343962c5857d9e6d4f67c1 (patch)
tree11a4ff173392d8ab10fd90125be6b1094f1eaeb6 /vespa-http-client
parent7ed06b86cf547d1cbb33878a224af7488b6ecb0e (diff)
Fail all queued documents on 401 or 403 (will repeat until done)
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java9
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java10
2 files changed, 13 insertions, 6 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
index 1764016bae6..b931a7f2617 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
@@ -347,11 +347,16 @@ public class IOThread implements Runnable, AutoCloseable {
currentConnection.handshake();
successfulHandshakes.getAndIncrement();
} catch (ServerResponseException ser) {
+ int code = ser.getResponseCode();
+ if (code == 401 || code == 403) {
+ drainDocumentQueueWhenFailingPermanently(new Exception("Denied access by endpoint:" + ser.getResponseString()));
+ log.log(Level.SEVERE, "Failed authentication or authorization with '" + endpoint + "': " + Exceptions.toMessageString(ser));
+ return ConnectionState.CONNECTED; // Should ideally exit immediately, instead of doing this per X documents :/
+ }
executeProblemsCounter.incrementAndGet();
log.log(Level.INFO, "Failed talking to endpoint. Handshake with server endpoint '" + endpoint +
- "' failed. Will re-try handshake.",
- ser);
+ "' failed -- will re-try handshake: " + Exceptions.toMessageString(ser));
drainFirstDocumentsInQueueIfOld();
resultQueue.onEndpointError(new FeedProtocolException(ser.getResponseCode(), ser.getResponseString(), ser, endpoint));
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
index c5913d73d7b..240adc29197 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/communication/IOThreadTest.java
@@ -41,18 +41,20 @@ public class IOThreadTest {
}
@Test
- public void testExceptionOnConnect() {
+ public void testFatalExceptionOnHandshake() {
OperationProcessorTester tester = new OperationProcessorTester();
IOThread ioThread = tester.getSingleIOThread();
DryRunGatewayConnection firstConnection = (DryRunGatewayConnection)ioThread.currentConnection();
firstConnection.throwOnHandshake(new ServerResponseException(403, "Not authorized"));
tester.send("doc1");
+ tester.send("doc2");
+ tester.send("doc3");
tester.tick(3);
- assertEquals(1, tester.incomplete());
+ assertEquals(0, tester.incomplete());
assertEquals(0, ioThread.resultQueue().getPendingSize());
assertEquals(0, tester.success());
- assertEquals("Awaiting retry", 0, tester.failures());
+ assertEquals(3, tester.failures());
}
@Test
@@ -60,7 +62,7 @@ public class IOThreadTest {
OperationProcessorTester tester = new OperationProcessorTester();
IOThread ioThread = tester.getSingleIOThread();
DryRunGatewayConnection firstConnection = (DryRunGatewayConnection)ioThread.currentConnection();
- firstConnection.throwOnHandshake(new ServerResponseException(403, "Not authorized"));
+ firstConnection.throwOnHandshake(new ServerResponseException(418, "I'm a teapot"));
tester.send("doc1");
tester.tick(3);