Separate out registration of applications in internal pipeline
@@ -6,6 +6,7 @@ import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.curator.Lock;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
+import com.yahoo.vespa.hosted.controller.LockedApplication;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
import com.yahoo.vespa.hosted.controller.api.integration.RunDataStore;
@@ -234,19 +235,8 @@ public class JobController {
ApplicationPackage applicationPackage, byte[] testPackageBytes) {
AtomicReference<ApplicationVersion> version = new AtomicReference<>();
controller.applications().lockOrThrow(id, application -> {
- if ( ! application.get().deploymentJobs().deployedInternally()) {
- // TODO jvenstad: Remove when there are no more SDv3 pipelines.
- // Copy all current packages to the new application store
- application.get().productionDeployments().values().stream()
- .map(Deployment::applicationVersion)
- .distinct()
- .forEach(appVersion -> {
- byte[] content = controller.applications().artifacts().getApplicationPackage(id, appVersion.id());
- controller.applications().applicationStore().put(id, appVersion, content);
- });
- // Make sure any ongoing upgrade is cancelled, since future jobs will require the tester artifact.
- application = application.withChange(application.get().change().withoutPlatform().withoutApplication());
- }
+ if ( ! application.get().deploymentJobs().deployedInternally())
+ application = registered(application);
long run = nextBuild(id);
if (applicationPackage.compileVersion().isPresent() && applicationPackage.buildTime().isPresent())
@@ -264,13 +254,29 @@ public class JobController {
testPackageBytes);
prunePackages(id);
- controller.applications().storeWithUpdatedConfig(application.withBuiltInternally(true), applicationPackage);
+ controller.applications().storeWithUpdatedConfig(application, applicationPackage);
controller.applications().deploymentTrigger().notifyOfCompletion(DeploymentJobs.JobReport.ofSubmission(id, projectId, version.get()));
});
return version.get();
}
+ /** Registers the given application, copying necessary application packages, and returns the modified version. */
+ private LockedApplication registered(LockedApplication application) {
+ // TODO jvenstad: Remove when there are no more SDv3 pipelines.
+ // Copy all current packages to the new application store
+ application.get().productionDeployments().values().stream()
+ .map(Deployment::applicationVersion)
+ .distinct()
+ .forEach(appVersion -> {
+ byte[] content = controller.applications().artifacts().getApplicationPackage(application.get().id(), appVersion.id());
+ controller.applications().applicationStore().put(application.get().id(), appVersion, content);
+ });
+ // Make sure any ongoing upgrade is cancelled, since future jobs will require the tester artifact.
+ return application.withChange(application.get().change().withoutPlatform().withoutApplication())
+ .withBuiltInternally(true);
+ }
+
/** Orders a run of the given type, or throws an IllegalStateException if that job type is already running. */
public void start(ApplicationId id, JobType type, Versions versions) {
controller.applications().lockIfPresent(id, application -> {
@@ -381,7 +387,7 @@ public class JobController {
});
}
- /** Locks and modifies the list of historic runs for the given application and job type. */
+ /** Locks all runs and modifies the list of historic runs for the given application and job type. */
private void locked(ApplicationId id, JobType type, Consumer<SortedMap<RunId, Run>> modifications) {
try (Lock __ = curator.lock(id, type)) {
SortedMap<RunId, Run> runs = curator.readHistoricRuns(id, type);
