summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-06-28 16:37:30 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-07-02 13:43:50 +0200
commit02780c2eb0d2bc1d5962ee3c09f4ea63fb6388c3 (patch)
treef52a8119f61eb6fffe147e7b19ae335f174f1d36 /controller-server
parentce5876ae157f5ac56bb51cd8e2ad76ed3b4b1f35 (diff)
Some more wiring and stubs
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java12
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java4
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RealStepRunner.java137
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/JobSerializer.java1
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java17
5 files changed, 118 insertions, 53 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
index 0dd80d54919..c43249f01bd 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
@@ -231,8 +231,8 @@ public class ApplicationController {
* @throws IllegalArgumentException if the application already exists
*/
public Application createApplication(ApplicationId id, Optional<NToken> token) {
- if ( ! (id.instance().isDefault() || id.instance().value().matches("\\d+"))) // TODO: Support instances properly
- throw new UnsupportedOperationException("Only the instance names 'default' and names which are just the PR number are supported at the moment");
+ if ( ! (id.instance().isDefault())) // TODO: Support instances properly
+ throw new UnsupportedOperationException("Only the instance name 'default' is supported at the moment");
try (Lock lock = lock(id)) {
// Validate only application names which do not already exist.
if (asList(id.tenant()).stream().noneMatch(application -> application.id().application().equals(id.application())))
@@ -353,6 +353,14 @@ public class ApplicationController {
}
}
+ /** Assembles and deploys a tester application to the given zone. */
+ public ActivateResult deployTester(ApplicationId tester, ApplicationPackage applicationPackage, ZoneId zone, DeployOptions options) {
+ if ( ! tester.instance().value().endsWith("-t"))
+ throw new IllegalArgumentException("'" + tester + "' is not a tester application!");
+
+ return deploy(tester, applicationPackage, zone, options, Collections.emptySet(), Collections.emptySet());
+ }
+
private ActivateResult deploy(ApplicationId application, ApplicationPackage applicationPackage,
ZoneId zone, DeployOptions deployOptions,
Set<String> rotationNames, Set<String> cnames) {
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java
index ba94b21b8bd..2ecac588d54 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java
@@ -44,7 +44,7 @@ public class RunStatus {
public RunStatus with(Step.Status status, LockedStep step) {
if (end.isPresent())
- throw new IllegalStateException("This step ended at " + end.get() + " -- it can't be further modified!");
+ throw new AssertionError("This step ended at " + end.get() + " -- it can't be further modified!");
EnumMap<Step, Step.Status> steps = new EnumMap<>(this.steps);
steps.put(step.get(), requireNonNull(status));
@@ -53,7 +53,7 @@ public class RunStatus {
public RunStatus finish(Instant now) {
if (end.isPresent())
- throw new IllegalStateException("This step ended at " + end.get() + " -- it can't be ended again!");
+ throw new AssertionError("This step ended at " + end.get() + " -- it can't be ended again!");
return new RunStatus(id, new EnumMap<>(steps), start, Optional.of(now));
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RealStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RealStepRunner.java
index 1ed55548ee7..9e64ec7def9 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RealStepRunner.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RealStepRunner.java
@@ -6,13 +6,21 @@ import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.api.ActivateResult;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId;
+import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
+import com.yahoo.vespa.hosted.controller.application.ApplicationVersion;
import com.yahoo.vespa.hosted.controller.deployment.LockedStep;
import com.yahoo.vespa.hosted.controller.deployment.RunStatus;
import com.yahoo.vespa.hosted.controller.deployment.Step;
+import com.yahoo.vespa.hosted.controller.deployment.Step.Status;
import java.util.Optional;
+import java.util.function.Supplier;
+import static com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException.ErrorCode.ACTIVATION_CONFLICT;
+import static com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException.ErrorCode.APPLICATION_LOCK_FAILURE;
+import static com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException.ErrorCode.OUT_OF_CAPACITY;
import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.failed;
import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.succeeded;
import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.unfinished;
@@ -27,7 +35,7 @@ public class RealStepRunner implements StepRunner {
private static ApplicationId testerOf(ApplicationId id) {
return ApplicationId.from(id.tenant().value(),
id.application().value(),
- "-test-" + id.instance().value());
+ id.instance().value() + "-t");
}
private final Controller controller;
@@ -37,7 +45,7 @@ public class RealStepRunner implements StepRunner {
}
@Override
- public Step.Status run(LockedStep step, RunStatus run) {
+ public Status run(LockedStep step, RunStatus run) {
RunId id = run.id();
switch (step.get()) {
case deployInitialReal: return deployInitialReal(id);
@@ -55,86 +63,121 @@ public class RealStepRunner implements StepRunner {
}
}
- private Step.Status deployInitialReal(RunId id) {
+ private Status deployInitialReal(RunId id) {
return deployReal(id, true);
}
- private Step.Status installInitialReal(RunId id) {
- // If converged and serviceconverged: succeeded
- // If timeout, failed
- return unfinished;
+ private Status deployReal(RunId id) {
+ // Separate out deploy logic from above, and reuse.
+ return deployReal(id, false);
}
- private Step.Status deployReal(RunId id) {
- // Separate out deploy logic from above, and reuse.
- return deployReal(id,false);
+ private Status deployReal(RunId id, boolean setTheStage) {
+ return deploy(id.application(),
+ id.type(),
+ () -> controller.applications().deploy(id.application(),
+ id.type().zone(controller.system()).get(),
+ Optional.empty(),
+ new DeployOptions(false,
+ Optional.empty(),
+ false,
+ setTheStage)));
}
- private Step.Status deployTester(RunId id) {
+ private Status deployTester(RunId id) {
// Find endpoints of real application. This will move down at a later time.
// See above.
- throw new AssertionError();
+ return deploy(testerOf(id.application()),
+ id.type(),
+ () -> controller.applications().deployTester(testerOf(id.application()),
+ testerPackage(id),
+ id.type().zone(controller.system()).get(),
+ new DeployOptions(true,
+ Optional.of(controller.systemVersion()),
+ false,
+ false)));
+ }
+
+ private Status deploy(ApplicationId id, JobType type, Supplier<ActivateResult> deploy) {
+ try {
+ // TODO jvenstad: Do whatever is required based on the result, and log all of this.
+ ActivateResult result = deploy.get();
+
+ return succeeded;
+ }
+ catch (ConfigServerException e) {
+ // TODO jvenstad: Consider retrying different things as well.
+ // TODO jvenstad: Log error information.
+ if ( e.getErrorCode() == OUT_OF_CAPACITY && type.isTest()
+ || e.getErrorCode() == ACTIVATION_CONFLICT
+ || e.getErrorCode() == APPLICATION_LOCK_FAILURE) {
+
+ return unfinished;
+ }
+ }
+ return failed;
}
- private Step.Status installReal(RunId id) {
- // See three above.
- throw new AssertionError();
+ private Status installInitialReal(RunId id) {
+ return install(id.application(), id.type());
}
- private Step.Status installTester(RunId id) {
- // See above.
- throw new AssertionError();
+ private Status installReal(RunId id) {
+ return install(id.application(), id.type());
+ }
+
+ private Status installTester(RunId id) {
+ return install(testerOf(id.application()), id.type());
+ }
+
+ private Status install(ApplicationId id, JobType type) {
+ // If converged and serviceconverged: succeeded
+ // If timeout, failed
+ return unfinished;
}
- private Step.Status startTests(RunId id) {
+ private Status startTests(RunId id) {
// Empty for now, but will be: find endpoints and post them.
throw new AssertionError();
}
- private Step.Status storeData(RunId id) {
+ private Status storeData(RunId id) {
// Update test logs.
// If tests are done, return test results.
throw new AssertionError();
}
- private Step.Status deactivateReal(RunId id) {
- // Try to deactivate, and if deactivated, finished.
- throw new AssertionError();
+ private Status deactivateReal(RunId id) {
+ return deactivate(id.application(), id.type());
}
- private Step.Status deactivateTester(RunId id) {
- // See above.
- throw new AssertionError();
+ private Status deactivateTester(RunId id) {
+ return deactivate(testerOf(id.application()), id.type());
}
- private Step.Status report(RunId id) {
- // Easy squeezy.
+ private Status deactivate(ApplicationId id, JobType type) {
+ // Try to deactivate, and if deactivated, finished.
throw new AssertionError();
}
- private Step.Status deployReal(RunId id, boolean setTheStage) {
- try {
- // TODO jvenstad: Do whatever is required based on the result, and log all of this.
- ActivateResult result = controller.applications().deploy(id.application(),
- id.type().zone(controller.system()).get(),
- Optional.empty(),
- new DeployOptions(false,
- Optional.empty(),
- false,
- setTheStage));
- return succeeded;
- }
- catch (ConfigServerException e) {
- // TODO jvenstad: Consider retrying different things as well.
- // TODO jvenstad: Log error information.
- if (id.type().isTest() && e.getErrorCode() == ConfigServerException.ErrorCode.OUT_OF_CAPACITY)
- return unfinished;
- }
- return failed;
+ private Status report(RunId id) {
+ // Easy squeezy.
+ throw new AssertionError();
}
private Application application(ApplicationId id) {
return controller.applications().require(id);
}
+ private ApplicationPackage testerPackage(RunId id) {
+ ApplicationVersion version = application(id.application()).deploymentJobs()
+ .statusOf(id.type()).get()
+ .lastTriggered().get()
+ .application();
+
+
+ // TODO hakonhall: Fetch!
+ throw new AssertionError();
+ }
+
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/JobSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/JobSerializer.java
index f34cde002d0..503f6fd990e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/JobSerializer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/JobSerializer.java
@@ -32,7 +32,6 @@ import static com.yahoo.vespa.hosted.controller.deployment.Step.installTester;
import static com.yahoo.vespa.hosted.controller.deployment.Step.report;
import static com.yahoo.vespa.hosted.controller.deployment.Step.startTests;
import static com.yahoo.vespa.hosted.controller.deployment.Step.storeData;
-import static java.util.Objects.requireNonNull;
public class JobSerializer {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java
index 04c670cf136..cf546d8b075 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ArtifactRepositoryMock.java
@@ -47,8 +47,23 @@ public class ArtifactRepositoryMock extends AbstractComponent implements Artifac
}
@Override
+ public void putApplicationPackage(ApplicationId application, String applicationVersion, byte[] applicationPackage) {
+ throw new AssertionError();
+ }
+
+ @Override
+ public byte[] getTesterJar(ApplicationId tester, String applicationVersion) {
+ throw new AssertionError();
+ }
+
+ @Override
+ public void putTesterJar(ApplicationId tester, String applicationVersion, byte[] fatTestJar) {
+ throw new AssertionError();
+ }
+
+ @Override
public byte[] getSystemApplicationPackage(ApplicationId application, ZoneId zone, Version version) {
- return new byte[0];
+ throw new AssertionError();
}
private static int artifactHash(ApplicationId applicationId, String applicationVersion) {