aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorvalerijf <valerijf@yahoo-inc.com>2017-04-07 10:47:52 +0200
committervalerijf <valerijf@yahoo-inc.com>2017-04-07 10:47:52 +0200
commitd1c2ff83b5f74f645d33f4131cf76ba53201820d (patch)
tree89fdf137289512697cdde1e7e4471a3171d56b2a /node-admin
parent7bf3d4baa39cb8cea7c574cdc6cfdc86476b0cfc (diff)
Re-throw orchestrator not found as OrchestratorNotFoundException
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/Orchestrator.java4
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImpl.java14
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorNotFoundException.java9
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImplTest.java7
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java5
5 files changed, 17 insertions, 22 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/Orchestrator.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/Orchestrator.java
index 9e1660fb231..e16f4d9bf6a 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/Orchestrator.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/Orchestrator.java
@@ -12,12 +12,14 @@ public interface Orchestrator {
/**
* Invokes orchestrator suspend of a host.
* @throws OrchestratorException if suspend was denied.
+ * @throws OrchestratorNotFoundException if host is unknown to the orchestrator
*/
void suspend(String hostName);
/**
* Invokes orchestrator resume of a host.
- * @throws OrchestratorException if resume was denied.
+ * @throws OrchestratorException if resume was denied
+ * @throws OrchestratorNotFoundException if host is unknown to the orchestrator
*/
void resume(String hostName);
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImpl.java
index 65769205adb..9fd0b600ca6 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImpl.java
@@ -2,10 +2,8 @@
package com.yahoo.vespa.hosted.node.admin.orchestrator;
import com.yahoo.vespa.defaults.Defaults;
-import com.yahoo.vespa.hosted.dockerapi.ContainerName;
import com.yahoo.vespa.hosted.node.admin.util.ConfigServerHttpRequestExecutor;
-import com.yahoo.vespa.hosted.node.admin.util.PrefixLogger;
import com.yahoo.vespa.orchestrator.restapi.HostApi;
import com.yahoo.vespa.orchestrator.restapi.HostSuspensionApi;
@@ -44,9 +42,7 @@ public class OrchestratorImpl implements Orchestrator {
Optional.empty(), /* body */
UpdateHostResponse.class);
} catch (ConfigServerHttpRequestExecutor.NotFoundException n) {
- // Orchestrator doesn't care about this node, so don't let that stop us.
- getLogger(hostName).info("Got not found on suspending, allowed to suspend");
- return;
+ throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found");
} catch (Exception e) {
throw new RuntimeException("Got error on suspend", e);
}
@@ -81,9 +77,7 @@ public class OrchestratorImpl implements Orchestrator {
String path = getSuspendPath(hostName);
response = requestExecutor.delete(path, WEB_SERVICE_PORT, UpdateHostResponse.class);
} catch (ConfigServerHttpRequestExecutor.NotFoundException n) {
- // Orchestrator doesn't care about this node, so don't let that stop us.
- getLogger(hostName).info("Got not found on resuming, allowed to resume");
- return;
+ throw new OrchestratorNotFoundException("Failed to resume " + hostName + ", host not found");
} catch (Exception e) {
throw new RuntimeException("Got error on resume", e);
}
@@ -93,10 +87,6 @@ public class OrchestratorImpl implements Orchestrator {
});
}
- private PrefixLogger getLogger(String hostName) {
- return PrefixLogger.getNodeAgentLogger(OrchestratorImpl.class, ContainerName.fromHostname(hostName));
- }
-
private String getSuspendPath(String hostName) {
return ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName + "/suspended";
}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorNotFoundException.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorNotFoundException.java
new file mode 100644
index 00000000000..c20fed566dc
--- /dev/null
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorNotFoundException.java
@@ -0,0 +1,9 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.node.admin.orchestrator;
+
+@SuppressWarnings("serial")
+public class OrchestratorNotFoundException extends OrchestratorException {
+ public OrchestratorNotFoundException(String message) {
+ super(message);
+ }
+}
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImplTest.java
index a4c27e565e8..c618b5c4648 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImplTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/orchestrator/OrchestratorImplTest.java
@@ -13,11 +13,10 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
/**
- * @author valerijf
+ * @author freva
*/
public class OrchestratorImplTest {
private static final String hostName = "host123.yahoo.com";
@@ -54,7 +53,7 @@ public class OrchestratorImplTest {
orchestrator.suspend(hostName);
}
- @Test
+ @Test(expected=OrchestratorNotFoundException.class)
public void testSuspendCallWithNotFound() {
when(requestExecutor.put(
any(String.class),
@@ -101,7 +100,7 @@ public class OrchestratorImplTest {
orchestrator.resume(hostName);
}
- @Test
+ @Test(expected=OrchestratorNotFoundException.class)
public void testResumeCallWithNotFound() {
when(requestExecutor.delete(
any(String.class),
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java
index 2fcb3df9b82..cc1db1eb3c7 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/util/ConfigServerHttpRequestExecutorTest.java
@@ -17,15 +17,10 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.List;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
-import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.junit.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;