summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-06-21 15:16:34 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-07-02 13:42:47 +0200
commit127573ef4f908eb985e30ee3aac9fbe78556e1bb (patch)
tree825eb8ee254713d2f73e1e61ae02ef9533ee5018 /controller-server
parent9387b79d50d0a41ac7ed8493d46341dda5f926d7 (diff)
Renaming and skeleton for steps
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java28
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobMeta.java46
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobState.java28
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java (renamed from controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobDetails.java)7
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunId.java (renamed from controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobId.java)22
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunResult.java (renamed from controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobOutcome.java)2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java83
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Step.java78
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/StepRunner.java22
9 files changed, 215 insertions, 101 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
index 4da13632eef..aff60191f7f 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
@@ -3,7 +3,8 @@ package com.yahoo.vespa.hosted.controller.deployment;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.api.integration.LogStore;
-import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
+import com.yahoo.vespa.hosted.controller.application.ApplicationVersion;
import java.util.List;
@@ -11,7 +12,7 @@ import java.util.List;
* A singleton owned by the controller, which contains the state and methods for controlling deployment jobs.
*
* Keys are the {@link ApplicationId} of the real application, for which the deployment job is run, and the
- * {@link ZoneId} of the real deployment to test.
+ * {@link JobType} of the real deployment to test.
*
* Although the deployment jobs are themselves applications, their IDs are not to be referenced.
*
@@ -35,27 +36,27 @@ public class JobController {
}
/** Returns a list of all application which have registered. */
- List<ApplicationId> applications() {
+ public List<ApplicationId> applications() {
return null;
}
/** Returns all job types which have been run for the given application. */
- List<ZoneId> jobs(ApplicationId application) {
+ public List<JobType> jobs(ApplicationId application) {
return null;
}
/** Returns a list of meta information about all known runs of the given job type. */
- List<JobMeta> runs(ApplicationId application, ZoneId zone) {
+ public List<RunStatus> runs(ApplicationId application, JobType type) {
return null;
}
/** Returns the current status of the given job. */
- JobMeta status(JobId job) {
+ public RunStatus status(RunId job) {
return null;
}
/** Returns the details for the given job. */
- JobDetails details(JobId job) {
+ public RunDetails details(RunId job) {
return null;
}
@@ -66,27 +67,32 @@ public class JobController {
;
}
+ /** Accepts and stores a new appliaction package and test jar pair, and returns the reference these will have. */
+ public ApplicationVersion submit(byte[] applicationPackage, byte[] applicationTestJar) {
+ return ApplicationVersion.unknown;
+ }
+
/** Orders a run of the given type, and returns the id of the created job. */
- JobId run(ApplicationId application, ZoneId zone) {
+ public RunId run(ApplicationId application, JobType type) {
return null;
}
// PUT:
/** Stores the given details for the given job. */
- void store(JobDetails details, JobId job) {
+ public void store(RunDetails details, RunId job) {
;
}
// DELETE:
/** Unregisters the given application, and deletes all associated data. */
- void unregister(ApplicationId application) {
+ public void unregister(ApplicationId application) {
;
}
/** Aborts the given job. */
- void abort(JobId job) {
+ public void abort(RunId job) {
;
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobMeta.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobMeta.java
deleted file mode 100644
index dde675402ce..00000000000
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobMeta.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.yahoo.vespa.hosted.controller.deployment;
-
-import java.time.Instant;
-import java.util.Optional;
-
-/**
- * Contains state information for a deployment job run by an {@link InternalBuildService}.
- *
- * @author jonmv
- */
-public class JobMeta {
-
- private final JobId id;
- private final JobState state;
- private final JobOutcome outcome;
- private final Instant start;
- private final Instant end;
-
- public JobMeta(JobId id, JobState state, JobOutcome outcome, Instant start, Instant end) {
- this.id = id;
- this.state = state;
- this.outcome = outcome;
- this.start = start;
- this.end = end;
- }
-
- public JobId id() {
- return id;
- }
-
- public JobState state() {
- return state;
- }
-
- public JobOutcome outcome() {
- return outcome;
- }
-
- public Instant start() {
- return start;
- }
-
- public Optional<Instant> end() {
- return Optional.ofNullable(end);
- }
-}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobState.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobState.java
deleted file mode 100644
index 19e575efaf8..00000000000
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobState.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.yahoo.vespa.hosted.controller.deployment;
-
-/**
- * Status of jobs run by an {@link InternalBuildService}.
- *
- * @author jonmv
- */
-public enum JobState {
-
- /** Job is not currently running, and may be started. */
- idle,
-
- /** Real application is deploying. */
- deploying,
-
- /** Real application is converging. */
- converging,
-
- /** Tester is starting up, but is not yet ready to serve its status. */
- initializing,
-
- /** Job is up and running normally. */
- running,
-
- /** Tests are complete, and results may be fetched. */
- finished
-
-}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobDetails.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
index 3c787c8314f..300452ac0a8 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobDetails.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
@@ -1,19 +1,20 @@
package com.yahoo.vespa.hosted.controller.deployment;
import com.yahoo.vespa.hosted.controller.api.ActivateResult;
+import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse;
/**
* Contains details about a deployment job run.
*
* @author jonmv
*/
-public class JobDetails {
+public class RunDetails {
- private final ActivateResult deploymentResult;
+ private final PrepareResponse deploymentResult;
private final String convergenceLog;
private final String testLog;
- public JobDetails(ActivateResult deploymentResult, String convergenceLog, String testLog) {
+ public RunDetails(PrepareResponse deploymentResult, String convergenceLog, String testLog) {
this.deploymentResult = deploymentResult;
this.convergenceLog = convergenceLog;
this.testLog = testLog;
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobId.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunId.java
index 541494a23fc..d78dbd6e636 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobId.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunId.java
@@ -2,8 +2,6 @@ package com.yahoo.vespa.hosted.controller.deployment;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
-import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
-import com.yahoo.vespa.hosted.controller.application.DeploymentJobs;
import java.util.Objects;
@@ -12,46 +10,46 @@ import java.util.Objects;
*
* @author jonmv
*/
-public class JobId {
+public class RunId {
private final ApplicationId application;
- private final ZoneId zone;
+ private final JobType type;
private final long number;
- public JobId(ApplicationId application, ZoneId zone, long number) {
+ public RunId(ApplicationId application, JobType type, long number) {
this.application = Objects.requireNonNull(application, "ApplicationId cannot be null!");
- this.zone = Objects.requireNonNull(zone, "ZoneId cannot be null!");
+ this.type = Objects.requireNonNull(type, "JobType cannot be null!");
if (number <= 0) throw new IllegalArgumentException("Build number must be a positive integer!");
this.number = number;
}
public ApplicationId application() { return application; }
- public ZoneId zone() { return zone; }
+ public JobType type() { return type; }
public long number() { return number; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if ( ! (o instanceof JobId)) return false;
+ if ( ! (o instanceof RunId)) return false;
- JobId id = (JobId) o;
+ RunId id = (RunId) o;
if (number != id.number) return false;
if ( ! application.equals(id.application)) return false;
- return zone == id.zone;
+ return type == id.type;
}
@Override
public int hashCode() {
int result = application.hashCode();
- result = 31 * result + zone.hashCode();
+ result = 31 * result + type.hashCode();
result = 31 * result + (int) (number ^ (number >>> 32));
return result;
}
@Override
public String toString() {
- return "Run " + number + " in " + zone + " for " + application;
+ return "Run " + number + " of " + type + " for " + application;
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobOutcome.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunResult.java
index caecdcffb9b..9bdf0c76d14 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobOutcome.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunResult.java
@@ -5,7 +5,7 @@ package com.yahoo.vespa.hosted.controller.deployment;
*
* @author jonmv
*/
-public enum JobOutcome {
+public enum RunResult {
/** Deployment of the real application was rejected due to missing capacity. */
outOfCapacity,
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
new file mode 100644
index 00000000000..f200ca4f82d
--- /dev/null
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunStatus.java
@@ -0,0 +1,83 @@
+package com.yahoo.vespa.hosted.controller.deployment;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.Stack;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.pending;
+import static java.util.Objects.requireNonNull;
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.toMap;
+
+/**
+ * Contains state information for a deployment job run by an {@link InternalBuildService}.
+ *
+ * Immutable.
+ *
+ * @author jonmv
+ */
+public class RunStatus {
+
+ private final RunId id;
+ private final Map<Step, Step.Status> status;
+ private final Set<Step> alwaysRun;
+ private final RunResult result;
+ private final Instant start;
+ private final Instant end;
+
+ RunStatus(RunId id, Map<Step, Step.Status> status, Set<Step> alwaysRun, RunResult result, Instant start, Instant end) {
+ this.id = id;
+ this.status = status;
+ this.alwaysRun = alwaysRun;
+ this.result = result;
+ this.start = start;
+ this.end = end;
+ }
+
+ public static RunStatus initial(RunId id, Set<Step> runWhileSuccess, Set<Step> alwaysRun, Instant now) {
+ ImmutableMap.Builder<Step, Step.Status> status = ImmutableMap.builder();
+ runWhileSuccess.forEach(step -> status.put(step, pending));
+ alwaysRun.forEach(step -> status.put(step, pending));
+ return new RunStatus(requireNonNull(id), status.build(), alwaysRun, null, requireNonNull(now), null);
+ }
+
+ public RunStatus with(Step.Status update, Step step) {
+ return new RunStatus(id, ImmutableMap.<Step, Step.Status>builder().putAll(status).put(step, update).build(), alwaysRun, result, start, end);
+ }
+
+ /** Returns the id of this run. */
+ public RunId id() {
+ return id;
+ }
+
+ /** Returns the status of all steps in this run. */
+ public Map<Step, Step.Status> status() {
+ return status;
+ }
+
+ /** Returns the final result of this run, if it has ended. */
+ public Optional<RunResult> result() {
+ return Optional.ofNullable(result);
+ }
+
+ /** Returns the instant at which this run began. */
+ public Instant start() {
+ return start;
+ }
+
+ /** Returns the instant at which this run ended, if it has. */
+ public Optional<Instant> end() {
+ return Optional.ofNullable(end);
+ }
+
+}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Step.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Step.java
new file mode 100644
index 00000000000..ccd7434a513
--- /dev/null
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Step.java
@@ -0,0 +1,78 @@
+package com.yahoo.vespa.hosted.controller.deployment;
+
+import java.util.Arrays;
+import java.util.List;
+
+public enum Step {
+
+ /** Download and deploy the initial real application, for staging tests. */
+ deployInitialReal,
+
+ /** See that the real application has had its nodes converge to the initial state. */
+ installInitialReal(deployInitialReal),
+
+ /** Download and deploy real application, restarting services if required. */
+ deployReal(installInitialReal),
+
+ /** See that real application has had its nodes converge to the wanted version and generation. */
+ installReal(deployReal),
+
+ /** Find test endpoints, download test-jar, and assemble and deploy tester application. */
+ deployTester(deployReal),
+
+ /** See that tester is done deploying, and is ready to serve. */
+ installTester(deployTester),
+
+ /** Ask the tester to run its tests. */
+ runTests(installReal, installTester),
+
+ /** Download data from the tester, and store it. */
+ storeData(runTests),
+
+ /** Deactivate the tester, and the real deployment if test or staging environment. */
+ tearDown(storeData);
+
+
+ private final List<Step> prerequisites;
+
+ Step(Step... prerequisites) {
+ this.prerequisites = Arrays.asList(prerequisites);
+ // Hmm ... Need to pick out only the relevant prerequisites, and to allow storeData and tearDown to always run.
+ }
+
+
+ public enum Profile {
+
+ systemTest(deployReal, installReal, deployTester, installTester, runTests),
+
+ stagingTest,
+
+ productionTest;
+
+
+ private final List<Step> steps;
+
+ Profile(Step... steps) {
+ this.steps = Arrays.asList(steps);
+ }
+
+ }
+
+
+ public enum Status {
+
+ /** Step is waiting for its prerequisites to succeed. */
+ pending,
+
+ /** Step is currently running. */
+ running,
+
+ /** Step failed, and subsequent steps can not start. */
+ failed,
+
+ /** Step succeeded, and subsequent steps may not start. */
+ succeeded;
+
+ }
+
+}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/StepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/StepRunner.java
new file mode 100644
index 00000000000..5e1b8d904c6
--- /dev/null
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/StepRunner.java
@@ -0,0 +1,22 @@
+package com.yahoo.vespa.hosted.controller.deployment;
+
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
+
+import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.succeeded;
+
+/**
+ * Executor which runs given {@link Step}s, for given {@link ApplicationId} and {@link JobType} combinations.
+ *
+ * @author jonmv
+ */
+public class StepRunner {
+
+ /** Returns the new status of the given step for the implied job run. */
+ Step.Status run(Step step, ApplicationId application, JobType jobType) {
+ switch (step) {
+ default: return succeeded;
+ }
+ }
+
+}