diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-09-18 13:20:21 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-09-18 16:39:10 +0200 |
commit | a64c2bec5539a200769a973702ba6543ae621837 (patch) | |
tree | 0fd86ab8d14cca25018f2a5218becd47f413c61c | |
parent | b6a52c8fda45d7d3f45a8606b419b5f4becfbaed (diff) |
Rename Application -> Instance
51 files changed, 1150 insertions, 1154 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 f097bd3c420..e0203f4063e 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 @@ -151,8 +151,8 @@ public class ApplicationController { Once.after(Duration.ofMinutes(1), () -> { Instant start = clock.instant(); int count = 0; - for (Application application : curator.readApplications()) { - lockIfPresent(application.id(), this::store); + for (Instance instance : curator.readApplications()) { + lockIfPresent(instance.id(), this::store); count++; } log.log(Level.INFO, String.format("Wrote %d applications in %s", count, @@ -161,7 +161,7 @@ public class ApplicationController { } /** Returns the application with the given id, or null if it is not present */ - public Optional<Application> get(ApplicationId id) { + public Optional<Instance> get(ApplicationId id) { return curator.readApplication(id); } @@ -170,17 +170,17 @@ public class ApplicationController { * * @throws IllegalArgumentException if it does not exist */ - public Application require(ApplicationId id) { + public Instance require(ApplicationId id) { return get(id).orElseThrow(() -> new IllegalArgumentException(id + " not found")); } /** Returns a snapshot of all applications */ - public List<Application> asList() { + public List<Instance> asList() { return sort(curator.readApplications()); } /** Returns all applications of a tenant */ - public List<Application> asList(TenantName tenant) { + public List<Instance> asList(TenantName tenant) { return sort(curator.readApplications(tenant)); } @@ -234,7 +234,7 @@ public class ApplicationController { * * @throws IllegalArgumentException if the application already exists */ - public Application createApplication(ApplicationId id, Optional<Credentials> credentials) { + public Instance createApplication(ApplicationId id, Optional<Credentials> credentials) { if (id.instance().isTester()) throw new IllegalArgumentException("'" + id + "' is a tester application!"); try (Lock lock = lock(id)) { @@ -256,7 +256,7 @@ public class ApplicationController { if ( ! id.instance().isTester()) // Only store the application permits for non-user applications. accessControl.createApplication(id, credentials.get()); } - LockedApplication application = new LockedApplication(new Application(id, clock.instant()), lock); + LockedApplication application = new LockedApplication(new Instance(id, clock.instant()), lock); store(application); log.info("Created " + application); return application.get(); @@ -374,19 +374,19 @@ public class ApplicationController { } /** Fetches the requested application package from the artifact store(s). */ - public ApplicationPackage getApplicationPackage(Application application, ApplicationVersion version) { + public ApplicationPackage getApplicationPackage(Instance instance, ApplicationVersion version) { try { - return application.deploymentJobs().deployedInternally() - ? new ApplicationPackage(applicationStore.get(application.id(), version)) - : new ApplicationPackage(artifactRepository.getApplicationPackage(application.id(), version.id())); + return instance.deploymentJobs().deployedInternally() + ? new ApplicationPackage(applicationStore.get(instance.id(), version)) + : new ApplicationPackage(artifactRepository.getApplicationPackage(instance.id(), version.id())); } catch (RuntimeException e) { // If application has switched deployment pipeline, artifacts stored prior to the switch are in the other artifact store. try { - log.info("Fetching application package for " + application.id() + " from alternate repository; it is now deployed " - + (application.deploymentJobs().deployedInternally() ? "internally" : "externally") + "\nException was: " + Exceptions.toMessageString(e)); - return application.deploymentJobs().deployedInternally() - ? new ApplicationPackage(artifactRepository.getApplicationPackage(application.id(), version.id())) - : new ApplicationPackage(applicationStore.get(application.id(), version)); + log.info("Fetching application package for " + instance.id() + " from alternate repository; it is now deployed " + + (instance.deploymentJobs().deployedInternally() ? "internally" : "externally") + "\nException was: " + Exceptions.toMessageString(e)); + return instance.deploymentJobs().deployedInternally() + ? new ApplicationPackage(artifactRepository.getApplicationPackage(instance.id(), version.id())) + : new ApplicationPackage(applicationStore.get(instance.id(), version)); } catch (RuntimeException s) { // If this fails, too, the first failure is most likely the relevant one. e.addSuppressed(s); @@ -475,13 +475,13 @@ public class ApplicationController { * * @return the registered endpoints */ - private Set<ContainerEndpoint> registerEndpointsInDns(Application application, ZoneId zone) { + private Set<ContainerEndpoint> registerEndpointsInDns(Instance instance, ZoneId zone) { var containerEndpoints = new HashSet<ContainerEndpoint>(); - var registerLegacyNames = application.deploymentSpec().globalServiceId().isPresent(); - for (var assignedRotation : application.rotations()) { + var registerLegacyNames = instance.deploymentSpec().globalServiceId().isPresent(); + for (var assignedRotation : instance.rotations()) { var names = new ArrayList<String>(); - var endpoints = application.endpointsIn(controller.system(), assignedRotation.endpointId()) - .scope(Endpoint.Scope.global); + var endpoints = instance.endpointsIn(controller.system(), assignedRotation.endpointId()) + .scope(Endpoint.Scope.global); // Skip rotations which do not apply to this zone. Legacy names always point to all zones if (!registerLegacyNames && !assignedRotation.regions().contains(zone.region())) { @@ -511,20 +511,20 @@ public class ApplicationController { return Collections.unmodifiableSet(containerEndpoints); } - private Optional<ApplicationCertificate> getApplicationCertificate(Application application) { + private Optional<ApplicationCertificate> getApplicationCertificate(Instance instance) { boolean provisionCertificate = provisionApplicationCertificate.with(FetchVector.Dimension.APPLICATION_ID, - application.id().serializedForm()).value(); + instance.id().serializedForm()).value(); if (!provisionCertificate) { return Optional.empty(); } // Re-use certificate if already provisioned - Optional<ApplicationCertificate> applicationCertificate = curator.readApplicationCertificate(application.id()); + Optional<ApplicationCertificate> applicationCertificate = curator.readApplicationCertificate(instance.id()); if(applicationCertificate.isPresent()) return applicationCertificate; - ApplicationCertificate newCertificate = controller.serviceRegistry().applicationCertificateProvider().requestCaSignedCertificate(application.id(), dnsNamesOf(application.id())); - curator.writeApplicationCertificate(application.id(), newCertificate); + ApplicationCertificate newCertificate = controller.serviceRegistry().applicationCertificateProvider().requestCaSignedCertificate(instance.id(), dnsNamesOf(instance.id())); + curator.writeApplicationCertificate(instance.id(), newCertificate); return Optional.of(newCertificate); } @@ -672,7 +672,7 @@ public class ApplicationController { // Find all instances of the application List<ApplicationId> instances = asList(tenantName).stream() - .map(Application::id) + .map(Instance::id) .filter(id -> id.application().equals(applicationName)) .collect(Collectors.toList()); if (instances.size() > 1) @@ -832,14 +832,14 @@ public class ApplicationController { } /** Verify that we don't downgrade an existing production deployment. */ - private void validateRun(Application application, ZoneId zone, Version platformVersion, ApplicationVersion applicationVersion) { - Deployment deployment = application.deployments().get(zone); + private void validateRun(Instance instance, ZoneId zone, Version platformVersion, ApplicationVersion applicationVersion) { + Deployment deployment = instance.deployments().get(zone); if ( zone.environment().isProduction() && deployment != null - && ( platformVersion.compareTo(deployment.version()) < 0 && ! application.change().isPinned() + && ( platformVersion.compareTo(deployment.version()) < 0 && ! instance.change().isPinned() || applicationVersion.compareTo(deployment.applicationVersion()) < 0)) throw new IllegalArgumentException(String.format("Rejecting deployment of %s to %s, as the requested versions (platform: %s, application: %s)" + " are older than the currently deployed (platform: %s, application: %s).", - application, zone, platformVersion, applicationVersion, deployment.version(), deployment.applicationVersion())); + instance, zone, platformVersion, applicationVersion, deployment.version(), deployment.applicationVersion())); } /** Returns the rotation repository, used for managing global rotation assignments */ @@ -852,8 +852,8 @@ public class ApplicationController { } /** Sort given list of applications by application ID */ - private static List<Application> sort(List<Application> applications) { - return applications.stream().sorted(Comparator.comparing(Application::id)).collect(Collectors.toList()); + private static List<Instance> sort(List<Instance> instances) { + return instances.stream().sorted(Comparator.comparing(Instance::id)).collect(Collectors.toList()); } /** diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Instance.java index 77b2f604d5d..60d74e3719d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Instance.java @@ -41,7 +41,7 @@ import java.util.stream.Collectors; * * @author bratseth */ -public class Application { +public class Instance { private final ApplicationId id; private final Instant createdAt; @@ -59,8 +59,8 @@ public class Application { private final List<AssignedRotation> rotations; private final RotationStatus rotationStatus; - /** Creates an empty application */ - public Application(ApplicationId id, Instant now) { + /** Creates an empty instance*/ + public Instance(ApplicationId id, Instant now) { this(id, now, DeploymentSpec.empty, ValidationOverrides.empty, Collections.emptyMap(), new DeploymentJobs(OptionalLong.empty(), Collections.emptyList(), Optional.empty(), false), Change.empty(), Change.empty(), Optional.empty(), Optional.empty(), OptionalInt.empty(), @@ -69,22 +69,22 @@ public class Application { } /** Used from persistence layer: Do not use */ - public Application(ApplicationId id, Instant createdAt, DeploymentSpec deploymentSpec, ValidationOverrides validationOverrides, - List<Deployment> deployments, DeploymentJobs deploymentJobs, Change change, - Change outstandingChange, Optional<IssueId> ownershipIssueId, Optional<User> owner, - OptionalInt majorVersion, ApplicationMetrics metrics, Optional<String> pemDeployKey, - List<AssignedRotation> rotations, RotationStatus rotationStatus) { + public Instance(ApplicationId id, Instant createdAt, DeploymentSpec deploymentSpec, ValidationOverrides validationOverrides, + List<Deployment> deployments, DeploymentJobs deploymentJobs, Change change, + Change outstandingChange, Optional<IssueId> ownershipIssueId, Optional<User> owner, + OptionalInt majorVersion, ApplicationMetrics metrics, Optional<String> pemDeployKey, + List<AssignedRotation> rotations, RotationStatus rotationStatus) { this(id, createdAt, deploymentSpec, validationOverrides, deployments.stream().collect(Collectors.toMap(Deployment::zone, Function.identity())), deploymentJobs, change, outstandingChange, ownershipIssueId, owner, majorVersion, metrics, pemDeployKey, rotations, rotationStatus); } - Application(ApplicationId id, Instant createdAt, DeploymentSpec deploymentSpec, ValidationOverrides validationOverrides, - Map<ZoneId, Deployment> deployments, DeploymentJobs deploymentJobs, Change change, - Change outstandingChange, Optional<IssueId> ownershipIssueId, Optional<User> owner, - OptionalInt majorVersion, ApplicationMetrics metrics, Optional<String> pemDeployKey, - List<AssignedRotation> rotations, RotationStatus rotationStatus) { + Instance(ApplicationId id, Instant createdAt, DeploymentSpec deploymentSpec, ValidationOverrides validationOverrides, + Map<ZoneId, Deployment> deployments, DeploymentJobs deploymentJobs, Change change, + Change outstandingChange, Optional<IssueId> ownershipIssueId, Optional<User> owner, + OptionalInt majorVersion, ApplicationMetrics metrics, Optional<String> pemDeployKey, + List<AssignedRotation> rotations, RotationStatus rotationStatus) { this.id = Objects.requireNonNull(id, "id cannot be null"); this.createdAt = Objects.requireNonNull(createdAt, "instant of creation cannot be null"); this.deploymentSpec = Objects.requireNonNull(deploymentSpec, "deploymentSpec cannot be null"); @@ -223,9 +223,9 @@ public class Application { @Override public boolean equals(Object o) { if (this == o) return true; - if (! (o instanceof Application)) return false; + if (! (o instanceof Instance)) return false; - Application that = (Application) o; + Instance that = (Instance) o; return id.equals(that.id); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java index d1a5d7bbf28..88fc6307a84 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java @@ -60,16 +60,16 @@ public class LockedApplication { /** * Used to create a locked application * - * @param application The application to lock. + * @param instance The application to lock. * @param lock The lock for the application. */ - LockedApplication(Application application, Lock lock) { - this(Objects.requireNonNull(lock, "lock cannot be null"), application.id(), application.createdAt(), - application.deploymentSpec(), application.validationOverrides(), - application.deployments(), - application.deploymentJobs(), application.change(), application.outstandingChange(), - application.ownershipIssueId(), application.owner(), application.majorVersion(), application.metrics(), - application.pemDeployKey(), application.rotations(), application.rotationStatus()); + LockedApplication(Instance instance, Lock lock) { + this(Objects.requireNonNull(lock, "lock cannot be null"), instance.id(), instance.createdAt(), + instance.deploymentSpec(), instance.validationOverrides(), + instance.deployments(), + instance.deploymentJobs(), instance.change(), instance.outstandingChange(), + instance.ownershipIssueId(), instance.owner(), instance.majorVersion(), instance.metrics(), + instance.pemDeployKey(), instance.rotations(), instance.rotationStatus()); } private LockedApplication(Lock lock, ApplicationId id, Instant createdAt, @@ -97,10 +97,10 @@ public class LockedApplication { } /** Returns a read-only copy of this */ - public Application get() { - return new Application(id, createdAt, deploymentSpec, validationOverrides, deployments, deploymentJobs, change, - outstandingChange, ownershipIssueId, owner, majorVersion, metrics, pemDeployKey, - rotations, rotationStatus); + public Instance get() { + return new Instance(id, createdAt, deploymentSpec, validationOverrides, deployments, deploymentJobs, change, + outstandingChange, ownershipIssueId, owner, majorVersion, metrics, pemDeployKey, + rotations, rotationStatus); } public LockedApplication withBuiltInternally(boolean builtInternally) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java index 56e77f3254b..b58476acd41 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java @@ -5,7 +5,7 @@ import com.google.common.collect.ImmutableList; import com.yahoo.component.Version; import com.yahoo.config.application.api.DeploymentSpec.UpgradePolicy; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import java.time.Instant; @@ -24,15 +24,15 @@ import java.util.stream.Stream; // TODO jvenstad: Make an AbstractFilteringList based on JobList and let this extend it for free not()s? public class ApplicationList { - private final ImmutableList<Application> list; + private final ImmutableList<Instance> list; - private ApplicationList(Iterable<Application> applications) { + private ApplicationList(Iterable<Instance> applications) { this.list = ImmutableList.copyOf(applications); } // ----------------------------------- Factories - public static ApplicationList from(Iterable<Application> applications) { + public static ApplicationList from(Iterable<Instance> applications) { return new ApplicationList(applications); } @@ -43,10 +43,10 @@ public class ApplicationList { // ----------------------------------- Accessors /** Returns the applications in this as an immutable list */ - public List<Application> asList() { return list; } + public List<Instance> asList() { return list; } /** Returns the ids of the applications in this as an immutable list */ - public List<ApplicationId> idList() { return ImmutableList.copyOf(list.stream().map(Application::id)::iterator); } + public List<ApplicationId> idList() { return ImmutableList.copyOf(list.stream().map(Instance::id)::iterator); } public boolean isEmpty() { return list.isEmpty(); } @@ -200,34 +200,34 @@ public class ApplicationList { // ----------------------------------- Internal helpers - private static boolean isUpgradingTo(Version version, Application application) { - return application.change().platform().equals(Optional.of(version)); + private static boolean isUpgradingTo(Version version, Instance instance) { + return instance.change().platform().equals(Optional.of(version)); } - private static boolean failingOn(Version version, Application application) { - return ! JobList.from(application) + private static boolean failingOn(Version version, Instance instance) { + return ! JobList.from(instance) .failing() .lastCompleted().on(version) .isEmpty(); } - private static boolean failingUpgradeToVersionSince(Application application, Version version, Instant threshold) { - return ! JobList.from(application) + private static boolean failingUpgradeToVersionSince(Instance instance, Version version, Instant threshold) { + return ! JobList.from(instance) .not().failingApplicationChange() .firstFailing().before(threshold) .lastCompleted().on(version) .isEmpty(); } - private static boolean failingApplicationChangeSince(Application application, Instant threshold) { - return ! JobList.from(application) + private static boolean failingApplicationChangeSince(Instance instance, Instant threshold) { + return ! JobList.from(instance) .failingApplicationChange() .firstFailing().before(threshold) .isEmpty(); } /** Convenience converter from a stream to an ApplicationList */ - private static ApplicationList listOf(Stream<Application> applications) { + private static ApplicationList listOf(Stream<Instance> applications) { return from(applications::iterator); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java index dce40f1c583..9ae2ed94d2a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/JobList.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.application; import com.google.common.collect.ImmutableList; import com.yahoo.component.Version; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.JobStatus.JobRun; @@ -39,8 +39,8 @@ public class JobList { return new JobList(jobs); } - public static JobList from(Application application) { - return from(application.deploymentJobs().jobStatus().values()); + public static JobList from(Instance instance) { + return from(instance.deploymentJobs().jobStatus().values()); } // ----------------------------------- Accessors diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java index 91f9e2d56d7..c9234b87a8b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/athenz/impl/AthenzFacade.java @@ -16,7 +16,7 @@ import com.yahoo.vespa.athenz.api.OktaAccessToken; import com.yahoo.vespa.athenz.client.zms.RoleAction; import com.yahoo.vespa.athenz.client.zms.ZmsClient; import com.yahoo.vespa.athenz.client.zts.ZtsClient; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory; import com.yahoo.vespa.hosted.controller.api.integration.athenz.ApplicationAction; import com.yahoo.vespa.hosted.controller.security.AccessControl; @@ -91,7 +91,7 @@ public class AthenzFacade implements AccessControl { } @Override - public Tenant updateTenant(TenantSpec tenantSpec, Credentials credentials, List<Tenant> existing, List<Application> applications) { + public Tenant updateTenant(TenantSpec tenantSpec, Credentials credentials, List<Tenant> existing, List<Instance> instances) { AthenzTenantSpec spec = (AthenzTenantSpec) tenantSpec; AthenzCredentials athenzCredentials = (AthenzCredentials) credentials; AthenzDomain newDomain = spec.domain(); @@ -121,12 +121,12 @@ public class AthenzFacade implements AccessControl { else { // Delete and recreate tenant, and optionally application, resources in Athenz otherwise. log("createTenancy(tenantDomain=%s, service=%s)", newDomain, service); zmsClient.createTenancy(newDomain, service, athenzCredentials.token()); - for (Application application : applications) - createApplication(newDomain, application.id().application(), athenzCredentials.token()); + for (Instance instance : instances) + createApplication(newDomain, instance.id().application(), athenzCredentials.token()); log("deleteTenancy(tenantDomain=%s, service=%s)", oldDomain, service); - for (Application application : applications) - deleteApplication(oldDomain, application.id().application(), athenzCredentials.token()); + for (Instance instance : instances) + deleteApplication(oldDomain, instance.id().application(), athenzCredentials.token()); zmsClient.deleteTenancy(oldDomain, service, athenzCredentials.token()); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java index b4fe8ea2971..05f9eb7a501 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.application.api.DeploymentSpec.Step; import com.yahoo.config.provision.ApplicationId; import com.yahoo.log.LogLevel; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; @@ -57,7 +57,7 @@ import static java.util.stream.Collectors.toList; /** * Responsible for scheduling deployment jobs in a build system and keeping - * {@link Application#change()} in sync with what is scheduled. + * {@link Instance#change()} in sync with what is scheduled. * * This class is multi-thread safe. * @@ -209,20 +209,20 @@ public class DeploymentTrigger { /** Force triggering of a job for given application. */ public List<JobType> forceTrigger(ApplicationId applicationId, JobType jobType, String user) { - Application application = applications().require(applicationId); + Instance instance = applications().require(applicationId); if (jobType == component) { - if (application.deploymentJobs().deployedInternally()) + if (instance.deploymentJobs().deployedInternally()) throw new IllegalArgumentException(applicationId + " has no component job we can trigger."); - buildService.trigger(BuildJob.of(applicationId, application.deploymentJobs().projectId().getAsLong(), jobType.jobName())); + buildService.trigger(BuildJob.of(applicationId, instance.deploymentJobs().projectId().getAsLong(), jobType.jobName())); return singletonList(component); } - Versions versions = Versions.from(application.change(), application, deploymentFor(application, jobType), + Versions versions = Versions.from(instance.change(), instance, deploymentFor(instance, jobType), controller.systemVersion()); String reason = "Job triggered manually by " + user; - return (jobType.isProduction() && ! isTested(application, versions) - ? testJobs(application, versions, reason, clock.instant(), __ -> true).stream() - : Stream.of(deploymentJob(application, versions, application.change(), jobType, reason, clock.instant()))) + return (jobType.isProduction() && ! isTested(instance, versions) + ? testJobs(instance, versions, reason, clock.instant(), __ -> true).stream() + : Stream.of(deploymentJob(instance, versions, instance.change(), jobType, reason, clock.instant()))) .peek(this::trigger) .map(Job::jobType).collect(toList()); } @@ -277,13 +277,13 @@ public class DeploymentTrigger { return controller.applications(); } - private Optional<JobRun> successOn(Application application, JobType jobType, Versions versions) { - return application.deploymentJobs().statusOf(jobType).flatMap(JobStatus::lastSuccess) - .filter(versions::targetsMatch); + private Optional<JobRun> successOn(Instance instance, JobType jobType, Versions versions) { + return instance.deploymentJobs().statusOf(jobType).flatMap(JobStatus::lastSuccess) + .filter(versions::targetsMatch); } - private Optional<Deployment> deploymentFor(Application application, JobType jobType) { - return Optional.ofNullable(application.deployments().get(jobType.zone(controller.system()))); + private Optional<Deployment> deploymentFor(Instance instance, JobType jobType) { + return Optional.ofNullable(instance.deployments().get(jobType.zone(controller.system()))); } private static <T extends Comparable<T>> Optional<T> max(Optional<T> o1, Optional<T> o2) { @@ -369,42 +369,42 @@ public class DeploymentTrigger { } /** Returns whether given job should be triggered */ - private boolean canTrigger(JobType job, Versions versions, Application application, List<JobType> parallelJobs) { - if (jobStateOf(application, job) != idle) return false; + private boolean canTrigger(JobType job, Versions versions, Instance instance, List<JobType> parallelJobs) { + if (jobStateOf(instance, job) != idle) return false; // Are we already running jobs which are not in the set which can run in parallel with this? - if (parallelJobs != null && ! parallelJobs.containsAll(runningProductionJobs(application))) return false; + if (parallelJobs != null && ! parallelJobs.containsAll(runningProductionJobs(instance))) return false; // Are there another suspended deployment such that we shouldn't simultaneously change this? - if (job.isProduction() && isSuspendedInAnotherZone(application, job.zone(controller.system()))) return false; + if (job.isProduction() && isSuspendedInAnotherZone(instance, job.zone(controller.system()))) return false; - return triggerAt(clock.instant(), job, versions, application); + return triggerAt(clock.instant(), job, versions, instance); } /** Returns whether given job should be triggered */ - private boolean canTrigger(JobType job, Versions versions, Application application) { - return canTrigger(job, versions, application, null); + private boolean canTrigger(JobType job, Versions versions, Instance instance) { + return canTrigger(job, versions, instance, null); } - private boolean isSuspendedInAnotherZone(Application application, ZoneId zone) { - for (Deployment deployment : application.productionDeployments().values()) { + private boolean isSuspendedInAnotherZone(Instance instance, ZoneId zone) { + for (Deployment deployment : instance.productionDeployments().values()) { if ( ! deployment.zone().equals(zone) - && controller.applications().isSuspended(new DeploymentId(application.id(), deployment.zone()))) + && controller.applications().isSuspended(new DeploymentId(instance.id(), deployment.zone()))) return true; } return false; } /** Returns whether the given job can trigger at the given instant */ - public boolean triggerAt(Instant instant, JobType job, Versions versions, Application application) { - Optional<JobStatus> jobStatus = application.deploymentJobs().statusOf(job); + public boolean triggerAt(Instant instant, JobType job, Versions versions, Instance instance) { + Optional<JobStatus> jobStatus = instance.deploymentJobs().statusOf(job); if (jobStatus.isEmpty()) return true; if (jobStatus.get().pausedUntil().isPresent() && jobStatus.get().pausedUntil().getAsLong() > clock.instant().toEpochMilli()) return false; if (jobStatus.get().isSuccess()) return true; // Success if (jobStatus.get().lastCompleted().isEmpty()) return true; // Never completed if (jobStatus.get().firstFailing().isEmpty()) return true; // Should not happen as firstFailing should be set for an unsuccessful job if ( ! versions.targetsMatch(jobStatus.get().lastCompleted().get())) return true; // Always trigger as targets have changed - if (application.deploymentSpec().upgradePolicy() == DeploymentSpec.UpgradePolicy.canary) return true; // Don't throttle canaries + if (instance.deploymentSpec().upgradePolicy() == DeploymentSpec.UpgradePolicy.canary) return true; // Don't throttle canaries Instant firstFailing = jobStatus.get().firstFailing().get().at(); Instant lastCompleted = jobStatus.get().lastCompleted().get().at(); @@ -426,28 +426,28 @@ public class DeploymentTrigger { // ---------- Job state helpers ---------- - private List<JobType> runningProductionJobs(Application application) { - return application.deploymentJobs().jobStatus().keySet().parallelStream() - .filter(JobType::isProduction) - .filter(job -> isRunning(application, job)) - .collect(toList()); + private List<JobType> runningProductionJobs(Instance instance) { + return instance.deploymentJobs().jobStatus().keySet().parallelStream() + .filter(JobType::isProduction) + .filter(job -> isRunning(instance, job)) + .collect(toList()); } /** Returns whether the given job is currently running; false if completed since last triggered, asking the build service otherwise. */ - private boolean isRunning(Application application, JobType jobType) { - return ! application.deploymentJobs().statusOf(jobType) - .flatMap(job -> job.lastCompleted().map(run -> run.at().isAfter(job.lastTriggered().get().at()))) - .orElse(false) - && EnumSet.of(running, queued).contains(jobStateOf(application, jobType)); + private boolean isRunning(Instance instance, JobType jobType) { + return ! instance.deploymentJobs().statusOf(jobType) + .flatMap(job -> job.lastCompleted().map(run -> run.at().isAfter(job.lastTriggered().get().at()))) + .orElse(false) + && EnumSet.of(running, queued).contains(jobStateOf(instance, jobType)); } - private JobState jobStateOf(Application application, JobType jobType) { - if (application.deploymentJobs().deployedInternally()) { - Optional<Run> run = controller.jobController().last(application.id(), jobType); + private JobState jobStateOf(Instance instance, JobType jobType) { + if (instance.deploymentJobs().deployedInternally()) { + Optional<Run> run = controller.jobController().last(instance.id(), jobType); return run.isPresent() && ! run.get().hasEnded() ? JobState.running : JobState.idle; } - return buildService.stateOf(BuildJob.of(application.id(), - application.deploymentJobs().projectId().getAsLong(), + return buildService.stateOf(BuildJob.of(instance.id(), + instance.deploymentJobs().projectId().getAsLong(), jobType.jobName())); } @@ -465,19 +465,19 @@ public class DeploymentTrigger { * Additionally, if the application is pinned to a Vespa version, and the given change has a (this) platform, * the deployment for the job must be on the pinned version. */ - public boolean isComplete(Change change, Application application, JobType jobType) { - Optional<Deployment> existingDeployment = deploymentFor(application, jobType); + public boolean isComplete(Change change, Instance instance, JobType jobType) { + Optional<Deployment> existingDeployment = deploymentFor(instance, jobType); if ( change.isPinned() && change.platform().isPresent() && ! existingDeployment.map(Deployment::version).equals(change.platform())) return false; - return application.deploymentJobs().statusOf(jobType).flatMap(JobStatus::lastSuccess) - .map(job -> change.platform().map(job.platform()::equals).orElse(true) + return instance.deploymentJobs().statusOf(jobType).flatMap(JobStatus::lastSuccess) + .map(job -> change.platform().map(job.platform()::equals).orElse(true) && change.application().map(job.application()::equals).orElse(true)) - .orElse(false) + .orElse(false) || jobType.isProduction() - && existingDeployment.map(deployment -> ! isUpgrade(change, deployment) && isDowngrade(application.change(), deployment)) + && existingDeployment.map(deployment -> ! isUpgrade(change, deployment) && isDowngrade(instance.change(), deployment)) .orElse(false); } @@ -489,24 +489,24 @@ public class DeploymentTrigger { return change.downgrades(deployment.version()) || change.downgrades(deployment.applicationVersion()); } - private boolean isTested(Application application, Versions versions) { - return testedIn(application, systemTest, versions) - && testedIn(application, stagingTest, versions) - || alreadyTriggered(application, versions); + private boolean isTested(Instance instance, Versions versions) { + return testedIn(instance, systemTest, versions) + && testedIn(instance, stagingTest, versions) + || alreadyTriggered(instance, versions); } - public boolean testedIn(Application application, JobType testType, Versions versions) { + public boolean testedIn(Instance instance, JobType testType, Versions versions) { if (testType == systemTest) - return successOn(application, systemTest, versions).isPresent(); + return successOn(instance, systemTest, versions).isPresent(); if (testType == stagingTest) - return successOn(application, stagingTest, versions).filter(versions::sourcesMatchIfPresent).isPresent(); + return successOn(instance, stagingTest, versions).filter(versions::sourcesMatchIfPresent).isPresent(); throw new IllegalArgumentException(testType + " is not a test job!"); } - public boolean alreadyTriggered(Application application, Versions versions) { - return application.deploymentJobs().jobStatus().values().stream() - .filter(job -> job.type().isProduction()) - .anyMatch(job -> job.lastTriggered() + public boolean alreadyTriggered(Instance instance, Versions versions) { + return instance.deploymentJobs().jobStatus().values().stream() + .filter(job -> job.type().isProduction()) + .anyMatch(job -> job.lastTriggered() .filter(versions::targetsMatch) .filter(versions::sourcesMatchIfPresent) .isPresent()); @@ -514,24 +514,24 @@ public class DeploymentTrigger { // ---------- Change management o_O ---------- - private boolean acceptNewApplicationVersion(Application application) { - if ( ! application.deploymentSpec().canChangeRevisionAt(clock.instant())) return false; - if (application.change().application().isPresent()) return true; // Replacing a previous application change is ok. - if (application.deploymentJobs().hasFailures()) return true; // Allow changes to fix upgrade problems. - return application.change().platform().isEmpty(); + private boolean acceptNewApplicationVersion(Instance instance) { + if ( ! instance.deploymentSpec().canChangeRevisionAt(clock.instant())) return false; + if (instance.change().application().isPresent()) return true; // Replacing a previous application change is ok. + if (instance.deploymentJobs().hasFailures()) return true; // Allow changes to fix upgrade problems. + return instance.change().platform().isEmpty(); } - private Change remainingChange(Application application) { - DeploymentSteps steps = steps(application.deploymentSpec()); + private Change remainingChange(Instance instance) { + DeploymentSteps steps = steps(instance.deploymentSpec()); List<JobType> jobs = steps.production().isEmpty() ? steps.testJobs() : steps.productionJobs(); - Change change = application.change(); - if (jobs.stream().allMatch(job -> isComplete(application.change().withoutApplication(), application, job))) + Change change = instance.change(); + if (jobs.stream().allMatch(job -> isComplete(instance.change().withoutApplication(), instance, job))) change = change.withoutPlatform(); - if (jobs.stream().allMatch(job -> isComplete(application.change().withoutPlatform(), application, job))) + if (jobs.stream().allMatch(job -> isComplete(instance.change().withoutPlatform(), instance, job))) change = change.withoutApplication(); return change; @@ -542,34 +542,34 @@ public class DeploymentTrigger { /** * Returns the list of test jobs that should run now, and that need to succeed on the given versions for it to be considered tested. */ - private List<Job> testJobs(Application application, Versions versions, String reason, Instant availableSince) { - return testJobs(application, versions, reason, availableSince, jobType -> canTrigger(jobType, versions, application)); + private List<Job> testJobs(Instance instance, Versions versions, String reason, Instant availableSince) { + return testJobs(instance, versions, reason, availableSince, jobType -> canTrigger(jobType, versions, instance)); } /** * Returns the list of test jobs that need to succeed on the given versions for it to be considered tested, filtered by the given condition. */ - private List<Job> testJobs(Application application, Versions versions, String reason, Instant availableSince, Predicate<JobType> condition) { + private List<Job> testJobs(Instance instance, Versions versions, String reason, Instant availableSince, Predicate<JobType> condition) { List<Job> jobs = new ArrayList<>(); - for (JobType jobType : steps(application.deploymentSpec()).testJobs()) { - Optional<JobRun> completion = successOn(application, jobType, versions) + for (JobType jobType : steps(instance.deploymentSpec()).testJobs()) { + Optional<JobRun> completion = successOn(instance, jobType, versions) .filter(run -> versions.sourcesMatchIfPresent(run) || jobType == systemTest); if (completion.isEmpty() && condition.test(jobType)) - jobs.add(deploymentJob(application, versions, application.change(), jobType, reason, availableSince)); + jobs.add(deploymentJob(instance, versions, instance.change(), jobType, reason, availableSince)); } return jobs; } - private Job deploymentJob(Application application, Versions versions, Change change, JobType jobType, String reason, Instant availableSince) { - boolean isRetry = application.deploymentJobs().statusOf(jobType) - .map(JobStatus::isOutOfCapacity) - .orElse(false); + private Job deploymentJob(Instance instance, Versions versions, Change change, JobType jobType, String reason, Instant availableSince) { + boolean isRetry = instance.deploymentJobs().statusOf(jobType) + .map(JobStatus::isOutOfCapacity) + .orElse(false); if (isRetry) reason += "; retrying on out of capacity"; JobRun triggering = JobRun.triggering(versions.targetPlatform(), versions.targetApplication(), versions.sourcePlatform(), versions.sourceApplication(), reason, clock.instant()); - return new Job(application, triggering, jobType, availableSince, isRetry, change.application().isPresent()); + return new Job(instance, triggering, jobType, availableSince, isRetry, change.application().isPresent()); } // ---------- Data containers ---------- @@ -583,9 +583,9 @@ public class DeploymentTrigger { private final boolean isRetry; private final boolean isApplicationUpgrade; - private Job(Application application, JobRun triggering, JobType jobType, Instant availableSince, + private Job(Instance instance, JobRun triggering, JobType jobType, Instant availableSince, boolean isRetry, boolean isApplicationUpgrade) { - super(application.id(), application.deploymentJobs().projectId().getAsLong(), jobType.jobName()); + super(instance.id(), instance.deploymentJobs().projectId().getAsLong(), jobType.jobName()); this.jobType = jobType; this.triggering = triggering; this.availableSince = availableSince; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index 69de59e55eb..61230c598af 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -19,7 +19,7 @@ import com.yahoo.security.KeyUtils; import com.yahoo.security.SignatureAlgorithm; import com.yahoo.security.X509CertificateBuilder; import com.yahoo.security.X509CertificateUtils; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; 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; @@ -568,11 +568,11 @@ public class InternalStepRunner implements StepRunner { /** Sends a mail with a notification of a failed run, if one should be sent. */ private void sendNotification(Run run, DualLogger logger) { - Application application = controller.applications().require(run.id().application()); - Notifications notifications = application.deploymentSpec().notifications(); - boolean newCommit = application.change().application() - .map(run.versions().targetApplication()::equals) - .orElse(false); + Instance instance = controller.applications().require(run.id().application()); + Notifications notifications = instance.deploymentSpec().notifications(); + boolean newCommit = instance.change().application() + .map(run.versions().targetApplication()::equals) + .orElse(false); When when = newCommit ? failingCommit : failing; List<String> recipients = new ArrayList<>(notifications.emailAddressesFor(when)); @@ -605,7 +605,7 @@ public class InternalStepRunner implements StepRunner { } /** Returns the real application with the given id. */ - private Application application(ApplicationId id) { + private Instance application(ApplicationId id) { controller.applications().lockOrThrow(id, __ -> { }); // Memory fence. return controller.applications().require(id); } 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 765cb465f50..031c88e55af 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 @@ -10,7 +10,7 @@ import com.yahoo.vespa.flags.BooleanFlag; import com.yahoo.vespa.flags.FetchVector; import com.yahoo.vespa.flags.FlagSource; import com.yahoo.vespa.flags.Flags; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.LockedApplication; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; @@ -197,7 +197,7 @@ public class JobController { public List<ApplicationId> applications() { return copyOf(controller.applications().asList().stream() .filter(application -> application.deploymentJobs().deployedInternally()) - .map(Application::id) + .map(Instance::id) .iterator()); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java index 068a41ed92c..70424cf9813 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.component.Version; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.Change; @@ -112,37 +112,37 @@ public class Versions { } /** Create versions using change contained in application */ - public static Versions from(Application application, Version defaultPlatformVersion) { - return from(application.change(), application, Optional.empty(), defaultPlatformVersion); + public static Versions from(Instance instance, Version defaultPlatformVersion) { + return from(instance.change(), instance, Optional.empty(), defaultPlatformVersion); } /** Create versions using given change and application */ - public static Versions from(Change change, Application application, Optional<Deployment> deployment, + public static Versions from(Change change, Instance instance, Optional<Deployment> deployment, Version defaultPlatformVersion) { - return new Versions(targetPlatform(application, change, deployment, defaultPlatformVersion), - targetApplication(application, change, deployment), + return new Versions(targetPlatform(instance, change, deployment, defaultPlatformVersion), + targetApplication(instance, change, deployment), deployment.map(Deployment::version), deployment.map(Deployment::applicationVersion)); } - private static Version targetPlatform(Application application, Change change, Optional<Deployment> deployment, + private static Version targetPlatform(Instance instance, Change change, Optional<Deployment> deployment, Version defaultVersion) { if (change.isPinned() && change.platform().isPresent()) return change.platform().get(); return max(change.platform(), deployment.map(Deployment::version)) - .orElseGet(() -> application.oldestDeployedPlatform().orElse(defaultVersion)); + .orElseGet(() -> instance.oldestDeployedPlatform().orElse(defaultVersion)); } - private static ApplicationVersion targetApplication(Application application, Change change, + private static ApplicationVersion targetApplication(Instance instance, Change change, Optional<Deployment> deployment) { return max(change.application(), deployment.map(Deployment::applicationVersion)) - .orElseGet(() -> defaultApplicationVersion(application)); + .orElseGet(() -> defaultApplicationVersion(instance)); } - private static ApplicationVersion defaultApplicationVersion(Application application) { - return application.oldestDeployedApplication() - .orElseGet(() -> Optional.ofNullable(application.deploymentJobs().jobStatus().get(JobType.component)) + private static ApplicationVersion defaultApplicationVersion(Instance instance) { + return instance.oldestDeployedApplication() + .orElseGet(() -> Optional.ofNullable(instance.deploymentJobs().jobStatus().get(JobType.component)) .flatMap(JobStatus::lastSuccess) .map(JobStatus.JobRun::application) .orElse(ApplicationVersion.unknown)); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java index 5b4d573f214..3a3666beb27 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.organization.ApplicationSummary; @@ -86,10 +86,10 @@ public class ApplicationOwnershipConfirmer extends Maintainer { /** Escalate ownership issues which have not been closed before a defined amount of time has passed. */ private void ensureConfirmationResponses() { - for (Application application : controller().applications().asList()) - application.ownershipIssueId().ifPresent(issueId -> { + for (Instance instance : controller().applications().asList()) + instance.ownershipIssueId().ifPresent(issueId -> { try { - Tenant tenant = tenantOf(application.id()); + Tenant tenant = tenantOf(instance.id()); ownershipIssues.ensureResponse(issueId, tenant.type() == Tenant.Type.athenz ? tenant.contact() : Optional.empty()); } catch (RuntimeException e) { @@ -114,8 +114,8 @@ public class ApplicationOwnershipConfirmer extends Maintainer { }); } - private User determineAssignee(Tenant tenant, Application application) { - return application.owner().orElse( + private User determineAssignee(Tenant tenant, Instance instance) { + return instance.owner().orElse( tenant instanceof UserTenant ? userFor(tenant) : null ); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java index 357076b5f73..c005cec598c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; @@ -72,13 +72,13 @@ public class ClusterInfoMaintainer extends Maintainer { @Override protected void maintain() { - for (Application application : controller().applications().asList()) { - for (Deployment deployment : application.deployments().values()) { - DeploymentId deploymentId = new DeploymentId(application.id(), deployment.zone()); + for (Instance instance : controller().applications().asList()) { + for (Deployment deployment : instance.deployments().values()) { + DeploymentId deploymentId = new DeploymentId(instance.id(), deployment.zone()); try { var nodes = nodeRepository.list(deploymentId.zoneId(), deploymentId.applicationId()); Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes); - controller().applications().lockIfPresent(application.id(), lockedApplication -> + controller().applications().lockIfPresent(instance.id(), lockedApplication -> controller.applications().store(lockedApplication.withClusterInfo(deployment.zone(), clusterInfo))); } catch (Exception e) { log.log(Level.WARNING, "Failing getting cluster information for " + deploymentId, e); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java index d396bfda669..44e0c9fd393 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirer.java @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.yolean.Exceptions; @@ -23,15 +23,15 @@ public class DeploymentExpirer extends Maintainer { @Override protected void maintain() { - for (Application application : controller().applications().asList()) { - for (Deployment deployment : application.deployments().values()) { + for (Instance instance : controller().applications().asList()) { + for (Deployment deployment : instance.deployments().values()) { if (!isExpired(deployment)) continue; try { - log.log(Level.INFO, "Expiring deployment of " + application.id() + " in " + deployment.zone()); - controller().applications().deactivate(application.id(), deployment.zone()); + log.log(Level.INFO, "Expiring deployment of " + instance.id() + " in " + deployment.zone()); + controller().applications().deactivate(instance.id(), deployment.zone()); } catch (Exception e) { - log.log(Level.WARNING, "Could not expire " + deployment + " of " + application + + log.log(Level.WARNING, "Could not expire " + deployment + " of " + instance + ": " + Exceptions.toMessageString(e) + ". Retrying in " + maintenanceInterval()); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java index 48e2702b9e0..455064550aa 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java @@ -4,15 +4,13 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.SystemName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.organization.DeploymentIssues; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import com.yahoo.vespa.hosted.controller.application.ApplicationList; -import com.yahoo.vespa.hosted.controller.tenant.AthenzTenant; import com.yahoo.vespa.hosted.controller.tenant.Tenant; -import com.yahoo.vespa.hosted.controller.tenant.UserTenant; import com.yahoo.yolean.Exceptions; import java.time.Duration; @@ -52,7 +50,7 @@ public class DeploymentIssueReporter extends Maintainer { } /** Returns the applications to maintain issue status for. */ - private List<Application> applications() { + private List<Instance> applications() { return ApplicationList.from(controller().applications().asList()) .withProjectId() .asList(); @@ -63,18 +61,18 @@ public class DeploymentIssueReporter extends Maintainer { * and store the issue id for the filed issues. Also, clear the issueIds of applications * where deployment has not failed for this amount of time. */ - private void maintainDeploymentIssues(List<Application> applications) { - Set<ApplicationId> failingApplications = ApplicationList.from(applications) + private void maintainDeploymentIssues(List<Instance> instances) { + Set<ApplicationId> failingApplications = ApplicationList.from(instances) .failingApplicationChangeSince(controller().clock().instant().minus(maxFailureAge)) .asList().stream() - .map(Application::id) + .map(Instance::id) .collect(Collectors.toSet()); - for (Application application : applications) - if (failingApplications.contains(application.id())) - fileDeploymentIssueFor(application.id()); + for (Instance instance : instances) + if (failingApplications.contains(instance.id())) + fileDeploymentIssueFor(instance.id()); else - store(application.id(), null); + store(instance.id(), null); } /** @@ -82,7 +80,7 @@ public class DeploymentIssueReporter extends Maintainer { * applications that have been failing the upgrade to the system version for * longer than the set grace period, or update this list if the issue already exists. */ - private void maintainPlatformIssue(List<Application> applications) { + private void maintainPlatformIssue(List<Instance> instances) { if (controller().system() == SystemName.cd) return; @@ -91,12 +89,12 @@ public class DeploymentIssueReporter extends Maintainer { if ((controller().versionStatus().version(systemVersion).confidence() != broken)) return; - if (ApplicationList.from(applications) + if (ApplicationList.from(instances) .failingUpgradeToVersionSince(systemVersion, controller().clock().instant().minus(upgradeGracePeriod)) .isEmpty()) return; - List<ApplicationId> failingApplications = ApplicationList.from(applications) + List<ApplicationId> failingApplications = ApplicationList.from(instances) .failingUpgradeToVersionSince(systemVersion, controller().clock().instant()) .idList(); @@ -129,8 +127,8 @@ public class DeploymentIssueReporter extends Maintainer { } /** Escalate issues for which there has been no activity for a certain amount of time. */ - private void escalateInactiveDeploymentIssues(Collection<Application> applications) { - applications.forEach(application -> application.deploymentJobs().issueId().ifPresent(issueId -> { + private void escalateInactiveDeploymentIssues(Collection<Instance> instances) { + instances.forEach(application -> application.deploymentJobs().issueId().ifPresent(issueId -> { try { Tenant tenant = ownerOf(application.id()); deploymentIssues.escalateIfInactive(issueId, diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java index 7c060c599ef..d77856a1661 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainer.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.SystemName; import com.yahoo.log.LogLevel; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.application.Deployment; @@ -42,12 +42,12 @@ public class DeploymentMetricsMaintainer extends Maintainer { protected void maintain() { AtomicInteger failures = new AtomicInteger(0); AtomicReference<Exception> lastException = new AtomicReference<>(null); - List<Application> applicationList = applications.asList(); + List<Instance> instanceList = applications.asList(); // Run parallel stream inside a custom ForkJoinPool so that we can control the number of threads used ForkJoinPool pool = new ForkJoinPool(applicationsToUpdateInParallel); pool.submit(() -> - applicationList.parallelStream().forEach(application -> { + instanceList.parallelStream().forEach(application -> { applications.lockIfPresent(application.id(), locked -> applications.store(locked.with(controller().metrics().getApplicationMetrics(application.id())))); @@ -84,7 +84,7 @@ public class DeploymentMetricsMaintainer extends Maintainer { log.log(LogLevel.WARNING, String.format("Failed to gather metrics for %d/%d applications. Retrying in %s. Last error: %s", failures.get(), - applicationList.size(), + instanceList.size(), maintenanceInterval(), Exceptions.toMessageString(lastException.get()))); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java index c7b76696d84..b062c23d98a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.google.common.collect.ImmutableMap; import com.yahoo.config.provision.ApplicationId; import com.yahoo.jdisc.Metric; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationList; @@ -78,13 +78,13 @@ public class MetricsReporter extends Maintainer { metric.set(DEPLOYMENT_WARNINGS, warnings, metric.createContext(dimensions(application))); }); - for (Application application : applications.asList()) - application.deploymentJobs().statusOf(JobType.component) - .flatMap(JobStatus::lastSuccess) - .flatMap(run -> run.application().buildTime()) - .ifPresent(buildTime -> metric.set(DEPLOYMENT_BUILD_AGE_SECONDS, + for (Instance instance : applications.asList()) + instance.deploymentJobs().statusOf(JobType.component) + .flatMap(JobStatus::lastSuccess) + .flatMap(run -> run.application().buildTime()) + .ifPresent(buildTime -> metric.set(DEPLOYMENT_BUILD_AGE_SECONDS, controller().clock().instant().getEpochSecond() - buildTime.getEpochSecond(), - metric.createContext(dimensions(application.id())))); + metric.createContext(dimensions(instance.id())))); } private void reportQueuedNameServiceRequests() { @@ -93,33 +93,33 @@ public class MetricsReporter extends Maintainer { } private static double deploymentFailRatio(ApplicationList applicationList) { - List<Application> applications = applicationList.asList(); - if (applications.isEmpty()) return 0; + List<Instance> instances = applicationList.asList(); + if (instances.isEmpty()) return 0; - return (double) applications.stream().filter(a -> a.deploymentJobs().hasFailures()).count() / - (double) applications.size(); + return (double) instances.stream().filter(a -> a.deploymentJobs().hasFailures()).count() / + (double) instances.size(); } private static Map<ApplicationId, Duration> averageDeploymentDurations(ApplicationList applications, Instant now) { return applications.asList().stream() - .collect(Collectors.toMap(Application::id, + .collect(Collectors.toMap(Instance::id, application -> averageDeploymentDuration(application, now))); } private static Map<ApplicationId, Integer> deploymentsFailingUpgrade(ApplicationList applications) { return applications.asList() .stream() - .collect(Collectors.toMap(Application::id, MetricsReporter::deploymentsFailingUpgrade)); + .collect(Collectors.toMap(Instance::id, MetricsReporter::deploymentsFailingUpgrade)); } - private static int deploymentsFailingUpgrade(Application application) { - return JobList.from(application).upgrading().failing().size(); + private static int deploymentsFailingUpgrade(Instance instance) { + return JobList.from(instance).upgrading().failing().size(); } - private static Duration averageDeploymentDuration(Application application, Instant now) { - List<Duration> jobDurations = application.deploymentJobs().jobStatus().values().stream() - .filter(status -> status.lastTriggered().isPresent()) - .map(status -> { + private static Duration averageDeploymentDuration(Instance instance, Instant now) { + List<Duration> jobDurations = instance.deploymentJobs().jobStatus().values().stream() + .filter(status -> status.lastTriggered().isPresent()) + .map(status -> { Instant triggeredAt = status.lastTriggered().get().at(); Instant runningUntil = status.lastCompleted() .map(JobStatus.JobRun::at) @@ -127,7 +127,7 @@ public class MetricsReporter extends Maintainer { .orElse(now); return Duration.between(triggeredAt, runningUntil); }) - .collect(Collectors.toList()); + .collect(Collectors.toList()); return jobDurations.stream() .reduce(Duration::plus) .map(totalDuration -> totalDuration.dividedBy(jobDurations.size())) @@ -136,7 +136,7 @@ public class MetricsReporter extends Maintainer { private static Map<ApplicationId, Integer> deploymentWarnings(ApplicationList applications) { return applications.asList().stream() - .collect(Collectors.toMap(Application::id, a -> maxWarningCountOf(a.deployments().values()))); + .collect(Collectors.toMap(Instance::id, a -> maxWarningCountOf(a.deployments().values()))); } private static int maxWarningCountOf(Collection<Deployment> deployments) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java index b34bd65901e..047905c0841 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import java.time.Duration; @@ -19,11 +19,11 @@ public class OutstandingChangeDeployer extends Maintainer { @Override protected void maintain() { - for (Application application : controller().applications().asList()) { - if ( application.outstandingChange().hasTargets() - && application.deploymentSpec().canChangeRevisionAt(controller().clock().instant())) { - controller().applications().deploymentTrigger().triggerChange(application.id(), - application.outstandingChange()); + for (Instance instance : controller().applications().asList()) { + if (instance.outstandingChange().hasTargets() + && instance.deploymentSpec().canChangeRevisionAt(controller().clock().instant())) { + controller().applications().deploymentTrigger().triggerChange(instance.id(), + instance.outstandingChange()); } } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java index a0eff95db48..0e7086809d3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.log.LogLevel; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService; @@ -73,9 +73,9 @@ public class RotationStatusUpdater extends Maintainer { } } - private RotationStatus getStatus(Application application) { + private RotationStatus getStatus(Instance instance) { var statusMap = new LinkedHashMap<RotationId, Map<ZoneId, RotationState>>(); - for (var assignedRotation : application.rotations()) { + for (var assignedRotation : instance.rotations()) { var rotation = applications.rotationRepository().getRotation(assignedRotation.rotationId()); if (rotation.isEmpty()) continue; var rotationStatus = service.getHealthStatus(rotation.get().name()).entrySet().stream() diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java index 322d0aa8d30..10decd226cb 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.application.api.DeploymentSpec.UpgradePolicy; import com.yahoo.vespa.curator.Lock; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.application.ApplicationList; import com.yahoo.vespa.hosted.controller.application.Change; @@ -103,15 +103,15 @@ public class Upgrader extends Maintainer { applications = applications.canUpgradeAt(controller().clock().instant()); // wait with applications that are currently blocking upgrades applications = applications.byIncreasingDeployedVersion(); // start with lowest versions applications = applications.first(numberOfApplicationsToUpgrade()); // throttle upgrades - for (Application application : applications.asList()) - controller().applications().deploymentTrigger().triggerChange(application.id(), Change.of(version)); + for (Instance instance : applications.asList()) + controller().applications().deploymentTrigger().triggerChange(instance.id(), Change.of(version)); } private void cancelUpgradesOf(ApplicationList applications, String reason) { if (applications.isEmpty()) return; log.info("Cancelling upgrading of " + applications.asList().size() + " applications: " + reason); - for (Application application : applications.asList()) - controller().applications().deploymentTrigger().cancelChange(application.id(), PLATFORM); + for (Instance instance : applications.asList()) + controller().applications().deploymentTrigger().cancelChange(instance.id(), PLATFORM); } /** Returns the number of applications to upgrade in this run */ diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java index 54dba6ec0db..24d960c3635 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java @@ -12,7 +12,7 @@ import com.yahoo.slime.Cursor; import com.yahoo.slime.Inspector; import com.yahoo.slime.ObjectTraverser; import com.yahoo.slime.Slime; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; @@ -48,7 +48,7 @@ import java.util.OptionalLong; import java.util.stream.Collectors; /** - * Serializes {@link Application} to/from slime. + * Serializes {@link Instance} to/from slime. * This class is multithread safe. * * @author bratseth @@ -162,25 +162,25 @@ public class ApplicationSerializer { // ------------------ Serialization - public Slime toSlime(Application application) { + public Slime toSlime(Instance instance) { Slime slime = new Slime(); Cursor root = slime.setObject(); - root.setString(idField, application.id().serializedForm()); - root.setLong(createdAtField, application.createdAt().toEpochMilli()); - root.setString(deploymentSpecField, application.deploymentSpec().xmlForm()); - root.setString(validationOverridesField, application.validationOverrides().xmlForm()); - deploymentsToSlime(application.deployments().values(), root.setArray(deploymentsField)); - toSlime(application.deploymentJobs(), root.setObject(deploymentJobsField)); - toSlime(application.change(), root, deployingField); - toSlime(application.outstandingChange(), root, outstandingChangeField); - application.ownershipIssueId().ifPresent(issueId -> root.setString(ownershipIssueIdField, issueId.value())); - application.owner().ifPresent(owner -> root.setString(ownerField, owner.username())); - application.majorVersion().ifPresent(majorVersion -> root.setLong(majorVersionField, majorVersion)); - root.setDouble(queryQualityField, application.metrics().queryServiceQuality()); - root.setDouble(writeQualityField, application.metrics().writeServiceQuality()); - application.pemDeployKey().ifPresent(pemDeployKey -> root.setString(pemDeployKeyField, pemDeployKey)); - assignedRotationsToSlime(application.rotations(), root, assignedRotationsField); - toSlime(application.rotationStatus(), root.setArray(rotationStatusField)); + root.setString(idField, instance.id().serializedForm()); + root.setLong(createdAtField, instance.createdAt().toEpochMilli()); + root.setString(deploymentSpecField, instance.deploymentSpec().xmlForm()); + root.setString(validationOverridesField, instance.validationOverrides().xmlForm()); + deploymentsToSlime(instance.deployments().values(), root.setArray(deploymentsField)); + toSlime(instance.deploymentJobs(), root.setObject(deploymentJobsField)); + toSlime(instance.change(), root, deployingField); + toSlime(instance.outstandingChange(), root, outstandingChangeField); + instance.ownershipIssueId().ifPresent(issueId -> root.setString(ownershipIssueIdField, issueId.value())); + instance.owner().ifPresent(owner -> root.setString(ownerField, owner.username())); + instance.majorVersion().ifPresent(majorVersion -> root.setLong(majorVersionField, majorVersion)); + root.setDouble(queryQualityField, instance.metrics().queryServiceQuality()); + root.setDouble(writeQualityField, instance.metrics().writeServiceQuality()); + instance.pemDeployKey().ifPresent(pemDeployKey -> root.setString(pemDeployKeyField, pemDeployKey)); + assignedRotationsToSlime(instance.rotations(), root, assignedRotationsField); + toSlime(instance.rotationStatus(), root.setArray(rotationStatusField)); return slime; } @@ -344,7 +344,7 @@ public class ApplicationSerializer { // ------------------ Deserialization - public Application fromSlime(Slime slime) { + public Instance fromSlime(Slime slime) { Inspector root = slime.get(); ApplicationId id = ApplicationId.fromSerializedForm(root.field(idField).asString()); @@ -364,9 +364,9 @@ public class ApplicationSerializer { List<AssignedRotation> assignedRotations = assignedRotationsFromSlime(deploymentSpec, root); RotationStatus rotationStatus = rotationStatusFromSlime(root); - return new Application(id, createdAt, deploymentSpec, validationOverrides, deployments, deploymentJobs, - deploying, outstandingChange, ownershipIssueId, owner, majorVersion, metrics, - pemDeployKey, assignedRotations, rotationStatus); + return new Instance(id, createdAt, deploymentSpec, validationOverrides, deployments, deploymentJobs, + deploying, outstandingChange, ownershipIssueId, owner, majorVersion, metrics, + pemDeployKey, assignedRotations, rotationStatus); } private List<Deployment> deploymentsFromSlime(Inspector array) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java index 2536e406d2e..6822d441cdf 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/CuratorDb.java @@ -13,7 +13,7 @@ import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.curator.Lock; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificate; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId; @@ -331,23 +331,23 @@ public class CuratorDb { // -------------- Application --------------------------------------------- - public void writeApplication(Application application) { - curator.set(applicationPath(application.id()), asJson(applicationSerializer.toSlime(application))); + public void writeApplication(Instance instance) { + curator.set(applicationPath(instance.id()), asJson(applicationSerializer.toSlime(instance))); } - public Optional<Application> readApplication(ApplicationId application) { + public Optional<Instance> readApplication(ApplicationId application) { return readSlime(applicationPath(application)).map(applicationSerializer::fromSlime); } - public List<Application> readApplications() { + public List<Instance> readApplications() { return readApplications(ignored -> true); } - public List<Application> readApplications(TenantName name) { + public List<Instance> readApplications(TenantName name) { return readApplications(application -> application.tenant().equals(name)); } - private List<Application> readApplications(Predicate<ApplicationId> applicationFilter) { + private List<Instance> readApplications(Predicate<ApplicationId> applicationFilter) { return curator.getChildren(applicationRoot).stream() .map(ApplicationId::fromSerializedForm) .filter(applicationFilter) diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 875ac43f356..c7b8e148e31 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -26,7 +26,7 @@ import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.athenz.client.zms.ZmsClientException; import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.hosted.controller.AlreadyExistsException; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.NotExistsException; import com.yahoo.vespa.hosted.controller.api.ActivateResult; @@ -335,10 +335,10 @@ public class ApplicationApiHandler extends LoggingRequestHandler { TenantName tenant = TenantName.from(tenantName); Slime slime = new Slime(); Cursor array = slime.setArray(); - for (Application application : controller.applications().asList(tenant)) { - if (applicationName.isPresent() && ! application.id().application().toString().equals(applicationName.get())) + for (Instance instance : controller.applications().asList(tenant)) { + if (applicationName.isPresent() && ! instance.id().application().toString().equals(applicationName.get())) continue; - toSlime(application, array.addObject(), request); + toSlime(instance, array.addObject(), request); } return new SlimeJsonResponse(slime); } @@ -372,7 +372,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { return new MessageResponse(messageBuilder.toString()); } - private Application getApplication(String tenantName, String applicationName, String instanceName) { + private Instance getApplication(String tenantName, String applicationName, String instanceName) { ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, instanceName); return controller.applications().get(applicationId) .orElseThrow(() -> new NotExistsException(applicationId + " not found")); @@ -462,40 +462,40 @@ public class ApplicationApiHandler extends LoggingRequestHandler { return new MessageResponse(type.jobName() + " for " + id + " paused for " + DeploymentTrigger.maxPause); } - private void toSlime(Cursor object, Application application, HttpRequest request) { - object.setString("tenant", application.id().tenant().value()); - object.setString("application", application.id().application().value()); - object.setString("instance", application.id().instance().value()); + private void toSlime(Cursor object, Instance instance, HttpRequest request) { + object.setString("tenant", instance.id().tenant().value()); + object.setString("application", instance.id().application().value()); + object.setString("instance", instance.id().instance().value()); object.setString("deployments", withPath("/application/v4" + - "/tenant/" + application.id().tenant().value() + - "/application/" + application.id().application().value() + - "/instance/" + application.id().instance().value() + "/job/", + "/tenant/" + instance.id().tenant().value() + + "/application/" + instance.id().application().value() + + "/instance/" + instance.id().instance().value() + "/job/", request.getUri()).toString()); - application.deploymentJobs().statusOf(JobType.component) - .flatMap(JobStatus::lastSuccess) - .map(run -> run.application().source()) - .ifPresent(source -> sourceRevisionToSlime(source, object.setObject("source"))); + instance.deploymentJobs().statusOf(JobType.component) + .flatMap(JobStatus::lastSuccess) + .map(run -> run.application().source()) + .ifPresent(source -> sourceRevisionToSlime(source, object.setObject("source"))); - application.deploymentJobs().projectId() - .ifPresent(id -> object.setLong("projectId", id)); + instance.deploymentJobs().projectId() + .ifPresent(id -> object.setLong("projectId", id)); // Currently deploying change - if ( ! application.change().isEmpty()) { - toSlime(object.setObject("deploying"), application.change()); + if ( ! instance.change().isEmpty()) { + toSlime(object.setObject("deploying"), instance.change()); } // Outstanding change - if ( ! application.outstandingChange().isEmpty()) { - toSlime(object.setObject("outstandingChange"), application.outstandingChange()); + if ( ! instance.outstandingChange().isEmpty()) { + toSlime(object.setObject("outstandingChange"), instance.outstandingChange()); } // Jobs sorted according to deployment spec List<JobStatus> jobStatus = controller.applications().deploymentTrigger() - .steps(application.deploymentSpec()) - .sortedJobs(application.deploymentJobs().jobStatus().values()); + .steps(instance.deploymentSpec()) + .sortedJobs(instance.deploymentJobs().jobStatus().values()); - object.setBool("deployedInternally", application.deploymentJobs().deployedInternally()); + object.setBool("deployedInternally", instance.deploymentJobs().deployedInternally()); Cursor deploymentsArray = object.setArray("deploymentJobs"); for (JobStatus job : jobStatus) { Cursor jobObject = deploymentsArray.addObject(); @@ -510,7 +510,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { // Change blockers Cursor changeBlockers = object.setArray("changeBlockers"); - application.deploymentSpec().changeBlocker().forEach(changeBlocker -> { + instance.deploymentSpec().changeBlocker().forEach(changeBlocker -> { Cursor changeBlockerObject = changeBlockers.addObject(); changeBlockerObject.setBool("versions", changeBlocker.blocksVersions()); changeBlockerObject.setBool("revisions", changeBlocker.blocksRevisions()); @@ -522,27 +522,27 @@ public class ApplicationApiHandler extends LoggingRequestHandler { }); // Compile version. The version that should be used when building an application - object.setString("compileVersion", compileVersion(application.id()).toFullString()); + object.setString("compileVersion", compileVersion(instance.id()).toFullString()); - application.majorVersion().ifPresent(majorVersion -> object.setLong("majorVersion", majorVersion)); + instance.majorVersion().ifPresent(majorVersion -> object.setLong("majorVersion", majorVersion)); // Rotation Cursor globalRotationsArray = object.setArray("globalRotations"); - application.endpointsIn(controller.system()) - .scope(Endpoint.Scope.global) - .legacy(false) // Hide legacy names - .asList().stream() - .map(Endpoint::url) - .map(URI::toString) - .forEach(globalRotationsArray::addString); - - application.rotations().stream() - .map(AssignedRotation::rotationId) - .findFirst() - .ifPresent(rotation -> object.setString("rotationId", rotation.asString())); + instance.endpointsIn(controller.system()) + .scope(Endpoint.Scope.global) + .legacy(false) // Hide legacy names + .asList().stream() + .map(Endpoint::url) + .map(URI::toString) + .forEach(globalRotationsArray::addString); + + instance.rotations().stream() + .map(AssignedRotation::rotationId) + .findFirst() + .ifPresent(rotation -> object.setString("rotationId", rotation.asString())); // Per-cluster rotations - Set<RoutingPolicy> routingPolicies = controller.applications().routingPolicies().get(application.id()); + Set<RoutingPolicy> routingPolicies = controller.applications().routingPolicies().get(instance.id()); for (RoutingPolicy policy : routingPolicies) { policy.rotationEndpointsIn(controller.system()).asList().stream() .map(Endpoint::url) @@ -552,8 +552,8 @@ public class ApplicationApiHandler extends LoggingRequestHandler { // Deployments sorted according to deployment spec List<Deployment> deployments = controller.applications().deploymentTrigger() - .steps(application.deploymentSpec()) - .sortedDeployments(application.deployments().values()); + .steps(instance.deploymentSpec()) + .sortedDeployments(instance.deployments().values()); Cursor instancesArray = object.setArray("instances"); for (Deployment deployment : deployments) { Cursor deploymentObject = instancesArray.addObject(); @@ -563,60 +563,60 @@ public class ApplicationApiHandler extends LoggingRequestHandler { // 0 rotations: No fields written // 1 rotation : Write legacy field and endpointStatus field // >1 rotation : Write only endpointStatus field - if (application.rotations().size() == 1) { + if (instance.rotations().size() == 1) { // TODO(mpolden): Stop writing this field once clients stop expecting it - toSlime(application.rotationStatus().of(application.rotations().get(0).rotationId(), deployment), + toSlime(instance.rotationStatus().of(instance.rotations().get(0).rotationId(), deployment), deploymentObject); } - if (!application.rotations().isEmpty()) { - toSlime(application.rotations(), application.rotationStatus(), deployment, deploymentObject); + if (!instance.rotations().isEmpty()) { + toSlime(instance.rotations(), instance.rotationStatus(), deployment, deploymentObject); } } if (recurseOverDeployments(request)) // List full deployment information when recursive. - toSlime(deploymentObject, new DeploymentId(application.id(), deployment.zone()), deployment, request); + toSlime(deploymentObject, new DeploymentId(instance.id(), deployment.zone()), deployment, request); else { deploymentObject.setString("environment", deployment.zone().environment().value()); deploymentObject.setString("region", deployment.zone().region().value()); - deploymentObject.setString("instance", application.id().instance().value()); // pointless + deploymentObject.setString("instance", instance.id().instance().value()); // pointless deploymentObject.setString("url", withPath(request.getUri().getPath() + "/environment/" + deployment.zone().environment().value() + "/region/" + deployment.zone().region().value() + - ( request.getUri().getPath().contains("/instance/") ? "" : "/instance/" + application.id().instance().value()), + ( request.getUri().getPath().contains("/instance/") ? "" : "/instance/" + instance.id().instance().value()), request.getUri()).toString()); } } - application.pemDeployKey().ifPresent(key -> object.setString("pemDeployKey", key)); + instance.pemDeployKey().ifPresent(key -> object.setString("pemDeployKey", key)); // Metrics Cursor metricsObject = object.setObject("metrics"); - metricsObject.setDouble("queryServiceQuality", application.metrics().queryServiceQuality()); - metricsObject.setDouble("writeServiceQuality", application.metrics().writeServiceQuality()); + metricsObject.setDouble("queryServiceQuality", instance.metrics().queryServiceQuality()); + metricsObject.setDouble("writeServiceQuality", instance.metrics().writeServiceQuality()); // Activity Cursor activity = object.setObject("activity"); - application.activity().lastQueried().ifPresent(instant -> activity.setLong("lastQueried", instant.toEpochMilli())); - application.activity().lastWritten().ifPresent(instant -> activity.setLong("lastWritten", instant.toEpochMilli())); - application.activity().lastQueriesPerSecond().ifPresent(value -> activity.setDouble("lastQueriesPerSecond", value)); - application.activity().lastWritesPerSecond().ifPresent(value -> activity.setDouble("lastWritesPerSecond", value)); + instance.activity().lastQueried().ifPresent(instant -> activity.setLong("lastQueried", instant.toEpochMilli())); + instance.activity().lastWritten().ifPresent(instant -> activity.setLong("lastWritten", instant.toEpochMilli())); + instance.activity().lastQueriesPerSecond().ifPresent(value -> activity.setDouble("lastQueriesPerSecond", value)); + instance.activity().lastWritesPerSecond().ifPresent(value -> activity.setDouble("lastWritesPerSecond", value)); - application.ownershipIssueId().ifPresent(issueId -> object.setString("ownershipIssueId", issueId.value())); - application.owner().ifPresent(owner -> object.setString("owner", owner.username())); - application.deploymentJobs().issueId().ifPresent(issueId -> object.setString("deploymentIssueId", issueId.value())); + instance.ownershipIssueId().ifPresent(issueId -> object.setString("ownershipIssueId", issueId.value())); + instance.owner().ifPresent(owner -> object.setString("owner", owner.username())); + instance.deploymentJobs().issueId().ifPresent(issueId -> object.setString("deploymentIssueId", issueId.value())); } private HttpResponse deployment(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) { ApplicationId id = ApplicationId.from(tenantName, applicationName, instanceName); - Application application = controller.applications().get(id) - .orElseThrow(() -> new NotExistsException(id + " not found")); + Instance instance = controller.applications().get(id) + .orElseThrow(() -> new NotExistsException(id + " not found")); - DeploymentId deploymentId = new DeploymentId(application.id(), + DeploymentId deploymentId = new DeploymentId(instance.id(), ZoneId.from(environment, region)); - Deployment deployment = application.deployments().get(deploymentId.zoneId()); + Deployment deployment = instance.deployments().get(deploymentId.zoneId()); if (deployment == null) - throw new NotExistsException(application + " is not deployed in " + deploymentId.zoneId()); + throw new NotExistsException(instance + " is not deployed in " + deploymentId.zoneId()); Slime slime = new Slime(); toSlime(slime.setObject(), deploymentId, deployment, request); @@ -747,11 +747,11 @@ public class ApplicationApiHandler extends LoggingRequestHandler { } private HttpResponse setGlobalRotationOverride(String tenantName, String applicationName, String instanceName, String environment, String region, boolean inService, HttpRequest request) { - Application application = controller.applications().require(ApplicationId.from(tenantName, applicationName, instanceName)); + Instance instance = controller.applications().require(ApplicationId.from(tenantName, applicationName, instanceName)); ZoneId zone = ZoneId.from(environment, region); - Deployment deployment = application.deployments().get(zone); + Deployment deployment = instance.deployments().get(zone); if (deployment == null) { - throw new NotExistsException(application + " has no deployment in " + zone); + throw new NotExistsException(instance + " has no deployment in " + zone); } Inspector requestData = toSlime(request.getData()).get(); @@ -760,10 +760,10 @@ public class ApplicationApiHandler extends LoggingRequestHandler { long timestamp = controller.clock().instant().getEpochSecond(); EndpointStatus.Status status = inService ? EndpointStatus.Status.in : EndpointStatus.Status.out; EndpointStatus endpointStatus = new EndpointStatus(status, reason, agent, timestamp); - controller.applications().setGlobalRotationStatus(new DeploymentId(application.id(), deployment.zone()), + controller.applications().setGlobalRotationStatus(new DeploymentId(instance.id(), deployment.zone()), endpointStatus); return new MessageResponse(String.format("Successfully set %s in %s.%s %s service", - application.id().toShortString(), + instance.id().toShortString(), deployment.zone().environment().value(), deployment.zone().region().value(), inService ? "in" : "out of")); @@ -792,17 +792,17 @@ public class ApplicationApiHandler extends LoggingRequestHandler { private HttpResponse rotationStatus(String tenantName, String applicationName, String instanceName, String environment, String region, Optional<String> endpointId) { ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, instanceName); - Application application = controller.applications().require(applicationId); + Instance instance = controller.applications().require(applicationId); ZoneId zone = ZoneId.from(environment, region); - RotationId rotation = findRotationId(application, endpointId); - Deployment deployment = application.deployments().get(zone); + RotationId rotation = findRotationId(instance, endpointId); + Deployment deployment = instance.deployments().get(zone); if (deployment == null) { - throw new NotExistsException(application + " has no deployment in " + zone); + throw new NotExistsException(instance + " has no deployment in " + zone); } Slime slime = new Slime(); Cursor response = slime.setObject(); - toSlime(application.rotationStatus().of(rotation, deployment), response); + toSlime(instance.rotationStatus().of(rotation, deployment), response); return new SlimeJsonResponse(slime); } @@ -870,7 +870,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { } private HttpResponse deploying(String tenant, String application, String instance, HttpRequest request) { - Application app = controller.applications().require(ApplicationId.from(tenant, application, instance)); + Instance app = controller.applications().require(ApplicationId.from(tenant, application, instance)); Slime slime = new Slime(); Cursor root = slime.setObject(); if ( ! app.change().isEmpty()) { @@ -955,10 +955,10 @@ public class ApplicationApiHandler extends LoggingRequestHandler { Optional<Credentials> credentials = controller.tenants().require(id.tenant()).type() == Tenant.Type.user ? Optional.empty() : Optional.of(accessControlRequests.credentials(id.tenant(), requestObject, request.getJDiscRequest())); - Application application = controller.applications().createApplication(id, credentials); + Instance instance = controller.applications().createApplication(id, credentials); Slime slime = new Slime(); - toSlime(application, slime.setObject(), request); + toSlime(instance, slime.setObject(), request); return new SlimeJsonResponse(slime); } catch (ZmsClientException e) { // TODO: Push conversion down @@ -1132,7 +1132,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { // Redeploy the existing deployment with the same versions. Optional<Deployment> deployment = controller.applications().get(applicationId) - .map(Application::deployments) + .map(Instance::deployments) .flatMap(deployments -> Optional.ofNullable(deployments.get(zone))); if(deployment.isEmpty()) @@ -1200,10 +1200,10 @@ public class ApplicationApiHandler extends LoggingRequestHandler { } private HttpResponse deactivate(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) { - Application application = controller.applications().require(ApplicationId.from(tenantName, applicationName, instanceName)); + Instance instance = controller.applications().require(ApplicationId.from(tenantName, applicationName, instanceName)); // Attempt to deactivate application even if the deployment is not known by the controller - DeploymentId deploymentId = new DeploymentId(application.id(), ZoneId.from(environment, region)); + DeploymentId deploymentId = new DeploymentId(instance.id(), ZoneId.from(environment, region)); controller.applications().deactivate(deploymentId.applicationId(), deploymentId.zoneId()); return new MessageResponse("Deactivated " + deploymentId); @@ -1292,12 +1292,12 @@ public class ApplicationApiHandler extends LoggingRequestHandler { default: throw new IllegalArgumentException("Unexpected tenant type '" + tenant.type() + "'."); } Cursor applicationArray = object.setArray("applications"); - for (Application application : controller.applications().asList(tenant.name())) { - if ( ! application.id().instance().isTester()) { + for (Instance instance : controller.applications().asList(tenant.name())) { + if ( ! instance.id().instance().isTester()) { if (recurseOverApplications(request)) - toSlime(applicationArray.addObject(), application, request); + toSlime(applicationArray.addObject(), instance, request); else - toSlime(application, applicationArray.addObject(), request); + toSlime(instance, applicationArray.addObject(), request); } } } @@ -1378,14 +1378,14 @@ public class ApplicationApiHandler extends LoggingRequestHandler { return Joiner.on("/").join(elements); } - private void toSlime(Application application, Cursor object, HttpRequest request) { - object.setString("tenant", application.id().tenant().value()); - object.setString("application", application.id().application().value()); - object.setString("instance", application.id().instance().value()); + private void toSlime(Instance instance, Cursor object, HttpRequest request) { + object.setString("tenant", instance.id().tenant().value()); + object.setString("application", instance.id().application().value()); + object.setString("instance", instance.id().instance().value()); object.setString("url", withPath("/application/v4" + - "/tenant/" + application.id().tenant().value() + - "/application/" + application.id().application().value() + - "/instance/" + application.id().instance().value(), + "/tenant/" + instance.id().tenant().value() + + "/application/" + instance.id().application().value() + + "/instance/" + instance.id().instance().value(), request.getUri()).toString()); } @@ -1575,21 +1575,21 @@ public class ApplicationApiHandler extends LoggingRequestHandler { return dataParts; } - private static RotationId findRotationId(Application application, Optional<String> endpointId) { - if (application.rotations().isEmpty()) { - throw new NotExistsException("global rotation does not exist for " + application); + private static RotationId findRotationId(Instance instance, Optional<String> endpointId) { + if (instance.rotations().isEmpty()) { + throw new NotExistsException("global rotation does not exist for " + instance); } if (endpointId.isPresent()) { - return application.rotations().stream() - .filter(r -> r.endpointId().id().equals(endpointId.get())) - .map(AssignedRotation::rotationId) - .findFirst() - .orElseThrow(() -> new NotExistsException("endpoint " + endpointId.get() + - " does not exist for " + application)); - } else if (application.rotations().size() > 1) { - throw new IllegalArgumentException(application + " has multiple rotations. Query parameter 'endpointId' must be given"); + return instance.rotations().stream() + .filter(r -> r.endpointId().id().equals(endpointId.get())) + .map(AssignedRotation::rotationId) + .findFirst() + .orElseThrow(() -> new NotExistsException("endpoint " + endpointId.get() + + " does not exist for " + instance)); + } else if (instance.rotations().size() > 1) { + throw new IllegalArgumentException(instance + " has multiple rotations. Query parameter 'endpointId' must be given"); } - return application.rotations().get(0).rotationId(); + return instance.rotations().get(0).rotationId(); } private static String rotationStateString(RotationState state) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java index 9940d5635b1..4742a8d54ef 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java @@ -10,7 +10,7 @@ import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.NotExistsException; import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; @@ -69,18 +69,18 @@ class JobControllerApiHandlerHelper { * @return Response with all job types that have recorded runs for the application _and_ the status for the last run of that type */ static HttpResponse jobTypeResponse(Controller controller, ApplicationId id, URI baseUriForJobs) { - Application application = controller.applications().require(id); - Change change = application.change(); - DeploymentSteps steps = new DeploymentSteps(application.deploymentSpec(), controller::system); + Instance instance = controller.applications().require(id); + Change change = instance.change(); + DeploymentSteps steps = new DeploymentSteps(instance.deploymentSpec(), controller::system); // The logic for pending runs imitates DeploymentTrigger logic; not good, but the trigger wiring must be re-written to reuse :S Map<JobType, Versions> pendingProduction = steps.productionJobs().stream() - .filter(type -> ! controller.applications().deploymentTrigger().isComplete(change, application, type)) + .filter(type -> ! controller.applications().deploymentTrigger().isComplete(change, instance, type)) .collect(Collectors.toMap(type -> type, type -> Versions.from(change, - application, - Optional.ofNullable(application.deployments().get(type.zone(controller.system()))), + instance, + Optional.ofNullable(instance.deployments().get(type.zone(controller.system()))), controller.systemVersion()), (v1, v2) -> { throw new IllegalStateException("Entries '" + v1 + "' and '" + v2 + "' have the same key!"); }, LinkedHashMap::new)); @@ -96,9 +96,9 @@ class JobControllerApiHandlerHelper { Cursor responseObject = slime.setObject(); Cursor lastVersionsObject = responseObject.setObject("lastVersions"); - if (application.deploymentJobs().statusOf(component).flatMap(JobStatus::lastSuccess).isPresent()) { - lastPlatformToSlime(lastVersionsObject.setObject("platform"), controller, application, change, steps); - lastApplicationToSlime(lastVersionsObject.setObject("application"), application, change, steps, controller); + if (instance.deploymentJobs().statusOf(component).flatMap(JobStatus::lastSuccess).isPresent()) { + lastPlatformToSlime(lastVersionsObject.setObject("platform"), controller, instance, change, steps); + lastApplicationToSlime(lastVersionsObject.setObject("application"), instance, change, steps, controller); } Cursor deployingObject = responseObject.setObject("deploying"); @@ -112,10 +112,10 @@ class JobControllerApiHandlerHelper { Cursor deploymentsObject = deploymentsArray.addObject(); steps.toJobs(step).forEach(type -> { ZoneId zone = type.zone(controller.system()); - Deployment deployment = application.deployments().get(zone); + Deployment deployment = instance.deployments().get(zone); if (deployment != null) deploymentToSlime(deploymentsObject.setObject(zone.region().value()), - application, + instance, change, pendingProduction, running, @@ -128,7 +128,7 @@ class JobControllerApiHandlerHelper { steps.jobs().forEach(type -> { jobTypeToSlime(jobsObject.setObject(shortNameOf(type, controller.system())), controller, - application, + instance, type, steps, pendingProduction, @@ -140,7 +140,7 @@ class JobControllerApiHandlerHelper { for (JobType type : JobType.allIn(controller.system())) if ( type.environment() != null && type.environment().isManuallyDeployed()) - controller.jobController().last(application.id(), type) + controller.jobController().last(instance.id(), type) .ifPresent(last -> { Cursor devJobObject = devJobsObject.setObject(type.jobName()); runToSlime(devJobObject.setArray("runs").addObject(), @@ -152,11 +152,11 @@ class JobControllerApiHandlerHelper { return new SlimeJsonResponse(slime); } - private static void lastPlatformToSlime(Cursor lastPlatformObject, Controller controller, Application application, Change change, DeploymentSteps steps) { + private static void lastPlatformToSlime(Cursor lastPlatformObject, Controller controller, Instance instance, Change change, DeploymentSteps steps) { VespaVersion lastVespa = controller.versionStatus().version(controller.systemVersion()); - VespaVersion.Confidence targetConfidence = application.deploymentSpec().upgradePolicy() == defaultPolicy ? normal - : application.deploymentSpec().upgradePolicy() == conservative ? high - : broken; + VespaVersion.Confidence targetConfidence = instance.deploymentSpec().upgradePolicy() == defaultPolicy ? normal + : instance.deploymentSpec().upgradePolicy() == conservative ? high + : broken; for (VespaVersion version : controller.versionStatus().versions()) if ( ! version.versionNumber().isAfter(controller.systemVersion()) && version.confidence().equalOrHigherThan(targetConfidence)) @@ -165,86 +165,86 @@ class JobControllerApiHandlerHelper { Version lastPlatform = lastVespa.versionNumber(); lastPlatformObject.setString("platform", lastPlatform.toString()); lastPlatformObject.setLong("at", lastVespa.committedAt().toEpochMilli()); - long completed = steps.productionJobs().stream().filter(type -> controller.applications().deploymentTrigger().isComplete(Change.of(lastPlatform), application, type)).count(); + long completed = steps.productionJobs().stream().filter(type -> controller.applications().deploymentTrigger().isComplete(Change.of(lastPlatform), instance, type)).count(); if (Optional.of(lastPlatform).equals(change.platform())) lastPlatformObject.setString("deploying", completed + " of " + steps.productionJobs().size() + " complete"); else if (completed == steps.productionJobs().size()) lastPlatformObject.setString("completed", completed + " of " + steps.productionJobs().size() + " complete"); - else if ( ! application.deploymentSpec().canUpgradeAt(controller.clock().instant())) { - lastPlatformObject.setString("blocked", application.deploymentSpec().changeBlocker().stream() - .filter(blocker -> blocker.blocksVersions()) - .filter(blocker -> blocker.window().includes(controller.clock().instant())) - .findAny().map(blocker -> blocker.window().toString()).get()); + else if ( ! instance.deploymentSpec().canUpgradeAt(controller.clock().instant())) { + lastPlatformObject.setString("blocked", instance.deploymentSpec().changeBlocker().stream() + .filter(blocker -> blocker.blocksVersions()) + .filter(blocker -> blocker.window().includes(controller.clock().instant())) + .findAny().map(blocker -> blocker.window().toString()).get()); } else lastPlatformObject.setString("pending", - application.change().isEmpty() + instance.change().isEmpty() ? "Waiting for upgrade slot" : "Waiting for current deployment to complete"); } - private static void lastApplicationToSlime(Cursor lastApplicationObject, Application application, Change change, DeploymentSteps steps, Controller controller) { + private static void lastApplicationToSlime(Cursor lastApplicationObject, Instance instance, Change change, DeploymentSteps steps, Controller controller) { long completed; - ApplicationVersion lastApplication = application.deploymentJobs().statusOf(component).flatMap(JobStatus::lastSuccess).get().application(); + ApplicationVersion lastApplication = instance.deploymentJobs().statusOf(component).flatMap(JobStatus::lastSuccess).get().application(); applicationVersionToSlime(lastApplicationObject.setObject("application"), lastApplication); - lastApplicationObject.setLong("at", application.deploymentJobs().statusOf(component).flatMap(JobStatus::lastSuccess).get().at().toEpochMilli()); - completed = steps.productionJobs().stream().filter(type -> controller.applications().deploymentTrigger().isComplete(Change.of(lastApplication), application, type)).count(); + lastApplicationObject.setLong("at", instance.deploymentJobs().statusOf(component).flatMap(JobStatus::lastSuccess).get().at().toEpochMilli()); + completed = steps.productionJobs().stream().filter(type -> controller.applications().deploymentTrigger().isComplete(Change.of(lastApplication), instance, type)).count(); if (Optional.of(lastApplication).equals(change.application())) lastApplicationObject.setString("deploying", completed + " of " + steps.productionJobs().size() + " complete"); else if (completed == steps.productionJobs().size()) lastApplicationObject.setString("completed", completed + " of " + steps.productionJobs().size() + " complete"); - else if ( ! application.deploymentSpec().canChangeRevisionAt(controller.clock().instant())) { - lastApplicationObject.setString("blocked", application.deploymentSpec().changeBlocker().stream() - .filter(blocker -> blocker.blocksRevisions()) - .filter(blocker -> blocker.window().includes(controller.clock().instant())) - .findAny().map(blocker -> blocker.window().toString()).get()); + else if ( ! instance.deploymentSpec().canChangeRevisionAt(controller.clock().instant())) { + lastApplicationObject.setString("blocked", instance.deploymentSpec().changeBlocker().stream() + .filter(blocker -> blocker.blocksRevisions()) + .filter(blocker -> blocker.window().includes(controller.clock().instant())) + .findAny().map(blocker -> blocker.window().toString()).get()); } else lastApplicationObject.setString("pending", "Waiting for current deployment to complete"); } - private static void deploymentToSlime(Cursor deploymentObject, Application application, Change change, + private static void deploymentToSlime(Cursor deploymentObject, Instance instance, Change change, Map<JobType, Versions> pendingProduction, Map<JobType, Run> running, JobType type, Deployment deployment) { deploymentObject.setLong("at", deployment.at().toEpochMilli()); deploymentObject.setString("platform", deployment.version().toString()); applicationVersionToSlime(deploymentObject.setObject("application"), deployment.applicationVersion()); - deploymentObject.setBool("verified", application.deploymentJobs().statusOf(type) - .flatMap(JobStatus::lastSuccess) - .filter(run -> run.platform().equals(deployment.version()) + deploymentObject.setBool("verified", instance.deploymentJobs().statusOf(type) + .flatMap(JobStatus::lastSuccess) + .filter(run -> run.platform().equals(deployment.version()) && run.application().equals(deployment.applicationVersion())) - .isPresent()); + .isPresent()); if (running.containsKey(type)) deploymentObject.setString("status", running.get(type).steps().get(deployReal) == unfinished ? "deploying" : "verifying"); else if (change.hasTargets()) deploymentObject.setString("status", pendingProduction.containsKey(type) ? "pending" : "completed"); } - private static void jobTypeToSlime(Cursor jobObject, Controller controller, Application application, JobType type, DeploymentSteps steps, + private static void jobTypeToSlime(Cursor jobObject, Controller controller, Instance instance, JobType type, DeploymentSteps steps, Map<JobType, Versions> pendingProduction, Map<JobType, Run> running, URI baseUriForJob) { - application.deploymentJobs().statusOf(type).ifPresent(status -> status.pausedUntil().ifPresent(until -> + instance.deploymentJobs().statusOf(type).ifPresent(status -> status.pausedUntil().ifPresent(until -> jobObject.setLong("pausedUntil", until))); int runs = 0; Cursor runArray = jobObject.setArray("runs"); if (type.isTest()) { Deque<List<JobType>> pending = new ArrayDeque<>(); pendingProduction.entrySet().stream() - .filter(typeVersions -> ! controller.applications().deploymentTrigger().testedIn(application, type, typeVersions.getValue())) - .filter(typeVersions -> ! controller.applications().deploymentTrigger().alreadyTriggered(application, typeVersions.getValue())) + .filter(typeVersions -> ! controller.applications().deploymentTrigger().testedIn(instance, type, typeVersions.getValue())) + .filter(typeVersions -> ! controller.applications().deploymentTrigger().alreadyTriggered(instance, typeVersions.getValue())) .collect(groupingBy(Map.Entry::getValue, LinkedHashMap::new, Collectors.mapping(Map.Entry::getKey, toList()))) .forEach((versions, types) -> pending.addFirst(types)); for (List<JobType> productionTypes : pending) { Versions versions = pendingProduction.get(productionTypes.get(0)); - if (statusOf(controller, application.id(), type, versions).equals("running")) + if (statusOf(controller, instance.id(), type, versions).equals("running")) continue; runs++; Cursor runObject = runArray.addObject(); runObject.setString("status", "pending"); versionsToSlime(runObject, versions); - if ( ! controller.applications().deploymentTrigger().triggerAt(controller.clock().instant(), type, versions, application)) + if ( ! controller.applications().deploymentTrigger().triggerAt(controller.clock().instant(), type, versions, instance)) runObject.setObject("tasks").setString("cooldown", "failed"); else runObject.setObject("tasks").setString("capacity", "running"); @@ -260,20 +260,20 @@ class JobControllerApiHandlerHelper { runObject.setString("status", "pending"); versionsToSlime(runObject, pendingProduction.get(type)); Cursor pendingObject = runObject.setObject("tasks"); - if (application.deploymentJobs().statusOf(type).map(status -> status.pausedUntil().isPresent()).orElse(false)) + if (instance.deploymentJobs().statusOf(type).map(status -> status.pausedUntil().isPresent()).orElse(false)) pendingObject.setString("paused", "pending"); - else if ( ! controller.applications().deploymentTrigger().triggerAt(controller.clock().instant(), type, versions, application)) + else if ( ! controller.applications().deploymentTrigger().triggerAt(controller.clock().instant(), type, versions, instance)) pendingObject.setString("cooldown", "failed"); else { int pending = 0; - if ( ! controller.applications().deploymentTrigger().alreadyTriggered(application, versions)) { - if ( ! controller.applications().deploymentTrigger().testedIn(application, systemTest, versions)) { + if ( ! controller.applications().deploymentTrigger().alreadyTriggered(instance, versions)) { + if ( ! controller.applications().deploymentTrigger().testedIn(instance, systemTest, versions)) { pending++; - pendingObject.setString(shortNameOf(systemTest, controller.system()), statusOf(controller, application.id(), systemTest, versions)); + pendingObject.setString(shortNameOf(systemTest, controller.system()), statusOf(controller, instance.id(), systemTest, versions)); } - if ( ! controller.applications().deploymentTrigger().testedIn(application, stagingTest, versions)) { + if ( ! controller.applications().deploymentTrigger().testedIn(instance, stagingTest, versions)) { pending++; - pendingObject.setString(shortNameOf(stagingTest, controller.system()), statusOf(controller, application.id(), stagingTest, versions)); + pendingObject.setString(shortNameOf(stagingTest, controller.system()), statusOf(controller, instance.id(), stagingTest, versions)); } } steps: for (DeploymentSpec.Step step : steps.production()) { @@ -281,11 +281,11 @@ class JobControllerApiHandlerHelper { break; for (JobType stepType : steps.toJobs(step)) { if (pendingProduction.containsKey(stepType)) { - Versions jobVersions = Versions.from(application.change(), - application, - Optional.ofNullable(application.deployments().get(stepType.zone(controller.system()))), + Versions jobVersions = Versions.from(instance.change(), + instance, + Optional.ofNullable(instance.deployments().get(stepType.zone(controller.system()))), controller.systemVersion()); - pendingObject.setString(shortNameOf(stepType, controller.system()), statusOf(controller, application.id(), stepType, jobVersions)); + pendingObject.setString(shortNameOf(stepType, controller.system()), statusOf(controller, instance.id(), stepType, jobVersions)); if (++pending == 3) break steps; } @@ -296,7 +296,7 @@ class JobControllerApiHandlerHelper { } } - controller.jobController().runs(application.id(), type).values().stream() + controller.jobController().runs(instance.id(), type).values().stream() .sorted(Comparator.comparing(run -> -run.id().number())) .limit(Math.max(0, 10 - runs)) .forEach(run -> runToSlime(runArray.addObject(), run, baseUriForJob)); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java index 44b67a186b8..3eb57875dad 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java @@ -11,7 +11,7 @@ import com.yahoo.container.jdisc.LoggingRequestHandler; import com.yahoo.restapi.Path; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.application.JobList; import com.yahoo.vespa.hosted.controller.application.JobStatus; @@ -132,15 +132,15 @@ public class DeploymentApiHandler extends LoggingRequestHandler { return new SlimeJsonResponse(slime); } - private void toSlime(Cursor object, Application application, HttpRequest request) { - object.setString("tenant", application.id().tenant().value()); - object.setString("application", application.id().application().value()); - object.setString("instance", application.id().instance().value()); + private void toSlime(Cursor object, Instance instance, HttpRequest request) { + object.setString("tenant", instance.id().tenant().value()); + object.setString("application", instance.id().application().value()); + object.setString("instance", instance.id().instance().value()); object.setString("url", new Uri(request.getUri()).withPath("/application/v4/tenant/" + - application.id().tenant().value() + + instance.id().tenant().value() + "/application/" + - application.id().application().value()).toString()); - object.setString("upgradePolicy", toString(application.deploymentSpec().upgradePolicy())); + instance.id().application().value()).toString()); + object.setString("upgradePolicy", toString(instance.deploymentSpec().upgradePolicy())); } private static String toString(DeploymentSpec.UpgradePolicy upgradePolicy) { @@ -153,8 +153,8 @@ public class DeploymentApiHandler extends LoggingRequestHandler { // ----------------------------- Utilities to pick out the relevant JobStatus -- filter chains should mirror the ones in VersionStatus /** The first upgrade job to fail on this version, for this application */ - private Optional<JobStatus> firstFailingOn(Version version, Application application) { - return JobList.from(application) + private Optional<JobStatus> firstFailingOn(Version version, Instance instance) { + return JobList.from(instance) .failing() .not().failingApplicationChange() .not().failingBecause(outOfCapacity) @@ -164,23 +164,23 @@ public class DeploymentApiHandler extends LoggingRequestHandler { } /** The number of production jobs for this application */ - private int productionJobsFor(Application application) { - return JobList.from(application) + private int productionJobsFor(Instance instance) { + return JobList.from(instance) .production() .size(); } /** The number of production jobs with last success on the given version, for this application */ - private int productionSuccessesFor(Version version, Application application) { - return JobList.from(application) + private int productionSuccessesFor(Version version, Instance instance) { + return JobList.from(instance) .production() .lastSuccess().on(version) .size(); } /** The last triggered upgrade to this version, for this application */ - private Optional<JobStatus> lastDeployingTo(Version version, Application application) { - return JobList.from(application) + private Optional<JobStatus> lastDeployingTo(Version version, Instance instance) { + return JobList.from(instance) .upgrading() .lastTriggered().on(version) .asList().stream() diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/SignatureFilter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/SignatureFilter.java index 1eb57f57402..9d7fa68807e 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/SignatureFilter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/SignatureFilter.java @@ -7,14 +7,12 @@ import com.google.inject.Inject; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.TenantName; -import com.yahoo.jdisc.Response; import com.yahoo.jdisc.http.filter.DiscFilterRequest; import com.yahoo.jdisc.http.filter.security.base.JsonSecurityRequestFilterBase; import com.yahoo.log.LogLevel; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.role.Role; -import com.yahoo.vespa.hosted.controller.api.role.RoleDefinition; import com.yahoo.vespa.hosted.controller.api.role.SecurityContext; import com.yahoo.yolean.Exceptions; @@ -48,7 +46,7 @@ public class SignatureFilter extends JsonSecurityRequestFilterBase { try { ApplicationId id = ApplicationId.fromSerializedForm(request.getHeader("X-Key-Id")); boolean verified = controller.applications().get(id) - .flatMap(Application::pemDeployKey) + .flatMap(Instance::pemDeployKey) .map(key -> new RequestVerifier(key, controller.clock())) .map(verifier -> verifier.verify(Method.valueOf(request.getMethod()), request.getUri(), diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepository.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepository.java index 75044328d5f..988df9c6a66 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepository.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepository.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.Endpoint; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.application.AssignedRotation; import com.yahoo.vespa.hosted.controller.application.EndpointId; @@ -55,11 +55,11 @@ public class RotationRepository { } /** Get rotation for given application */ - public Optional<Rotation> getRotation(Application application) { - return application.rotations().stream() - .map(AssignedRotation::rotationId) - .map(allRotations::get) - .findFirst(); + public Optional<Rotation> getRotation(Instance instance) { + return instance.rotations().stream() + .map(AssignedRotation::rotationId) + .map(allRotations::get) + .findFirst(); } /** Get rotation for the given rotationId */ @@ -73,23 +73,23 @@ public class RotationRepository { * If a rotation is already assigned to the application, that rotation will be returned. * If no rotation is assigned, return an available rotation. The caller is responsible for assigning the rotation. * - * @param application The application requesting a rotation + * @param instance The application requesting a rotation * @param lock Lock which must be acquired by the caller */ - public Rotation getOrAssignRotation(Application application, RotationLock lock) { - if (! application.rotations().isEmpty()) { - return allRotations.get(application.rotations().get(0).rotationId()); + public Rotation getOrAssignRotation(Instance instance, RotationLock lock) { + if (! instance.rotations().isEmpty()) { + return allRotations.get(instance.rotations().get(0).rotationId()); } - if (application.deploymentSpec().globalServiceId().isEmpty()) { + if (instance.deploymentSpec().globalServiceId().isEmpty()) { throw new IllegalArgumentException("global-service-id is not set in deployment spec"); } - long productionZones = application.deploymentSpec().zones().stream() - .filter(zone -> zone.deploysTo(Environment.prod)) - .count(); + long productionZones = instance.deploymentSpec().zones().stream() + .filter(zone -> zone.deploysTo(Environment.prod)) + .count(); if (productionZones < 2) { throw new IllegalArgumentException("global-service-id is set but less than 2 prod zones are defined"); } - return findAvailableRotation(application, lock); + return findAvailableRotation(instance, lock); } /** @@ -99,27 +99,27 @@ public class RotationRepository { * If rotations are not assigned, a new assignment will be created taking new rotations from the repository. * This method supports both global-service-id as well as the new endpoints tag. * - * @param application The application requesting rotations. + * @param instance The application requesting rotations. * @param lock Lock which by acquired by the caller * @return List of rotation assignments - either new or existing. */ - public List<AssignedRotation> getOrAssignRotations(Application application, RotationLock lock) { - if (application.deploymentSpec().globalServiceId().isPresent() && ! application.deploymentSpec().endpoints().isEmpty()) { + public List<AssignedRotation> getOrAssignRotations(Instance instance, RotationLock lock) { + if (instance.deploymentSpec().globalServiceId().isPresent() && ! instance.deploymentSpec().endpoints().isEmpty()) { throw new IllegalArgumentException("Cannot provision rotations with both global-service-id and 'endpoints'"); } // Support the older case of setting global-service-id - if (application.deploymentSpec().globalServiceId().isPresent()) { - final var regions = application.deploymentSpec().zones().stream() - .filter(zone -> zone.environment().isProduction()) - .flatMap(zone -> zone.region().stream()) - .collect(Collectors.toSet()); + if (instance.deploymentSpec().globalServiceId().isPresent()) { + final var regions = instance.deploymentSpec().zones().stream() + .filter(zone -> zone.environment().isProduction()) + .flatMap(zone -> zone.region().stream()) + .collect(Collectors.toSet()); - final var rotation = getOrAssignRotation(application, lock); + final var rotation = getOrAssignRotation(instance, lock); return List.of( new AssignedRotation( - new ClusterSpec.Id(application.deploymentSpec().globalServiceId().get()), + new ClusterSpec.Id(instance.deploymentSpec().globalServiceId().get()), EndpointId.default_(), rotation.id(), regions @@ -127,20 +127,20 @@ public class RotationRepository { ); } - final Map<EndpointId, AssignedRotation> existingAssignments = existingEndpointAssignments(application); - final Map<EndpointId, AssignedRotation> updatedAssignments = assignRotationsToEndpoints(application, existingAssignments, lock); + final Map<EndpointId, AssignedRotation> existingAssignments = existingEndpointAssignments(instance); + final Map<EndpointId, AssignedRotation> updatedAssignments = assignRotationsToEndpoints(instance, existingAssignments, lock); existingAssignments.putAll(updatedAssignments); return List.copyOf(existingAssignments.values()); } - private Map<EndpointId, AssignedRotation> assignRotationsToEndpoints(Application application, Map<EndpointId, AssignedRotation> existingAssignments, RotationLock lock) { + private Map<EndpointId, AssignedRotation> assignRotationsToEndpoints(Instance instance, Map<EndpointId, AssignedRotation> existingAssignments, RotationLock lock) { final var availableRotations = new ArrayList<>(availableRotations(lock).values()); - final var neededRotations = application.deploymentSpec().endpoints().stream() - .filter(Predicate.not(endpoint -> existingAssignments.containsKey(EndpointId.of(endpoint.endpointId())))) - .collect(Collectors.toSet()); + final var neededRotations = instance.deploymentSpec().endpoints().stream() + .filter(Predicate.not(endpoint -> existingAssignments.containsKey(EndpointId.of(endpoint.endpointId())))) + .collect(Collectors.toSet()); if (neededRotations.size() > availableRotations.size()) { throw new IllegalStateException("Hosted Vespa ran out of rotations, unable to assign rotation: need " + neededRotations.size() + ", have " + availableRotations.size()); @@ -165,17 +165,17 @@ public class RotationRepository { ); } - private Map<EndpointId, AssignedRotation> existingEndpointAssignments(Application application) { + private Map<EndpointId, AssignedRotation> existingEndpointAssignments(Instance instance) { // // Get the regions that has been configured for an endpoint. Empty set if the endpoint // is no longer mentioned in the configuration file. // final Function<EndpointId, Set<RegionName>> configuredRegionsForEndpoint = endpointId -> { - return application.deploymentSpec().endpoints().stream() - .filter(endpoint -> endpointId.id().equals(endpoint.endpointId())) - .map(Endpoint::regions) - .findFirst() - .orElse(Set.of()); + return instance.deploymentSpec().endpoints().stream() + .filter(endpoint -> endpointId.id().equals(endpoint.endpointId())) + .map(Endpoint::regions) + .findFirst() + .orElse(Set.of()); }; // @@ -191,8 +191,8 @@ public class RotationRepository { ); }; - return application.rotations().stream() - .collect( + return instance.rotations().stream() + .collect( Collectors.toMap( AssignedRotation::endpointId, assignedRotationWithConfiguredRegions, @@ -219,15 +219,15 @@ public class RotationRepository { return Collections.unmodifiableMap(unassignedRotations); } - private Rotation findAvailableRotation(Application application, RotationLock lock) { + private Rotation findAvailableRotation(Instance instance, RotationLock lock) { Map<RotationId, Rotation> availableRotations = availableRotations(lock); if (availableRotations.isEmpty()) { - throw new IllegalStateException("Unable to assign global rotation to " + application.id() + throw new IllegalStateException("Unable to assign global rotation to " + instance.id() + " - no rotations available"); } // Return first available rotation RotationId rotation = availableRotations.keySet().iterator().next(); - log.info(String.format("Offering %s to application %s", rotation, application.id())); + log.info(String.format("Offering %s to application %s", rotation, instance.id())); return allRotations.get(rotation); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/AccessControl.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/AccessControl.java index 77ccce873fe..6ed32feae28 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/AccessControl.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/AccessControl.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.security; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.tenant.Tenant; import java.util.List; @@ -33,10 +33,10 @@ public interface AccessControl { * @param tenantSpec specification for the tenant to update * @param credentials the credentials for the entity requesting the update * @param existing list of existing tenants, to check for conflicts - * @param applications list of applications this tenant already owns + * @param instances list of applications this tenant already owns * @return the updated tenant, for keeping */ - Tenant updateTenant(TenantSpec tenantSpec, Credentials credentials, List<Tenant> existing, List<Application> applications); + Tenant updateTenant(TenantSpec tenantSpec, Credentials credentials, List<Tenant> existing, List<Instance> instances); /** * Deletes access control for the given tenant. diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/CloudAccessControl.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/CloudAccessControl.java index 8c52931cd6c..b53388d7aa6 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/CloudAccessControl.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/security/CloudAccessControl.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.security; import com.google.inject.Inject; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.organization.BillingInfo; import com.yahoo.vespa.hosted.controller.api.integration.user.Roles; import com.yahoo.vespa.hosted.controller.api.integration.user.UserId; @@ -44,7 +44,7 @@ public class CloudAccessControl implements AccessControl { } @Override - public Tenant updateTenant(TenantSpec tenantSpec, Credentials credentials, List<Tenant> existing, List<Application> applications) { + public Tenant updateTenant(TenantSpec tenantSpec, Credentials credentials, List<Tenant> existing, List<Instance> instances) { throw new UnsupportedOperationException("Update is not supported here, as it would entail changing the tenant name."); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java index 87ae2538ad6..17926f18b5c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java @@ -8,7 +8,7 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.log.LogLevel; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.application.ApplicationList; @@ -189,50 +189,50 @@ public class VersionStatus { } private static Collection<DeploymentStatistics> computeDeploymentStatistics(Set<Version> infrastructureVersions, - List<Application> applications) { + List<Instance> instances) { Map<Version, DeploymentStatistics> versionMap = new HashMap<>(); for (Version infrastructureVersion : infrastructureVersions) { versionMap.put(infrastructureVersion, DeploymentStatistics.empty(infrastructureVersion)); } - ApplicationList applicationList = ApplicationList.from(applications) + ApplicationList applicationList = ApplicationList.from(instances) .hasProductionDeployment(); - for (Application application : applicationList.asList()) { + for (Instance instance : applicationList.asList()) { // Note that each version deployed on this application in production exists // (ignore non-production versions) - for (Deployment deployment : application.productionDeployments().values()) { + for (Deployment deployment : instance.productionDeployments().values()) { versionMap.computeIfAbsent(deployment.version(), DeploymentStatistics::empty); } // List versions which have failing jobs, versions which are in production, and versions for which there are running deployment jobs // Failing versions - JobList.from(application) + JobList.from(instance) .failing() .not().failingApplicationChange() .not().failingBecause(outOfCapacity) .mapToList(job -> job.lastCompleted().get().platform()) .forEach(version -> versionMap .put(version, versionMap.getOrDefault(version, DeploymentStatistics.empty(version)) - .withFailing(application.id()))); + .withFailing(instance.id()))); // Succeeding versions - JobList.from(application) + JobList.from(instance) .lastSuccess().present() .production() .mapToList(job -> job.lastSuccess().get().platform()) .forEach(version -> versionMap .put(version, versionMap.getOrDefault(version, DeploymentStatistics.empty(version)) - .withProduction(application.id()))); + .withProduction(instance.id()))); // Deploying versions - JobList.from(application) + JobList.from(instance) .upgrading() .mapToList(job -> job.lastTriggered().get().platform()) .forEach(version -> versionMap .put(version, versionMap.getOrDefault(version, DeploymentStatistics.empty(version)) - .withDeploying(application.id()))); + .withDeploying(instance.id()))); } return versionMap.values(); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index d1b8fc183d2..b427ebb730e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -82,7 +82,7 @@ public class ControllerTest { // staging job - succeeding Version version1 = tester.defaultPlatformVersion(); - Application app1 = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app1).uploadArtifact(applicationPackage).submit(); assertEquals("Application version is known from completion of initial job", ApplicationVersion.from(BuildJob.defaultSourceRevision, BuildJob.defaultBuildNumber), @@ -211,7 +211,7 @@ public class ControllerTest { @Test public void testDeploymentApplicationVersion() { - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -279,7 +279,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistration() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -288,14 +288,14 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage); - Collection<Deployment> deployments = tester.application(application.id()).deployments().values(); + tester.deployCompletely(instance, applicationPackage); + Collection<Deployment> deployments = tester.application(instance.id()).deployments().values(); assertFalse(deployments.isEmpty()); for (Deployment deployment : deployments) { assertEquals("Rotation names are passed to config server in " + deployment.zone(), Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), deployment.zone()))); + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), deployment.zone()))); } tester.flushDnsRequests(); @@ -309,7 +309,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistrationLegacy() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -318,8 +318,8 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage); - Collection<Deployment> deployments = tester.application(application.id()).deployments().values(); + tester.deployCompletely(instance, applicationPackage); + Collection<Deployment> deployments = tester.application(instance.id()).deployments().values(); assertFalse(deployments.isEmpty()); for (Deployment deployment : deployments) { assertEquals("Rotation names are passed to config server in " + deployment.zone(), @@ -327,7 +327,7 @@ public class ControllerTest { "app1--tenant1.global.vespa.oath.cloud", "app1.tenant1.global.vespa.yahooapis.com", "app1--tenant1.global.vespa.yahooapis.com"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), deployment.zone()))); + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), deployment.zone()))); } tester.flushDnsRequests(); assertEquals(3, tester.controllerTester().nameService().records().size()); @@ -350,7 +350,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistrationWithEndpoints() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -362,8 +362,8 @@ public class ControllerTest { .region("us-central-1") .build(); - tester.deployCompletely(application, applicationPackage); - Collection<Deployment> deployments = tester.application(application.id()).deployments().values(); + tester.deployCompletely(instance, applicationPackage); + Collection<Deployment> deployments = tester.application(instance.id()).deployments().values(); assertFalse(deployments.isEmpty()); var notWest = Set.of( @@ -376,7 +376,7 @@ public class ControllerTest { for (Deployment deployment : deployments) { assertEquals("Rotation names are passed to config server in " + deployment.zone(), ZoneId.from("prod.us-west-1").equals(deployment.zone()) ? west : notWest, - tester.configServer().rotationNames().get(new DeploymentId(application.id(), deployment.zone()))); + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), deployment.zone()))); } tester.flushDnsRequests(); @@ -405,7 +405,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistrationWithChangingZones() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -414,16 +414,16 @@ public class ControllerTest { .region("us-central-1") .build(); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); assertEquals( Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1"))) ); assertEquals( Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-central-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-central-1"))) ); @@ -434,24 +434,24 @@ public class ControllerTest { .region("us-central-1") .build(); - tester.deployCompletely(application, applicationPackage2, BuildJob.defaultBuildNumber + 1); + tester.deployCompletely(instance, applicationPackage2, BuildJob.defaultBuildNumber + 1); assertEquals( Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1"))) ); assertEquals( Set.of(), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-central-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-central-1"))) ); - assertEquals(Set.of(RegionName.from("us-west-1")), tester.application(application.id()).rotations().get(0).regions()); + assertEquals(Set.of(RegionName.from("us-west-1")), tester.application(instance.id()).rotations().get(0).regions()); } @Test public void testUnassignRotations() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -460,7 +460,7 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); ApplicationPackage applicationPackage2 = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -468,17 +468,17 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage2, BuildJob.defaultBuildNumber + 1); + tester.deployCompletely(instance, applicationPackage2, BuildJob.defaultBuildNumber + 1); assertEquals( List.of(AssignedRotation.fromStrings("qrs", "default", "rotation-id-01", Set.of())), - tester.application(application.id()).rotations() + tester.application(instance.id()).rotations() ); assertEquals( Set.of(), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1"))) ); } @@ -486,7 +486,7 @@ public class ControllerTest { public void testUpdatesExistingDnsAlias() { // Application 1 is deployed and deleted { - Application app1 = tester.createApplication("app1", "tenant1", 1, 1L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .endpoint("default", "foo") @@ -532,7 +532,7 @@ public class ControllerTest { // Application 2 is deployed and assigned same rotation as application 1 had before deletion { - Application app2 = tester.createApplication("app2", "tenant2", 2, 1L); + Instance app2 = tester.createApplication("app2", "tenant2", 2, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .endpoint("default", "foo") @@ -551,7 +551,7 @@ public class ControllerTest { // Application 1 is recreated, deployed and assigned a new rotation { tester.buildService().clear(); - Application app1 = tester.createApplication("app1", "tenant1", 1, 1L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .endpoint("default", "foo") @@ -589,7 +589,7 @@ public class ControllerTest { .build(); // Create application - Application app = tester.createApplication("app1", "tenant1", 1, 2L); + Instance app = tester.createApplication("app1", "tenant1", 1, 2L); // Direct deploy is allowed when deployDirectly is true ZoneId zone = ZoneId.from("prod", "cd-us-central-1"); @@ -619,7 +619,7 @@ public class ControllerTest { .build(); // Create application - Application app = tester.createApplication("app1", "tenant1", 1, 2L); + Instance app = tester.createApplication("app1", "tenant1", 1, 2L); ZoneId zone = ZoneId.from("dev", "us-east-1"); // Deploy @@ -633,7 +633,7 @@ public class ControllerTest { @Test public void testSuspension() { - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -657,7 +657,7 @@ public class ControllerTest { // second time will not fail @Test public void testDeletingApplicationThatHasAlreadyBeenDeleted() { - Application app = tester.createApplication("app2", "tenant1", 1, 12L); + Instance app = tester.createApplication("app2", "tenant1", 1, 12L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-east-3") @@ -672,33 +672,33 @@ public class ControllerTest { @Test public void testDeployApplicationPackageWithApplicationDir() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") .build(true); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); } @Test public void testDeployApplicationWithWarnings() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") .build(); ZoneId zone = ZoneId.from("prod", "us-west-1"); int warnings = 3; - tester.configServer().generateWarnings(new DeploymentId(application.id(), zone), warnings); - tester.deployCompletely(application, applicationPackage); - assertEquals(warnings, tester.applications().require(application.id()).deployments().get(zone) + tester.configServer().generateWarnings(new DeploymentId(instance.id(), zone), warnings); + tester.deployCompletely(instance, applicationPackage); + assertEquals(warnings, tester.applications().require(instance.id()).deployments().get(zone) .metrics().warnings().get(DeploymentMetrics.Warning.all).intValue()); } @Test public void testDeploySelectivelyProvisionsCertificate() { ((InMemoryFlagSource) tester.controller().flagSource()).withBooleanFlag(Flags.PROVISION_APPLICATION_CERTIFICATE.id(), true); - Function<Application, Optional<ApplicationCertificate>> certificate = (application) -> tester.controller().curator().readApplicationCertificate(application.id()); + Function<Instance, Optional<ApplicationCertificate>> certificate = (application) -> tester.controller().curator().readApplicationCertificate(application.id()); // Create app1 var app1 = tester.createApplication("app1", "tenant1", 1, 2L); @@ -780,7 +780,7 @@ public class ControllerTest { private void runDeployment(DeploymentTester tester, ApplicationId application, ApplicationVersion version, ApplicationPackage applicationPackage, SourceRevision sourceRevision, long buildNumber) { - Application app = tester.applications().require(application); + Instance app = tester.applications().require(application); tester.jobCompletion(component) .application(app) .buildNumber(buildNumber) @@ -796,13 +796,13 @@ public class ControllerTest { } private void assertStatus(JobStatus expectedStatus, ApplicationId id, Controller controller) { - Application app = controller.applications().get(id).get(); + Instance app = controller.applications().get(id).get(); JobStatus existingStatus = app.deploymentJobs().jobStatus().get(expectedStatus.type()); assertNotNull("Status of type " + expectedStatus.type() + " is present", existingStatus); assertEquals(expectedStatus, existingStatus); } - private void runDeployment(DeploymentTester tester, Application app, ApplicationVersion version, + private void runDeployment(DeploymentTester tester, Instance app, ApplicationVersion version, Optional<Version> upgrade, Optional<ApplicationPackage> applicationPackage) { Version vespaVersion = upgrade.orElseGet(tester::defaultPlatformVersion); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java index a4e07bd74e8..52a8f5f5e27 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java @@ -126,8 +126,8 @@ public final class ControllerTester { .ifPresent(configureFunc); } - public static BuildService.BuildJob buildJob(Application application, JobType jobType) { - return BuildService.BuildJob.of(application.id(), application.deploymentJobs().projectId().getAsLong(), jobType.jobName()); + public static BuildService.BuildJob buildJob(Instance instance, JobType jobType) { + return BuildService.BuildJob.of(instance.id(), instance.deploymentJobs().projectId().getAsLong(), jobType.jobName()); } public Controller controller() { return controller; } @@ -157,37 +157,37 @@ public final class ControllerTester { } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId, Long propertyId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId, Long propertyId) { return createAndDeploy(tenantName, domainName, applicationName, toZone(environment), projectId, propertyId); } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, - String instanceName, ZoneId zone, long projectId, Long propertyId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, + String instanceName, ZoneId zone, long projectId, Long propertyId) { TenantName tenant = createTenant(tenantName, domainName, propertyId); - Application application = createApplication(tenant, applicationName, instanceName, projectId); - deploy(application, zone); - return application; + Instance instance = createApplication(tenant, applicationName, instanceName, projectId); + deploy(instance, zone); + return instance; } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, ZoneId zone, long projectId, Long propertyId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, ZoneId zone, long projectId, Long propertyId) { return createAndDeploy(tenantName, domainName, applicationName, "default", zone, projectId, propertyId); } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId) { return createAndDeploy(tenantName, domainName, applicationName, environment, projectId, null); } /** Create application from slime */ - public Application createApplication(Slime slime) { + public Instance createApplication(Slime slime) { ApplicationSerializer serializer = new ApplicationSerializer(); - Application application = serializer.fromSlime(slime); - try (Lock lock = controller().applications().lock(application.id())) { - controller().applications().store(new LockedApplication(application, lock)); + Instance instance = serializer.fromSlime(slime); + try (Lock lock = controller().applications().lock(instance.id())) { + controller().applications().store(new LockedApplication(instance, lock)); } - return application; + return instance; } public ZoneId toZone(Environment environment) { @@ -241,7 +241,7 @@ public final class ControllerTester { new OktaAccessToken("okta-token"))); } - public Application createApplication(TenantName tenant, String applicationName, String instanceName, long projectId) { + public Instance createApplication(TenantName tenant, String applicationName, String instanceName, long projectId) { ApplicationId applicationId = ApplicationId.from(tenant.value(), applicationName, instanceName); controller().applications().createApplication(applicationId, credentialsFor(applicationId)); controller().applications().lockOrThrow(applicationId, lockedApplication -> @@ -249,36 +249,36 @@ public final class ControllerTester { return controller().applications().require(applicationId); } - public void deploy(Application application, ZoneId zone) { - deploy(application, zone, new ApplicationPackage(new byte[0])); + public void deploy(Instance instance, ZoneId zone) { + deploy(instance, zone, new ApplicationPackage(new byte[0])); } - public void deploy(Application application, ZoneId zone, ApplicationPackage applicationPackage) { - deploy(application, zone, applicationPackage, false); + public void deploy(Instance instance, ZoneId zone, ApplicationPackage applicationPackage) { + deploy(instance, zone, applicationPackage, false); } - public void deploy(Application application, ZoneId zone, ApplicationPackage applicationPackage, boolean deployCurrentVersion) { - deploy(application, zone, Optional.of(applicationPackage), deployCurrentVersion); + public void deploy(Instance instance, ZoneId zone, ApplicationPackage applicationPackage, boolean deployCurrentVersion) { + deploy(instance, zone, Optional.of(applicationPackage), deployCurrentVersion); } - public void deploy(Application application, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) { - deploy(application, zone, applicationPackage, deployCurrentVersion, Optional.empty()); + public void deploy(Instance instance, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) { + deploy(instance, zone, applicationPackage, deployCurrentVersion, Optional.empty()); } - public void deploy(Application application, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion, Optional<Version> version) { - controller().applications().deploy(application.id(), + public void deploy(Instance instance, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion, Optional<Version> version) { + controller().applications().deploy(instance.id(), zone, applicationPackage, new DeployOptions(false, version, false, deployCurrentVersion)); } - public Supplier<Application> application(ApplicationId application) { + public Supplier<Instance> application(ApplicationId application) { return () -> controller().applications().require(application); } /** Used by ApplicationSerializerTest to avoid breaking encapsulation. Should not be used by anything else */ - public static LockedApplication writable(Application application) { - return new LockedApplication(application, new Lock("/test", new MockCurator())); + public static LockedApplication writable(Instance instance) { + return new LockedApplication(instance, new Lock("/test", new MockCurator())); } private static Controller createController(CuratorDb curator, RotationsConfig rotationsConfig, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java index afe4a1dba1f..7b2aba296a4 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; @@ -51,10 +51,10 @@ public class BuildJob { return this; } - public BuildJob application(Application application) { - this.applicationId = application.id(); - if (application.deploymentJobs().projectId().isPresent()) { - this.projectId = application.deploymentJobs().projectId().getAsLong(); + public BuildJob application(Instance instance) { + this.applicationId = instance.id(); + if (instance.deploymentJobs().projectId().isPresent()) { + this.projectId = instance.deploymentJobs().projectId().getAsLong(); } return this; } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java index cc5e22d775b..02b45b77769 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java @@ -7,7 +7,7 @@ import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.test.ManualClock; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.ControllerTester; @@ -112,11 +112,11 @@ public class DeploymentTester { public ConfigServerMock configServer() { return tester.serviceRegistry().configServerMock(); } - public Application application(String name) { + public Instance application(String name) { return application(ApplicationId.from("tenant1", name, "default")); } - public Application application(ApplicationId application) { + public Instance application(ApplicationId application) { return controller().applications().require(application); } @@ -169,11 +169,11 @@ public class DeploymentTester { return configServer().initialVersion(); } - public Application createApplication(String applicationName, String tenantName, long projectId, long propertyId) { + public Instance createApplication(String applicationName, String tenantName, long projectId, long propertyId) { return createApplication("default", applicationName, tenantName, projectId, propertyId); } - public Application createApplication(String instanceName, String applicationName, String tenantName, long projectId, long propertyId) { + public Instance createApplication(String instanceName, String applicationName, String tenantName, long projectId, long propertyId) { TenantName tenant = tester.createTenant(tenantName, UUID.randomUUID().toString(), propertyId); return tester.createApplication(tenant, applicationName, instanceName, projectId); } @@ -191,134 +191,134 @@ public class DeploymentTester { } /** Simulate the full lifecycle of an application deployment as declared in given application package */ - public Application createAndDeploy(String applicationName, int projectId, ApplicationPackage applicationPackage) { + public Instance createAndDeploy(String applicationName, int projectId, ApplicationPackage applicationPackage) { TenantName tenant = tester.createTenant("tenant1", "domain1", 1L); return createAndDeploy(tenant, applicationName, projectId, applicationPackage); } /** Simulate the full lifecycle of an application deployment as declared in given application package */ - public Application createAndDeploy(TenantName tenant, String applicationName, int projectId, ApplicationPackage applicationPackage) { - Application application = tester.createApplication(tenant, applicationName, "default", projectId); - deployCompletely(application, applicationPackage); - return applications().require(application.id()); + public Instance createAndDeploy(TenantName tenant, String applicationName, int projectId, ApplicationPackage applicationPackage) { + Instance instance = tester.createApplication(tenant, applicationName, "default", projectId); + deployCompletely(instance, applicationPackage); + return applications().require(instance.id()); } /** Simulate the full lifecycle of an application deployment to prod.us-west-1 with the given upgrade policy */ - public Application createAndDeploy(String applicationName, int projectId, String upgradePolicy) { + public Instance createAndDeploy(String applicationName, int projectId, String upgradePolicy) { return createAndDeploy(applicationName, projectId, applicationPackage(upgradePolicy)); } /** Simulate the full lifecycle of an application deployment to prod.us-west-1 with the given upgrade policy */ - public Application createAndDeploy(TenantName tenant, String applicationName, int projectId, String upgradePolicy) { + public Instance createAndDeploy(TenantName tenant, String applicationName, int projectId, String upgradePolicy) { return createAndDeploy(tenant, applicationName, projectId, applicationPackage(upgradePolicy)); } /** Deploy application completely using the given application package */ - public void deployCompletely(Application application, ApplicationPackage applicationPackage) { - deployCompletely(application, applicationPackage, BuildJob.defaultBuildNumber); + public void deployCompletely(Instance instance, ApplicationPackage applicationPackage) { + deployCompletely(instance, applicationPackage, BuildJob.defaultBuildNumber); } - public void completeDeploymentWithError(Application application, ApplicationPackage applicationPackage, long buildNumber, JobType failOnJob) { - jobCompletion(JobType.component).application(application) + public void completeDeploymentWithError(Instance instance, ApplicationPackage applicationPackage, long buildNumber, JobType failOnJob) { + jobCompletion(JobType.component).application(instance) .buildNumber(buildNumber) .uploadArtifact(applicationPackage) .submit(); - completeDeployment(application, applicationPackage, Optional.ofNullable(failOnJob)); + completeDeployment(instance, applicationPackage, Optional.ofNullable(failOnJob)); } - public void deployCompletely(Application application, ApplicationPackage applicationPackage, long buildNumber) { - completeDeploymentWithError(application, applicationPackage, buildNumber, null); + public void deployCompletely(Instance instance, ApplicationPackage applicationPackage, long buildNumber) { + completeDeploymentWithError(instance, applicationPackage, buildNumber, null); } - private void completeDeployment(Application application, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { - assertTrue(application.id() + " has pending changes to deploy", applications().require(application.id()).change().hasTargets()); + private void completeDeployment(Instance instance, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { + assertTrue(instance.id() + " has pending changes to deploy", applications().require(instance.id()).change().hasTargets()); DeploymentSteps steps = controller().applications().deploymentTrigger().steps(applicationPackage.deploymentSpec()); List<JobType> jobs = steps.jobs(); for (JobType job : jobs) { boolean failJob = failOnJob.map(j -> j.equals(job)).orElse(false); - deployAndNotify(application, applicationPackage, ! failJob, job); + deployAndNotify(instance, applicationPackage, ! failJob, job); if (failJob) { break; } } if (failOnJob.isPresent()) { - assertTrue(applications().require(application.id()).change().hasTargets()); - assertTrue(applications().require(application.id()).deploymentJobs().hasFailures()); + assertTrue(applications().require(instance.id()).change().hasTargets()); + assertTrue(applications().require(instance.id()).deploymentJobs().hasFailures()); } else { - assertFalse(applications().require(application.id()).change().hasTargets()); + assertFalse(applications().require(instance.id()).change().hasTargets()); } if (updateDnsAutomatically) { flushDnsRequests(); } } - public void completeUpgrade(Application application, Version version, String upgradePolicy) { - completeUpgrade(application, version, applicationPackage(upgradePolicy)); + public void completeUpgrade(Instance instance, Version version, String upgradePolicy) { + completeUpgrade(instance, version, applicationPackage(upgradePolicy)); } - public void completeUpgrade(Application application, Version version, ApplicationPackage applicationPackage) { - assertTrue(application + " has a change", applications().require(application.id()).change().hasTargets()); - assertEquals(Change.of(version), applications().require(application.id()).change()); - completeDeployment(application, applicationPackage, Optional.empty()); + public void completeUpgrade(Instance instance, Version version, ApplicationPackage applicationPackage) { + assertTrue(instance + " has a change", applications().require(instance.id()).change().hasTargets()); + assertEquals(Change.of(version), applications().require(instance.id()).change()); + completeDeployment(instance, applicationPackage, Optional.empty()); } - public void completeUpgradeWithError(Application application, Version version, String upgradePolicy, JobType failOnJob) { - completeUpgradeWithError(application, version, applicationPackage(upgradePolicy), Optional.of(failOnJob)); + public void completeUpgradeWithError(Instance instance, Version version, String upgradePolicy, JobType failOnJob) { + completeUpgradeWithError(instance, version, applicationPackage(upgradePolicy), Optional.of(failOnJob)); } - public void completeUpgradeWithError(Application application, Version version, ApplicationPackage applicationPackage, JobType failOnJob) { - completeUpgradeWithError(application, version, applicationPackage, Optional.of(failOnJob)); + public void completeUpgradeWithError(Instance instance, Version version, ApplicationPackage applicationPackage, JobType failOnJob) { + completeUpgradeWithError(instance, version, applicationPackage, Optional.of(failOnJob)); } - private void completeUpgradeWithError(Application application, Version version, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { - assertTrue(applications().require(application.id()).change().hasTargets()); - assertEquals(Change.of(version), applications().require(application.id()).change()); - completeDeployment(application, applicationPackage, failOnJob); + private void completeUpgradeWithError(Instance instance, Version version, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { + assertTrue(applications().require(instance.id()).change().hasTargets()); + assertEquals(Change.of(version), applications().require(instance.id()).change()); + completeDeployment(instance, applicationPackage, failOnJob); } - public void deploy(JobType job, Application application, ApplicationPackage applicationPackage) { - deploy(job, application, Optional.of(applicationPackage), false); + public void deploy(JobType job, Instance instance, ApplicationPackage applicationPackage) { + deploy(job, instance, Optional.of(applicationPackage), false); } - public void deploy(JobType job, Application application, ApplicationPackage applicationPackage, + public void deploy(JobType job, Instance instance, ApplicationPackage applicationPackage, boolean deployCurrentVersion) { - deploy(job, application, Optional.of(applicationPackage), deployCurrentVersion); + deploy(job, instance, Optional.of(applicationPackage), deployCurrentVersion); } - public void deploy(JobType job, Application application, Optional<ApplicationPackage> applicationPackage, + public void deploy(JobType job, Instance instance, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) { - tester.deploy(application, job.zone(controller().system()), applicationPackage, deployCurrentVersion); + tester.deploy(instance, job.zone(controller().system()), applicationPackage, deployCurrentVersion); } - public void deployAndNotify(Application application, String upgradePolicy, boolean success, JobType job) { - deployAndNotify(application, applicationPackage(upgradePolicy), success, job); + public void deployAndNotify(Instance instance, String upgradePolicy, boolean success, JobType job) { + deployAndNotify(instance, applicationPackage(upgradePolicy), success, job); } - public void deployAndNotify(Application application, ApplicationPackage applicationPackage, boolean success, JobType job) { - deployAndNotify(application, Optional.of(applicationPackage), success, job); + public void deployAndNotify(Instance instance, ApplicationPackage applicationPackage, boolean success, JobType job) { + deployAndNotify(instance, Optional.of(applicationPackage), success, job); } - public void deployAndNotify(Application application, boolean success, JobType job) { - deployAndNotify(application, Optional.empty(), success, job); + public void deployAndNotify(Instance instance, boolean success, JobType job) { + deployAndNotify(instance, Optional.empty(), success, job); } - public void deployAndNotify(Application application, Optional<ApplicationPackage> applicationPackage, boolean success, JobType job) { + public void deployAndNotify(Instance instance, Optional<ApplicationPackage> applicationPackage, boolean success, JobType job) { if (success) { // Staging deploys twice, once with current version and once with new version if (job == JobType.stagingTest) { - deploy(job, application, applicationPackage, true); + deploy(job, instance, applicationPackage, true); } - deploy(job, application, applicationPackage, false); + deploy(job, instance, applicationPackage, false); } // Deactivate test deployments after deploy. This replicates the behaviour of the tenant pipeline if (job.isTest()) { - controller().applications().deactivate(application.id(), job.zone(controller().system())); + controller().applications().deactivate(instance.id(), job.zone(controller().system())); } - jobCompletion(job).application(application).success(success).submit(); + jobCompletion(job).application(instance).success(success).submit(); } - public Optional<JobStatus.JobRun> firstFailing(Application application, JobType job) { - return tester.controller().applications().require(application.id()) + public Optional<JobStatus.JobRun> firstFailing(Instance instance, JobType job) { + return tester.controller().applications().require(instance.id()) .deploymentJobs().jobStatus().get(job).firstFailing(); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java index f8e7026d9d5..7cb520f0fd9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java @@ -7,7 +7,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; @@ -68,7 +68,7 @@ public class DeploymentTriggerTest { @Test public void testTriggerFailing() { - Application app = tester.createApplication("app1", "tenant1", 1, 1L); + Instance app = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .upgradePolicy("default") .environment(Environment.prod) @@ -109,8 +109,8 @@ public class DeploymentTriggerTest { @Test public void testIndependentInstances() { - Application instance1 = tester.createApplication("instance1", "app", "tenant", 1, 1L); - Application instance2 = tester.createApplication("instance2", "app", "tenant", 2, 1L); + Instance instance1 = tester.createApplication("instance1", "app", "tenant", 1, 1L); + Instance instance2 = tester.createApplication("instance2", "app", "tenant", 2, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .upgradePolicy("default") .environment(Environment.prod) @@ -152,7 +152,7 @@ public class DeploymentTriggerTest { InternalDeploymentTester iTester = new InternalDeploymentTester(); DeploymentTester tester = iTester.tester(); - Application app = iTester.app(); + Instance app = iTester.app(); ApplicationPackage applicationPackage = InternalDeploymentTester.applicationPackage; tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); @@ -213,7 +213,7 @@ public class DeploymentTriggerTest { public void deploymentSpecDecidesTriggerOrder() { TenantName tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L); MockBuildService mockBuildService = tester.buildService(); - Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); + Instance instance = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-east-3") @@ -222,21 +222,21 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(applicationPackage).submit(); // Application is deployed to all test environments and declared zones - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsEast3); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsWest1); assertTrue("All jobs consumed", mockBuildService.jobs().isEmpty()); } @Test public void deploymentsSpecWithDelays() { MockBuildService mockBuildService = tester.buildService(); - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -249,11 +249,11 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(applicationPackage).submit(); // Test jobs pass - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); tester.deploymentTrigger().triggerReadyJobs(); // No jobs have started yet, as 30 seconds have not yet passed. @@ -263,16 +263,16 @@ public class DeploymentTriggerTest { // 30 seconds later, the first jobs may trigger. assertEquals(1, mockBuildService.jobs().size()); - tester.assertRunning(productionUsWest1, application.id()); + tester.assertRunning(productionUsWest1, instance.id()); // 3 minutes pass, delayed trigger does nothing as us-west-1 is still in progress tester.clock().advance(Duration.ofMinutes(3)); tester.deploymentTrigger().triggerReadyJobs(); assertEquals(1, mockBuildService.jobs().size()); - tester.assertRunning(productionUsWest1, application.id()); + tester.assertRunning(productionUsWest1, instance.id()); // us-west-1 completes - tester.deployAndNotify(application, applicationPackage, true, productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, productionUsWest1); // Delayed trigger does nothing as not enough time has passed after us-west-1 completion tester.deploymentTrigger().triggerReadyJobs(); @@ -286,7 +286,7 @@ public class DeploymentTriggerTest { // 4 minutes pass, us-central-1 is triggered tester.clock().advance(Duration.ofMinutes(1)); tester.deploymentTrigger().triggerReadyJobs(); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); assertTrue("All jobs consumed", mockBuildService.jobs().isEmpty()); // Delayed trigger job runs again, with nothing to trigger @@ -297,7 +297,7 @@ public class DeploymentTriggerTest { @Test public void deploymentSpecWithParallelDeployments() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -307,75 +307,75 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(applicationPackage).submit(); // Test jobs pass - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); // Deploys in first region assertEquals(1, tester.buildService().jobs().size()); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); // Deploys in two regions in parallel assertEquals(2, tester.buildService().jobs().size()); - tester.assertRunning(productionUsEast3, application.id()); - tester.assertRunning(productionUsWest1, application.id()); + tester.assertRunning(productionUsEast3, instance.id()); + tester.assertRunning(productionUsWest1, instance.id()); - tester.deploy(JobType.productionUsWest1, application, applicationPackage, false); - tester.jobCompletion(JobType.productionUsWest1).application(application).submit(); + tester.deploy(JobType.productionUsWest1, instance, applicationPackage, false); + tester.jobCompletion(JobType.productionUsWest1).application(instance).submit(); assertEquals("One job still running.", JobType.productionUsEast3.jobName(), tester.buildService().jobs().get(0).jobName()); - tester.deploy(JobType.productionUsEast3, application, applicationPackage, false); - tester.jobCompletion(JobType.productionUsEast3).application(application).submit(); + tester.deploy(JobType.productionUsEast3, instance, applicationPackage, false); + tester.jobCompletion(JobType.productionUsEast3).application(instance).submit(); // Last region completes assertEquals(1, tester.buildService().jobs().size()); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionEuWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionEuWest1); assertTrue("All jobs consumed", tester.buildService().jobs().isEmpty()); } @Test public void testNoOtherChangesDuringSuspension() { // Application is deployed in 3 regions: - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .parallel("us-west-1", "us-east-3") .build(); tester.jobCompletion(component) - .application(application) + .application(instance) .uploadArtifact(applicationPackage) .submit(); - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsWest1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsEast3); // The first production zone is suspended: - tester.configServer().setSuspended(new DeploymentId(application.id(), JobType.productionUsCentral1.zone(tester.controller().system())), true); + tester.configServer().setSuspended(new DeploymentId(instance.id(), JobType.productionUsCentral1.zone(tester.controller().system())), true); // A new change needs to be pushed out, but should not go beyond the suspended zone: tester.jobCompletion(component) - .application(application) + .application(instance) .nextBuildNumber() .sourceRevision(new SourceRevision("repository1", "master", "cafed00d")) .uploadArtifact(applicationPackage) .submit(); - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); tester.triggerUntilQuiescence(); - tester.assertNotRunning(JobType.productionUsEast3, application.id()); - tester.assertNotRunning(JobType.productionUsWest1, application.id()); + tester.assertNotRunning(JobType.productionUsEast3, instance.id()); + tester.assertNotRunning(JobType.productionUsWest1, instance.id()); // The zone is unsuspended so jobs start: - tester.configServer().setSuspended(new DeploymentId(application.id(), JobType.productionUsCentral1.zone(tester.controller().system())), false); + tester.configServer().setSuspended(new DeploymentId(instance.id(), JobType.productionUsCentral1.zone(tester.controller().system())), false); tester.triggerUntilQuiescence(); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsWest1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsEast3); } @Test @@ -385,7 +385,7 @@ public class DeploymentTriggerTest { .parallel("us-east-3", "us-west-1") .build(); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); // Test environments pass @@ -409,7 +409,7 @@ public class DeploymentTriggerTest { public void testSuccessfulDeploymentApplicationPackageChanged() { TenantName tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L); MockBuildService mockBuildService = tester.buildService(); - Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); + Instance instance = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); ApplicationPackage previousApplicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-east-3") @@ -425,16 +425,16 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(newApplicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(newApplicationPackage).submit(); // Application is deployed to all test environments and declared zones - tester.deployAndNotify(application, newApplicationPackage, true, JobType.systemTest); - tester.deploy(JobType.stagingTest, application, previousApplicationPackage, true); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsEast3); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsCentral1); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsWest1); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionEuWest1); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.systemTest); + tester.deploy(JobType.stagingTest, instance, previousApplicationPackage, true); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionEuWest1); assertTrue("All jobs consumed", mockBuildService.jobs().isEmpty()); } @@ -457,7 +457,7 @@ public class DeploymentTriggerTest { .region("us-central-1") .region("us-east-3"); - Application app = tester.createAndDeploy("app1", 1, applicationPackageBuilder.build()); + Instance app = tester.createAndDeploy("app1", 1, applicationPackageBuilder.build()); tester.clock().advance(Duration.ofHours(1)); // --------------- Enter block window: 18:30 @@ -506,7 +506,7 @@ public class DeploymentTriggerTest { .region("us-west-1") .region("us-east-3") .build(); - Application application = tester.createAndDeploy("app1", 1, applicationPackage); + Instance instance = tester.createAndDeploy("app1", 1, applicationPackage); // Application on (6.1, 1.0.42) Version v1 = Version.fromString("6.1"); @@ -514,48 +514,48 @@ public class DeploymentTriggerTest { // Application is mid-upgrade when block window begins, and has an outstanding change. Version v2 = Version.fromString("6.2"); tester.upgradeSystem(v2); - tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).nextBuildNumber().uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application, applicationPackage, true, stagingTest); - tester.deployAndNotify(application, applicationPackage, true, systemTest); + tester.deployAndNotify(instance, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, systemTest); // Entering block window will keep the outstanding change in place. tester.clock().advance(Duration.ofHours(1)); tester.outstandingChangeDeployer().run(); - tester.deployAndNotify(application, applicationPackage, true, productionUsWest1); - assertEquals(BuildJob.defaultBuildNumber, tester.application(application.id()).deploymentJobs().jobStatus() - .get(productionUsWest1).lastSuccess().get().application().buildNumber().getAsLong()); - assertEquals((BuildJob.defaultBuildNumber + 1), tester.application(application.id()).outstandingChange().application().get().buildNumber().getAsLong()); + tester.deployAndNotify(instance, applicationPackage, true, productionUsWest1); + assertEquals(BuildJob.defaultBuildNumber, tester.application(instance.id()).deploymentJobs().jobStatus() + .get(productionUsWest1).lastSuccess().get().application().buildNumber().getAsLong()); + assertEquals((BuildJob.defaultBuildNumber + 1), tester.application(instance.id()).outstandingChange().application().get().buildNumber().getAsLong()); tester.readyJobTrigger().maintain(); // Platform upgrade keeps rolling, since it has already deployed in a production zone, and tests for the new revision have also started. assertEquals(3, tester.buildService().jobs().size()); - tester.deployAndNotify(application, applicationPackage, true, productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, productionUsEast3); assertEquals(2, tester.buildService().jobs().size()); // Upgrade is done, and oustanding change rolls out when block window ends. - assertEquals(Change.empty(), tester.application(application.id()).change()); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).outstandingChange().hasTargets()); + assertEquals(Change.empty(), tester.application(instance.id()).change()); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).outstandingChange().hasTargets()); - tester.deployAndNotify(application, applicationPackage, true, stagingTest); - tester.deployAndNotify(application, applicationPackage, true, systemTest); + tester.deployAndNotify(instance, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, systemTest); tester.clock().advance(Duration.ofHours(1)); tester.outstandingChangeDeployer().run(); - assertTrue(tester.application(application.id()).change().hasTargets()); - assertFalse(tester.application(application.id()).outstandingChange().hasTargets()); + assertTrue(tester.application(instance.id()).change().hasTargets()); + assertFalse(tester.application(instance.id()).outstandingChange().hasTargets()); tester.readyJobTrigger().run(); - tester.deployAndNotify(application, applicationPackage, true, productionUsWest1); - tester.deployAndNotify(application, applicationPackage, true, productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, productionUsEast3); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertFalse(tester.application(application.id()).outstandingChange().hasTargets()); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertFalse(tester.application(instance.id()).outstandingChange().hasTargets()); } @Test public void testJobPause() { - Application app = tester.createAndDeploy("app", 3, "default"); + Instance app = tester.createAndDeploy("app", 3, "default"); tester.upgradeSystem(new Version("9.8.7")); tester.applications().deploymentTrigger().pauseJob(app.id(), productionUsWest1, tester.clock().instant().plus(Duration.ofSeconds(1))); @@ -589,7 +589,7 @@ public class DeploymentTriggerTest { ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator())); - Application app = tester.createAndDeploy("default0", 3, "default"); + Instance app = tester.createAndDeploy("default0", 3, "default"); // Store that we are upgrading but don't start the system-tests job tester.controller().applications().lockOrThrow(app.id(), locked -> { tester.controller().applications().store(locked.withChange(Change.of(Version.fromString("6.2")))); @@ -602,58 +602,58 @@ public class DeploymentTriggerTest { @Test public void applicationVersionIsNotDowngraded() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .region("eu-west-1") .build(); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // productionUsCentral1 fails after deployment, causing a mismatch between deployed and successful state. - tester.completeDeploymentWithError(application, applicationPackage, BuildJob.defaultBuildNumber + 1, productionUsCentral1); + tester.completeDeploymentWithError(instance, applicationPackage, BuildJob.defaultBuildNumber + 1, productionUsCentral1); // deployAndNotify doesn't actually deploy if the job fails, so we need to do that manually. - tester.deployAndNotify(application, false, productionUsCentral1); - tester.deploy(productionUsCentral1, application, Optional.empty(), false); + tester.deployAndNotify(instance, false, productionUsCentral1); + tester.deploy(productionUsCentral1, instance, Optional.empty(), false); ApplicationVersion appVersion1 = ApplicationVersion.from(BuildJob.defaultSourceRevision, BuildJob.defaultBuildNumber + 1); assertEquals(appVersion1, app.get().deployments().get(ZoneId.from("prod.us-central-1")).applicationVersion()); // Verify the application change is not removed when change is cancelled. - tester.deploymentTrigger().cancelChange(application.id(), PLATFORM); + tester.deploymentTrigger().cancelChange(instance.id(), PLATFORM); assertEquals(Change.of(appVersion1), app.get().change()); // Now cancel the change as is done through the web API. - tester.deploymentTrigger().cancelChange(application.id(), ALL); + tester.deploymentTrigger().cancelChange(instance.id(), ALL); assertEquals(Change.empty(), app.get().change()); // A new version is released, which should now deploy the currently deployed application version to avoid downgrades. Version version1 = new Version("6.2"); tester.upgradeSystem(version1); - tester.jobCompletion(productionUsCentral1).application(application).unsuccessful().submit(); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, false, productionUsCentral1); + tester.jobCompletion(productionUsCentral1).application(instance).unsuccessful().submit(); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, false, productionUsCentral1); // The last job has a different target, and the tests need to run again. // These may now start, since the first job has been triggered once, and thus is verified already. - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Finally, the two production jobs complete, in order. - tester.deployAndNotify(application, true, productionUsCentral1); - tester.deployAndNotify(application, true, productionEuWest1); + tester.deployAndNotify(instance, true, productionUsCentral1); + tester.deployAndNotify(instance, true, productionEuWest1); assertEquals(appVersion1, app.get().deployments().get(ZoneId.from("prod.us-central-1")).applicationVersion()); } @Test public void stepIsCompletePreciselyWhenItShouldBe() { - Application application1 = tester.createApplication("app1", "tenant1", 1, 1L); - Application application2 = tester.createApplication("app2", "tenant2", 2, 2L); - Supplier<Application> app1 = () -> tester.application(application1.id()); + Instance instance1 = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance2 = tester.createApplication("app2", "tenant2", 2, 2L); + Supplier<Instance> app1 = () -> tester.application(instance1.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -663,23 +663,23 @@ public class DeploymentTriggerTest { // System upgrades to version0 and applications deploy on that version Version version0 = Version.fromString("7.0"); tester.upgradeSystem(version0); - tester.deployCompletely(application1, applicationPackage); - tester.deployCompletely(application2, applicationPackage); + tester.deployCompletely(instance1, applicationPackage); + tester.deployCompletely(instance2, applicationPackage); // version1 is released and application1 skips upgrading to that version Version version1 = Version.fromString("7.1"); tester.upgradeSystem(version1); // Deploy application2 to keep this version present in the system - tester.deployCompletely(application2, applicationPackage); - tester.applications().deploymentTrigger().cancelChange(application1.id(), ALL); + tester.deployCompletely(instance2, applicationPackage); + tester.applications().deploymentTrigger().cancelChange(instance1.id(), ALL); tester.buildService().clear(); // Clear stale build jobs for cancelled change // version2 is released and application1 starts upgrading Version version2 = Version.fromString("7.2"); tester.upgradeSystem(version2); - tester.completeUpgradeWithError(application1, version2, applicationPackage, productionUsCentral1); - tester.deploy(productionUsCentral1, application1, applicationPackage); - tester.deployAndNotify(application1, applicationPackage, false, productionUsCentral1); + tester.completeUpgradeWithError(instance1, version2, applicationPackage, productionUsCentral1); + tester.deploy(productionUsCentral1, instance1, applicationPackage); + tester.deployAndNotify(instance1, applicationPackage, false, productionUsCentral1); assertEquals(version2, app1.get().deployments().get(productionUsCentral1.zone(main)).version()); // version2 becomes broken and upgrade targets latest non-broken @@ -687,34 +687,34 @@ public class DeploymentTriggerTest { tester.computeVersionStatus(); tester.upgrader().maintain(); // Cancel upgrades to broken version assertEquals("Change becomes latest non-broken version", Change.of(version1), app1.get().change()); - tester.deployAndNotify(application1, applicationPackage, false, productionUsCentral1); + tester.deployAndNotify(instance1, applicationPackage, false, productionUsCentral1); Instant triggered = app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).lastTriggered().get().at(); tester.clock().advance(Duration.ofHours(1)); // version1 proceeds 'til the last job, where it fails; us-central-1 is skipped, as current change is strictly dominated by what's deployed there. - tester.deployAndNotify(application1, applicationPackage, true, systemTest); - tester.deployAndNotify(application1, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance1, applicationPackage, true, systemTest); + tester.deployAndNotify(instance1, applicationPackage, true, stagingTest); assertEquals(triggered, app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).lastTriggered().get().at()); - tester.deployAndNotify(application1, applicationPackage, false, productionEuWest1); + tester.deployAndNotify(instance1, applicationPackage, false, productionEuWest1); //Eagerly triggered system and staging tests complete. - tester.deployAndNotify(application1, applicationPackage, true, systemTest); - tester.deployAndNotify(application1, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance1, applicationPackage, true, systemTest); + tester.deployAndNotify(instance1, applicationPackage, true, stagingTest); // Roll out a new application version, which gives a dual change -- this should trigger us-central-1, but only as long as it hasn't yet deployed there. - tester.jobCompletion(component).application(application1).nextBuildNumber().uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application1, applicationPackage, false, productionEuWest1); - tester.deployAndNotify(application1, applicationPackage, true, systemTest); - tester.deployAndNotify(application1, applicationPackage, true, stagingTest); + tester.jobCompletion(component).application(instance1).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.deployAndNotify(instance1, applicationPackage, false, productionEuWest1); + tester.deployAndNotify(instance1, applicationPackage, true, systemTest); + tester.deployAndNotify(instance1, applicationPackage, true, stagingTest); - tester.assertRunning(productionUsCentral1, application1.id()); + tester.assertRunning(productionUsCentral1, instance1.id()); assertEquals(version2, app1.get().deployments().get(productionUsCentral1.zone(main)).version()); assertEquals(42, app1.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().getAsLong()); assertNotEquals(triggered, app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).lastTriggered().get().at()); // Change has a higher application version than what is deployed -- deployment should trigger. - tester.deployAndNotify(application1, applicationPackage, false, productionUsCentral1); - tester.deploy(productionUsCentral1, application1, applicationPackage); + tester.deployAndNotify(instance1, applicationPackage, false, productionUsCentral1); + tester.deploy(productionUsCentral1, instance1, applicationPackage); assertEquals(version2, app1.get().deployments().get(productionUsCentral1.zone(main)).version()); assertEquals(43, app1.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().getAsLong()); @@ -722,67 +722,67 @@ public class DeploymentTriggerTest { tester.clock().advance(Duration.ofHours(2).plus(Duration.ofSeconds(1))); // Enough time for retry tester.readyJobTrigger().maintain(); // Failing job is not retried as change has been deployed - tester.assertNotRunning(productionUsCentral1, application1.id()); + tester.assertNotRunning(productionUsCentral1, instance1.id()); // Last job has a different deployment target, so tests need to run again. - tester.deployAndNotify(application1, true, systemTest); - tester.deployAndNotify(application1, true, stagingTest); - tester.deployAndNotify(application1, applicationPackage, true, productionEuWest1); + tester.deployAndNotify(instance1, true, systemTest); + tester.deployAndNotify(instance1, true, stagingTest); + tester.deployAndNotify(instance1, applicationPackage, true, productionEuWest1); assertFalse(app1.get().change().hasTargets()); assertFalse(app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).isSuccess()); } @Test public void eachDeployTargetIsTested() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .parallel("eu-west-1", "us-east-3") .build(); // Application version 42 and platform version 6.1. - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Success in first prod zone, change cancelled between triggering and deployment to two parallel zones. // One of the parallel zones get a deployment, but both fail their jobs. Version v1 = new Version("6.1"); Version v2 = new Version("6.2"); tester.upgradeSystem(v2); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deploymentTrigger().cancelChange(application.id(), PLATFORM); - tester.deploy(productionEuWest1, application, applicationPackage); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deploymentTrigger().cancelChange(instance.id(), PLATFORM); + tester.deploy(productionEuWest1, instance, applicationPackage); assertEquals(v2, app.get().deployments().get(productionEuWest1.zone(main)).version()); assertEquals(v1, app.get().deployments().get(productionUsEast3.zone(main)).version()); // New application version should run system and staging tests against both 6.1 and 6.2, in no particular order. - tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).nextBuildNumber().uploadArtifact(applicationPackage).submit(); Version firstTested = app.get().deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().platform(); assertEquals(firstTested, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Tests are not re-triggered, because the deployments that were tested have not yet been triggered on the tested versions. assertEquals(firstTested, app.get().deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().platform()); assertEquals(firstTested, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); // Finish old runs of the production jobs, which fail. - tester.deployAndNotify(application, applicationPackage, false, productionEuWest1); - tester.deployAndNotify(application, applicationPackage, false, productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, false, productionEuWest1); + tester.deployAndNotify(instance, applicationPackage, false, productionUsEast3); tester.triggerUntilQuiescence(); // New upgrade is already tested for one of the jobs, which has now been triggered, and tests may run for the other job. assertNotEquals(firstTested, app.get().deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().platform()); assertNotEquals(firstTested, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Both jobs fail again, and must be re-triggered -- this is ok, as they are both already triggered on their current targets. - tester.deployAndNotify(application, false, productionEuWest1); - tester.deployAndNotify(application, false, productionUsEast3); - tester.deployAndNotify(application, true, productionUsEast3); - tester.deployAndNotify(application, true, productionEuWest1); + tester.deployAndNotify(instance, false, productionEuWest1); + tester.deployAndNotify(instance, false, productionUsEast3); + tester.deployAndNotify(instance, true, productionUsEast3); + tester.deployAndNotify(instance, true, productionEuWest1); assertFalse(app.get().change().hasTargets()); assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionEuWest1).lastSuccess().get().application().buildNumber().getAsLong()); assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionUsEast3).lastSuccess().get().application().buildNumber().getAsLong()); @@ -790,98 +790,98 @@ public class DeploymentTriggerTest { @Test public void eachDifferentUpgradeCombinationIsTested() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .parallel("eu-west-1", "us-east-3") .build(); // Application version 42 and platform version 6.1. - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Application partially upgrades, then a new version is released. Version v1 = new Version("6.1"); Version v2 = new Version("6.2"); tester.upgradeSystem(v2); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsCentral1); - tester.deployAndNotify(application, true, productionEuWest1); - tester.deployAndNotify(application, false, productionUsEast3); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsCentral1); + tester.deployAndNotify(instance, true, productionEuWest1); + tester.deployAndNotify(instance, false, productionUsEast3); assertEquals(v2, app.get().deployments().get(ZoneId.from("prod", "us-central-1")).version()); assertEquals(v2, app.get().deployments().get(ZoneId.from("prod", "eu-west-1")).version()); assertEquals(v1, app.get().deployments().get(ZoneId.from("prod", "us-east-3")).version()); Version v3 = new Version("6.3"); tester.upgradeSystem(v3); - tester.deployAndNotify(application, false, productionUsEast3); + tester.deployAndNotify(instance, false, productionUsEast3); // See that sources for staging are: first v2, then v1. - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); assertEquals(v2, app.get().deploymentJobs().jobStatus().get(stagingTest).lastSuccess().get().sourcePlatform().get()); - tester.deployAndNotify(application, true, productionUsCentral1); + tester.deployAndNotify(instance, true, productionUsCentral1); assertEquals(v1, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().sourcePlatform().get()); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionEuWest1); - tester.deployAndNotify(application, true, productionUsEast3); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionEuWest1); + tester.deployAndNotify(instance, true, productionUsEast3); } @Test public void retriesFailingJobs() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .build(); // Deploy completely on default application and platform versions - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // New application change is deployed and fails in system-test for a while - tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application, false, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.jobCompletion(component).application(instance).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.deployAndNotify(instance, false, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Retries immediately in the first minute after failing tester.clock().advance(Duration.ofSeconds(59)); - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertRunning(systemTest, application.id()); + tester.assertRunning(systemTest, instance.id()); // Stops immediate retry after failing for 1 minute tester.clock().advance(Duration.ofSeconds(1)); - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertNotRunning(systemTest, application.id()); + tester.assertNotRunning(systemTest, instance.id()); // Retries after 10 minutes since previous completion as we failed within the last hour tester.clock().advance(Duration.ofMinutes(10).plus(Duration.ofSeconds(1))); tester.readyJobTrigger().maintain(); - tester.assertRunning(systemTest, application.id()); + tester.assertRunning(systemTest, instance.id()); // Retries less frequently after 1 hour of failure tester.clock().advance(Duration.ofMinutes(50)); - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertNotRunning(systemTest, application.id()); + tester.assertNotRunning(systemTest, instance.id()); // Retries after two hours pass since last completion tester.clock().advance(Duration.ofHours(2).plus(Duration.ofSeconds(1))); tester.readyJobTrigger().maintain(); - tester.assertRunning(systemTest, application.id()); + tester.assertRunning(systemTest, instance.id()); // Still fails and is not retried - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertNotRunning(systemTest, application.id()); + tester.assertNotRunning(systemTest, instance.id()); // Another application change is deployed and fixes system-test. Change is triggered immediately as target changes - tester.jobCompletion(component).application(application).nextBuildNumber(2).uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsCentral1); + tester.jobCompletion(component).application(instance).nextBuildNumber(2).uploadArtifact(applicationPackage).submit(); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsCentral1); assertTrue("Deployment completed", tester.buildService().jobs().isEmpty()); } @@ -895,7 +895,7 @@ public class DeploymentTriggerTest { Version version = Version.fromString("6.2"); tester.upgradeSystem(version); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); @@ -954,7 +954,7 @@ public class DeploymentTriggerTest { Version version = Version.fromString("6.2"); tester.upgradeSystem(version); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); @@ -988,7 +988,7 @@ public class DeploymentTriggerTest { @Test public void testUpdatesFailingJobStatus() { // Setup application - Application app = tester.createApplication("app1", "foo", 1, 1L); + Instance app = tester.createApplication("app1", "foo", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -1058,7 +1058,7 @@ public class DeploymentTriggerTest { .build(); Version version1 = tester.controller().versionStatus().systemVersion().get().versionNumber(); - Application app1 = tester.createApplication("application1", "tenant1", 1, 1L); + Instance app1 = tester.createApplication("application1", "tenant1", 1, 1L); // First deployment: An application change tester.jobCompletion(component).application(app1).uploadArtifact(applicationPackage).submit(); @@ -1124,9 +1124,9 @@ public class DeploymentTriggerTest { long project1 = 1; long project2 = 2; long project3 = 3; - Application app1 = tester.createApplication("app1", "tenant1", project1, 1L); - Application app2 = tester.createApplication("app2", "tenant2", project2, 1L); - Application app3 = tester.createApplication("app3", "tenant3", project3, 1L); + Instance app1 = tester.createApplication("app1", "tenant1", project1, 1L); + Instance app2 = tester.createApplication("app2", "tenant2", project2, 1L); + Instance app3 = tester.createApplication("app3", "tenant3", project3, 1L); MockBuildService mockBuildService = tester.buildService(); // all applications: system-test completes successfully with some time in between, to determine trigger order. diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java index 879007494db..b6315bc6780 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java @@ -11,7 +11,7 @@ import com.yahoo.security.KeyUtils; import com.yahoo.security.SignatureAlgorithm; import com.yahoo.security.X509CertificateBuilder; import com.yahoo.test.ManualClock; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; @@ -86,7 +86,7 @@ public class InternalDeploymentTester { public ConfigServerMock configServer() { return tester.configServer(); } public ApplicationController applications() { return tester.applications(); } public ManualClock clock() { return tester.clock(); } - public Application app() { return tester.application(appId); } + public Instance app() { return tester.application(appId); } public InternalDeploymentTester() { tester = new DeploymentTester(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java index f9c8b66acda..98e8eff508e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.organization.ApplicationSummary; import com.yahoo.vespa.hosted.controller.api.integration.organization.Contact; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; @@ -44,12 +44,12 @@ public class ApplicationOwnershipConfirmerTest { Optional<Contact> contact = Optional.of(tester.controllerTester().serviceRegistry().contactRetrieverMock().contact()); TenantName property = tester.controllerTester().createTenant("property", "domain", 1L, contact); tester.createAndDeploy(property, "application", 1, "default"); - Supplier<Application> propertyApp = () -> tester.controller().applications().require(ApplicationId.from("property", "application", "default")); + Supplier<Instance> propertyApp = () -> tester.controller().applications().require(ApplicationId.from("property", "application", "default")); UserTenant user = UserTenant.create("by-user", contact); tester.controller().tenants().createUser(user); tester.createAndDeploy(user.name(), "application", 2, "default"); - Supplier<Application> userApp = () -> tester.controller().applications().require(ApplicationId.from("by-user", "application", "default")); + Supplier<Instance> userApp = () -> tester.controller().applications().require(ApplicationId.from("by-user", "application", "default")); assertFalse("No issue is initially stored for a new application.", propertyApp.get().ownershipIssueId().isPresent()); assertFalse("No issue is initially stored for a new application.", userApp.get().ownershipIssueId().isPresent()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java index 730b2943431..b2ac44bf23b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -33,8 +33,8 @@ public class DeploymentExpirerTest { ); DeploymentExpirer expirer = new DeploymentExpirer(tester.controller(), Duration.ofDays(10), new JobControl(new MockCuratorDb())); - Application devApp = tester.createApplication("app1", "tenant1", 123L, 1L); - Application prodApp = tester.createApplication("app2", "tenant2", 456L, 2L); + Instance devApp = tester.createApplication("app1", "tenant1", 123L, 1L); + Instance prodApp = tester.createApplication("app2", "tenant2", 456L, 2L); // Deploy dev tester.controllerTester().deploy(devApp, tester.controllerTester().toZone(Environment.dev)); @@ -60,11 +60,11 @@ public class DeploymentExpirerTest { assertEquals(1, permanentDeployments(prodApp).size()); } - private List<Deployment> permanentDeployments(Application application) { - return tester.controller().applications().get(application.id()).get().deployments().values().stream() - .filter(deployment -> deployment.zone().environment() != Environment.test && + private List<Deployment> permanentDeployments(Instance instance) { + return tester.controller().applications().get(instance.id()).get().deployments().values().stream() + .filter(deployment -> deployment.zone().environment() != Environment.test && deployment.zone().environment() != Environment.staging) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java index 7da1064cb23..d20ccdf5963 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.organization.Contact; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues; @@ -78,9 +78,9 @@ public class DeploymentIssueReporterTest { tester.controllerTester().createTenant("tenant3", "domain3", 1L, contact); // Create and deploy one application for each of three tenants. - Application app1 = tester.createApplication("application1", "tenant1", projectId1, propertyId1); - Application app2 = tester.createApplication("application2", "tenant2", projectId2, propertyId2); - Application app3 = tester.createApplication("application3", "tenant3", projectId3, propertyId3); + Instance app1 = tester.createApplication("application1", "tenant1", projectId1, propertyId1); + Instance app2 = tester.createApplication("application2", "tenant2", projectId2, propertyId2); + Instance app3 = tester.createApplication("application3", "tenant3", projectId3, propertyId3); // NOTE: All maintenance should be idempotent within a small enough time interval, so maintain is called twice in succession throughout. diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java index c8b3cd01fe8..c4a835cd7e7 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java @@ -6,7 +6,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.application.v4.model.ClusterMetrics; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; @@ -40,7 +40,7 @@ public class DeploymentMetricsMaintainerTest { deploy(application, Version.fromString("7.1")); DeploymentMetricsMaintainer maintainer = maintainer(tester.controller()); - Supplier<Application> app = () -> tester.application(application.id()); + Supplier<Instance> app = () -> tester.application(application.id()); Supplier<Deployment> deployment = () -> app.get().deployments().values().stream().findFirst().get(); // No metrics gathered yet @@ -127,8 +127,8 @@ public class DeploymentMetricsMaintainerTest { return new DeploymentMetricsMaintainer(controller, Duration.ofDays(1), new JobControl(controller.curator())); } - private void deploy(Application application, Version version) { - tester.controllerTester().deploy(application, + private void deploy(Instance instance, Version version) { + tester.controllerTester().deploy(instance, ZoneId.from(Environment.dev, RegionName.from("us-east-1")), Optional.of(new ApplicationPackage(new byte[0])), false, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java index 148be3f258e..46e6d9c3f50 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; @@ -46,10 +46,10 @@ public class MetricsReporterTest { assertEquals(0.0, metrics.getMetric(MetricsReporter.DEPLOYMENT_FAIL_METRIC)); // Deploy all apps successfully - Application app1 = tester.createApplication("app1", "tenant1", 1, 11L); - Application app2 = tester.createApplication("app2", "tenant1", 2, 22L); - Application app3 = tester.createApplication("app3", "tenant1", 3, 33L); - Application app4 = tester.createApplication("app4", "tenant1", 4, 44L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app2 = tester.createApplication("app2", "tenant1", 2, 22L); + Instance app3 = tester.createApplication("app3", "tenant1", 3, 33L); + Instance app4 = tester.createApplication("app4", "tenant1", 4, 44L); tester.deployCompletely(app1, applicationPackage); tester.deployCompletely(app2, applicationPackage); tester.deployCompletely(app3, applicationPackage); @@ -76,7 +76,7 @@ public class MetricsReporterTest { MetricsReporter reporter = createReporter(tester.controller()); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.deployCompletely(app, applicationPackage); reporter.maintain(); assertEquals(Duration.ZERO, getAverageDeploymentDuration(app)); // An exceptionally fast deployment :-) @@ -117,7 +117,7 @@ public class MetricsReporterTest { .build(); MetricsReporter reporter = createReporter(tester.controller()); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); // Initial deployment without failures tester.deployCompletely(app, applicationPackage); @@ -168,12 +168,12 @@ public class MetricsReporterTest { .region("us-east-3") .build(); MetricsReporter reporter = createReporter(tester.controller()); - Application application = tester.createApplication("app1", "tenant1", 1, 11L); - tester.configServer().generateWarnings(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1")), 3); - tester.configServer().generateWarnings(new DeploymentId(application.id(), ZoneId.from("prod", "us-east-3")), 4); - tester.deployCompletely(application, applicationPackage); + Instance instance = tester.createApplication("app1", "tenant1", 1, 11L); + tester.configServer().generateWarnings(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1")), 3); + tester.configServer().generateWarnings(new DeploymentId(instance.id(), ZoneId.from("prod", "us-east-3")), 4); + tester.deployCompletely(instance, applicationPackage); reporter.maintain(); - assertEquals(4, getDeploymentWarnings(application)); + assertEquals(4, getDeploymentWarnings(instance)); } @Test @@ -198,11 +198,11 @@ public class MetricsReporterTest { .region("us-east-3") .build(); MetricsReporter reporter = createReporter(tester.controller()); - Application application = tester.createApplication("app1", "tenant1", 1, 11L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 11L); reporter.maintain(); assertEquals("Queue is empty initially", 0, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); reporter.maintain(); assertEquals("Deployment queues name services requests", 6, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); @@ -211,31 +211,31 @@ public class MetricsReporterTest { assertEquals("Queue consumed", 0, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); } - private Duration getAverageDeploymentDuration(Application application) { - return Duration.ofSeconds(getMetric(MetricsReporter.DEPLOYMENT_AVERAGE_DURATION, application).longValue()); + private Duration getAverageDeploymentDuration(Instance instance) { + return Duration.ofSeconds(getMetric(MetricsReporter.DEPLOYMENT_AVERAGE_DURATION, instance).longValue()); } - private int getDeploymentsFailingUpgrade(Application application) { - return getMetric(MetricsReporter.DEPLOYMENT_FAILING_UPGRADES, application).intValue(); + private int getDeploymentsFailingUpgrade(Instance instance) { + return getMetric(MetricsReporter.DEPLOYMENT_FAILING_UPGRADES, instance).intValue(); } - private int getDeploymentWarnings(Application application) { - return getMetric(MetricsReporter.DEPLOYMENT_WARNINGS, application).intValue(); + private int getDeploymentWarnings(Instance instance) { + return getMetric(MetricsReporter.DEPLOYMENT_WARNINGS, instance).intValue(); } - private Number getMetric(String name, Application application) { - return metrics.getMetric((dimensions) -> application.id().tenant().value().equals(dimensions.get("tenant")) && - appDimension(application).equals(dimensions.get("app")), + private Number getMetric(String name, Instance instance) { + return metrics.getMetric((dimensions) -> instance.id().tenant().value().equals(dimensions.get("tenant")) && + appDimension(instance).equals(dimensions.get("app")), name) - .orElseThrow(() -> new RuntimeException("Expected metric to exist for " + application.id())); + .orElseThrow(() -> new RuntimeException("Expected metric to exist for " + instance.id())); } private MetricsReporter createReporter(Controller controller) { return new MetricsReporter(controller, metrics, new JobControl(new MockCuratorDb())); } - private static String appDimension(Application application) { - return application.id().application().value() + "." + application.id().instance().value(); + private static String appDimension(Instance instance) { + return instance.id().application().value() + "." + instance.id().instance().value(); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java index 3a7c62c900a..4bd1bfcffae 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; @@ -53,7 +53,7 @@ public class OutstandingChangeDeployerTest { .uploadArtifact(applicationPackage) .submit(); - Application app = tester.application("app1"); + Instance app = tester.application("app1"); assertTrue(app.outstandingChange().hasTargets()); assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id()); assertEquals(2, tester.buildService().jobs().size()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java index f0b12cb48b6..7f97f1bc4a9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -42,7 +42,7 @@ public class RotationStatusUpdaterTest { .build(); tester.deployCompletely(application, applicationPackage); - Supplier<Application> app = () -> tester.application(application.id()); + Supplier<Instance> app = () -> tester.application(application.id()); Supplier<Deployment> deployment1 = () -> app.get().deployments().get(zone1); Supplier<Deployment> deployment2 = () -> app.get().deployments().get(zone2); Supplier<Deployment> deployment3 = () -> app.get().deployments().get(zone3); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java index 0dee5fcb78c..1763ff74fb0 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java @@ -5,7 +5,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.configserver.LoadBalancer; import com.yahoo.vespa.hosted.controller.api.integration.dns.Record; @@ -38,8 +38,8 @@ public class RoutingPoliciesTest { private final DeploymentTester tester = new DeploymentTester(); - private final Application app1 = tester.createApplication("app1", "tenant1", 1, 1L); - private final Application app2 = tester.createApplication("app2", "tenant1", 1, 1L); + private final Instance app1 = tester.createApplication("app1", "tenant1", 1, 1L); + private final Instance app2 = tester.createApplication("app2", "tenant1", 1, 1L); private final ZoneId zone1 = ZoneId.from("prod", "us-west-1"); private final ZoneId zone2 = ZoneId.from("prod", "us-central-1"); @@ -238,8 +238,8 @@ public class RoutingPoliciesTest { tester.controller().applications().clusterEndpoints(new DeploymentId(app1.id(), zone1))); } - private Set<RoutingPolicy> policies(Application application) { - return tester.controller().curator().readRoutingPolicies(application.id()); + private Set<RoutingPolicy> policies(Instance instance) { + return tester.controller().curator().readRoutingPolicies(instance.id()); } private Set<String> recordNames() { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java index ab4d4987d6a..a54d6f3ece7 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java @@ -5,7 +5,7 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; @@ -54,12 +54,12 @@ public class UpgraderTest { assertEquals("No applications: Nothing to do", 0, tester.buildService().jobs().size()); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application conservative0 = tester.createAndDeploy("conservative0", 6, "conservative"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance conservative0 = tester.createAndDeploy("conservative0", 6, "conservative"); tester.upgrader().maintain(); tester.triggerUntilQuiescence(); @@ -183,8 +183,8 @@ public class UpgraderTest { // --- Starting upgrading to a new version which breaks, causing upgrades to commence on the previous version Version version4 = Version.fromString("6.6"); - Application default3 = tester.createAndDeploy("default3", 7, "default"); // need 4 to break a version - Application default4 = tester.createAndDeploy("default4", 8, "default"); + Instance default3 = tester.createAndDeploy("default3", 7, "default"); // need 4 to break a version + Instance default4 = tester.createAndDeploy("default4", 8, "default"); tester.upgradeSystem(version4); tester.upgrader().maintain(); // cause canary upgrades to new version tester.triggerUntilQuiescence(); @@ -271,18 +271,18 @@ public class UpgraderTest { assertEquals("No applications: Nothing to do", 0, tester.buildService().jobs().size()); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); - Application default4 = tester.createAndDeploy("default4", 7, "default"); - Application default5 = tester.createAndDeploy("default5", 8, "default"); - Application default6 = tester.createAndDeploy("default6", 9, "default"); - Application default7 = tester.createAndDeploy("default7", 10, "default"); - Application default8 = tester.createAndDeploy("default8", 11, "default"); - Application default9 = tester.createAndDeploy("default9", 12, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); + Instance default4 = tester.createAndDeploy("default4", 7, "default"); + Instance default5 = tester.createAndDeploy("default5", 8, "default"); + Instance default6 = tester.createAndDeploy("default6", 9, "default"); + Instance default7 = tester.createAndDeploy("default7", 10, "default"); + Instance default8 = tester.createAndDeploy("default8", 11, "default"); + Instance default9 = tester.createAndDeploy("default9", 12, "default"); tester.upgrader().maintain(); tester.triggerUntilQuiescence(); @@ -338,7 +338,7 @@ public class UpgraderTest { Version version = Version.fromString("6.2"); tester.upgradeSystem(version); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); tester.deployAndNotify(app, applicationPackage, true, systemTest); tester.deployAndNotify(app, applicationPackage, true, stagingTest); @@ -389,13 +389,13 @@ public class UpgraderTest { tester.upgradeSystem(version); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); - Application default4 = tester.createAndDeploy("default4", 7, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); + Instance default4 = tester.createAndDeploy("default4", 7, "default"); // New version is released version = Version.fromString("6.3"); @@ -455,13 +455,13 @@ public class UpgraderTest { tester.upgradeSystem(v0); // Setup applications on V0 - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); - Application default4 = tester.createAndDeploy("default4", 7, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); + Instance default4 = tester.createAndDeploy("default4", 7, "default"); // V1 is released Version v1 = Version.fromString("6.3"); @@ -542,13 +542,13 @@ public class UpgraderTest { ApplicationPackage defaultPolicy = DeploymentTester.applicationPackage("default"); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, canaryPolicy); - Application canary1 = tester.createAndDeploy("canary1", 2, canaryPolicy); - Application default0 = tester.createAndDeploy("default0", 3, defaultPolicy); - Application default1 = tester.createAndDeploy("default1", 4, defaultPolicy); - Application default2 = tester.createAndDeploy("default2", 5, defaultPolicy); - Application default3 = tester.createAndDeploy("default3", 6, defaultPolicy); - Application default4 = tester.createAndDeploy("default4", 7, defaultPolicy); + Instance canary0 = tester.createAndDeploy("canary0", 1, canaryPolicy); + Instance canary1 = tester.createAndDeploy("canary1", 2, canaryPolicy); + Instance default0 = tester.createAndDeploy("default0", 3, defaultPolicy); + Instance default1 = tester.createAndDeploy("default1", 4, defaultPolicy); + Instance default2 = tester.createAndDeploy("default2", 5, defaultPolicy); + Instance default3 = tester.createAndDeploy("default3", 6, defaultPolicy); + Instance default4 = tester.createAndDeploy("default4", 7, defaultPolicy); // New version is released version = Version.fromString("6.3"); @@ -600,7 +600,7 @@ public class UpgraderTest { .region("us-west-1") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -643,7 +643,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -680,7 +680,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -758,13 +758,13 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, canaryApplicationPackage); - Application canary1 = tester.createAndDeploy("canary1", 2, canaryApplicationPackage); - Application default0 = tester.createAndDeploy("default0", 3, defaultApplicationPackage); - Application default1 = tester.createAndDeploy("default1", 4, defaultApplicationPackage); - Application default2 = tester.createAndDeploy("default2", 5, defaultApplicationPackage); - Application default3 = tester.createAndDeploy("default3", 6, defaultApplicationPackage); - Application default4 = tester.createAndDeploy("default4", 7, defaultApplicationPackage); + Instance canary0 = tester.createAndDeploy("canary0", 1, canaryApplicationPackage); + Instance canary1 = tester.createAndDeploy("canary1", 2, canaryApplicationPackage); + Instance default0 = tester.createAndDeploy("default0", 3, defaultApplicationPackage); + Instance default1 = tester.createAndDeploy("default1", 4, defaultApplicationPackage); + Instance default2 = tester.createAndDeploy("default2", 5, defaultApplicationPackage); + Instance default3 = tester.createAndDeploy("default3", 6, defaultApplicationPackage); + Instance default4 = tester.createAndDeploy("default4", 7, defaultApplicationPackage); assertEquals(version, default0.oldestDeployedPlatform().get()); @@ -810,7 +810,7 @@ public class UpgraderTest { tester.jobCompletion(stagingTest).application(default4).unsuccessful().submit(); // 5th app never reports back and has a dead job, but no ongoing change - Application deadLocked = tester.applications().require(default4.id()); + Instance deadLocked = tester.applications().require(default4.id()); tester.assertRunning(systemTest, deadLocked.id()); assertFalse("No change present", deadLocked.change().hasTargets()); @@ -857,15 +857,15 @@ public class UpgraderTest { upgrader.setUpgradesPerMinute(0.2); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); // Dev deployment which should be ignored - Application dev0 = tester.createApplication("dev0", "tenant1", 7, 1L); + Instance dev0 = tester.createApplication("dev0", "tenant1", 7, 1L); tester.controllerTester().deploy(dev0, ZoneId.from(Environment.dev, RegionName.from("dev-region"))); // New version is released and canaries upgrade @@ -910,8 +910,8 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application default0 = tester.createAndDeploy("default0", 2, version6ApplicationPackage); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance default0 = tester.createAndDeploy("default0", 2, version6ApplicationPackage); // New major version is released version = Version.fromString("7.0"); @@ -944,8 +944,8 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application default0 = tester.createAndDeploy("default0", 2, default0ApplicationPackage); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance default0 = tester.createAndDeploy("default0", 2, default0ApplicationPackage); tester.applications().lockOrThrow(default0.id(), a -> tester.applications().store(a.withMajorVersion(6))); assertEquals(OptionalInt.of(6), tester.applications().get(default0.id()).get().majorVersion()); @@ -987,9 +987,9 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary", 1, version7CanaryApplicationPackage); - Application default0 = tester.createAndDeploy("default0", 2, version7DefaultApplicationPackage); - Application default1 = tester.createAndDeploy("default1", 3, "default"); + Instance canary0 = tester.createAndDeploy("canary", 1, version7CanaryApplicationPackage); + Instance default0 = tester.createAndDeploy("default0", 2, version7DefaultApplicationPackage); + Instance default1 = tester.createAndDeploy("default1", 3, "default"); // New major version is released, but we don't want to upgrade to it yet tester.upgrader().setTargetMajorVersion(Optional.of(6)); @@ -1034,7 +1034,7 @@ public class UpgraderTest { .region("us-west-1") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -1087,7 +1087,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); tester.jobCompletion(component).application(app).nextBuildNumber().uploadArtifact(applicationPackage).submit(); @@ -1139,7 +1139,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); tester.jobCompletion(component).application(app).nextBuildNumber().uploadArtifact(applicationPackage).submit(); @@ -1183,61 +1183,61 @@ public class UpgraderTest { tester.upgradeSystem(version0); // Create an application with pinned platform version. - Application application = tester.createApplication("application", "tenant", 2, 3); + Instance instance = tester.createApplication("application", "tenant", 2, 3); ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod) .region("us-east-3") .region("us-west-1") .build(); - tester.deploymentTrigger().forceChange(application.id(), Change.empty().withPin()); + tester.deploymentTrigger().forceChange(instance.id(), Change.empty().withPin()); - tester.deployCompletely(application, applicationPackage); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).change().isPinned()); - assertEquals(2, tester.application(application.id()).deployments().size()); + tester.deployCompletely(instance, applicationPackage); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).change().isPinned()); + assertEquals(2, tester.application(instance.id()).deployments().size()); // Application does not upgrade. Version version1 = Version.fromString("6.3"); tester.upgradeSystem(version1); tester.upgrader().maintain(); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).change().isPinned()); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).change().isPinned()); // New application package is deployed. - tester.deployCompletely(application, applicationPackage, BuildJob.defaultBuildNumber + 1); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).change().isPinned()); + tester.deployCompletely(instance, applicationPackage, BuildJob.defaultBuildNumber + 1); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).change().isPinned()); // Application upgrades to new version when pin is removed. - tester.deploymentTrigger().cancelChange(application.id(), PIN); + tester.deploymentTrigger().cancelChange(instance.id(), PIN); tester.upgrader().maintain(); - assertTrue(tester.application(application.id()).change().hasTargets()); - assertFalse(tester.application(application.id()).change().isPinned()); + assertTrue(tester.application(instance.id()).change().hasTargets()); + assertFalse(tester.application(instance.id()).change().isPinned()); // Application is pinned to new version, and upgrade is therefore not cancelled, even though confidence is broken. - tester.deploymentTrigger().forceChange(application.id(), Change.empty().withPin()); + tester.deploymentTrigger().forceChange(instance.id(), Change.empty().withPin()); tester.upgrader().maintain(); tester.readyJobTrigger().maintain(); - assertEquals(version1, tester.application(application.id()).change().platform().get()); + assertEquals(version1, tester.application(instance.id()).change().platform().get()); // Application fails upgrade after one zone is complete, and is pinned again to the old version. - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsEast3); - tester.deploy(productionUsWest1, application, Optional.empty(), false); - tester.deployAndNotify(application, false, productionUsWest1); - tester.deploymentTrigger().cancelChange(application.id(), ALL); - tester.deploymentTrigger().forceChange(application.id(), Change.of(version0).withPin()); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsEast3); + tester.deploy(productionUsWest1, instance, Optional.empty(), false); + tester.deployAndNotify(instance, false, productionUsWest1); + tester.deploymentTrigger().cancelChange(instance.id(), ALL); + tester.deploymentTrigger().forceChange(instance.id(), Change.of(version0).withPin()); tester.buildService().clear(); - assertEquals(version0, tester.application(application.id()).change().platform().get()); + assertEquals(version0, tester.application(instance.id()).change().platform().get()); // Application downgrades to pinned version. tester.readyJobTrigger().maintain(); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsEast3); - assertTrue(tester.application(application.id()).change().hasTargets()); - tester.deployAndNotify(application, true, productionUsWest1); - assertFalse(tester.application(application.id()).change().hasTargets()); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsEast3); + assertTrue(tester.application(instance.id()).change().hasTargets()); + tester.deployAndNotify(instance, true, productionUsWest1); + assertFalse(tester.application(instance.id()).change().hasTargets()); } @Test @@ -1250,8 +1250,8 @@ public class UpgraderTest { tester.upgrader().setTargetMajorVersion(Optional.of(6)); // All applications deploy on current version - Application app1 = tester.createAndDeploy("app1", 1, "default"); - Application app2 = tester.createAndDeploy("app2", 1, "default"); + Instance app1 = tester.createAndDeploy("app1", 1, "default"); + Instance app2 = tester.createAndDeploy("app2", 1, "default"); // Keep app 1 on current version tester.controller().applications().lockIfPresent(app1.id(), app -> tester.controller().applications().store(app.withChange(app.get().change().withPin()))); @@ -1283,8 +1283,8 @@ public class UpgraderTest { @Test public void testsEachUpgradeCombinationWithFailingDeployments() { DeploymentTester tester = new DeploymentTester(); - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -1294,22 +1294,22 @@ public class UpgraderTest { // Application deploys on system version Version v1 = Version.fromString("6.1"); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Next version is released and 2/3 deployments upgrade Version v2 = Version.fromString("6.2"); tester.upgradeSystem(v2); tester.upgrader().maintain(); assertEquals(Change.of(v2), app.get().change()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsCentral1); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsCentral1); // While second deployment completes upgrade, version confidence becomes broken and upgrade is cancelled tester.upgrader().overrideConfidence(v2, VespaVersion.Confidence.broken); tester.computeVersionStatus(); tester.upgrader().maintain(); - tester.deployAndNotify(application, true, productionUsWest1); + tester.deployAndNotify(instance, true, productionUsWest1); assertTrue(app.get().change().isEmpty()); // Next version is released @@ -1317,21 +1317,21 @@ public class UpgraderTest { tester.upgradeSystem(v3); tester.upgrader().maintain(); assertEquals(Change.of(v3), app.get().change()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // First deployment starts upgrading - tester.deploy(productionUsCentral1, application, applicationPackage); + tester.deploy(productionUsCentral1, instance, applicationPackage); // Before deployment completes, v1->v3 combination is tested as us-east-3 is still on v1 tester.readyJobTrigger().maintain(); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, stagingTest); assertEquals(v1, app.get().deploymentJobs().jobStatus().get(stagingTest).lastSuccess().get().sourcePlatform().get()); assertEquals(v3, app.get().deploymentJobs().jobStatus().get(stagingTest).lastSuccess().get().platform()); // First deployment fails and then successfully upgrades to v3 - tester.jobCompletion(productionUsCentral1).application(application).unsuccessful().submit(); - tester.jobCompletion(productionUsCentral1).application(application).submit(); + tester.jobCompletion(productionUsCentral1).application(instance).unsuccessful().submit(); + tester.jobCompletion(productionUsCentral1).application(instance).submit(); // Deployments are now on 3 versions assertEquals(v3, app.get().deployments().get(productionUsCentral1.zone(main)).version()); @@ -1342,19 +1342,19 @@ public class UpgraderTest { tester.readyJobTrigger().maintain(); assertEquals(v2, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().sourcePlatform().get()); assertEquals(v3, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, stagingTest); // Second deployment upgrades - tester.deployAndNotify(application, true, productionUsWest1); + tester.deployAndNotify(instance, true, productionUsWest1); // ... now we have to test v1->v3 again :( tester.readyJobTrigger().maintain(); assertEquals(v1, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().sourcePlatform().get()); assertEquals(v3, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, stagingTest); // Upgrade completes - tester.deployAndNotify(application, true, productionUsEast3); + tester.deployAndNotify(instance, true, productionUsEast3); assertTrue("Upgrade complete", app.get().change().isEmpty()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java index 16f57a61916..25193688d85 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java @@ -8,7 +8,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; @@ -104,22 +104,22 @@ public class ApplicationSerializerTest { Map.of(ZoneId.from("prod", "us-west-1"), RotationState.in, ZoneId.from("prod", "us-east-3"), RotationState.out))); - Application original = new Application(ApplicationId.from("t1", "a1", "i1"), - Instant.now().truncatedTo(ChronoUnit.MILLIS), - deploymentSpec, - validationOverrides, - deployments, deploymentJobs, - Change.of(Version.fromString("6.7")).withPin(), - Change.of(ApplicationVersion.from(new SourceRevision("repo", "master", "deadcafe"), 42)), - Optional.of(IssueId.from("1234")), - Optional.of(User.from("by-username")), - OptionalInt.of(7), - new ApplicationMetrics(0.5, 0.9), - Optional.of("-----BEGIN PUBLIC KEY-----\n∠( ᐛ 」∠)_\n-----END PUBLIC KEY-----"), - List.of(AssignedRotation.fromStrings("foo", "default", "my-rotation", Set.of())), - rotationStatus); - - Application serialized = applicationSerializer.fromSlime(applicationSerializer.toSlime(original)); + Instance original = new Instance(ApplicationId.from("t1", "a1", "i1"), + Instant.now().truncatedTo(ChronoUnit.MILLIS), + deploymentSpec, + validationOverrides, + deployments, deploymentJobs, + Change.of(Version.fromString("6.7")).withPin(), + Change.of(ApplicationVersion.from(new SourceRevision("repo", "master", "deadcafe"), 42)), + Optional.of(IssueId.from("1234")), + Optional.of(User.from("by-username")), + OptionalInt.of(7), + new ApplicationMetrics(0.5, 0.9), + Optional.of("-----BEGIN PUBLIC KEY-----\n∠( ᐛ 」∠)_\n-----END PUBLIC KEY-----"), + List.of(AssignedRotation.fromStrings("foo", "default", "my-rotation", Set.of())), + rotationStatus); + + Instance serialized = applicationSerializer.fromSlime(applicationSerializer.toSlime(original)); assertEquals(original.id(), serialized.id()); assertEquals(original.createdAt(), serialized.createdAt()); @@ -183,27 +183,27 @@ public class ApplicationSerializerTest { assertEquals(original.deployments().get(zone2).metrics().instant(), serialized.deployments().get(zone2).metrics().instant()); assertEquals(original.deployments().get(zone2).metrics().warnings(), serialized.deployments().get(zone2).metrics().warnings()); { // test more deployment serialization cases - Application original2 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 42))).get(); - Application serialized2 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original2)); + Instance original2 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 42))).get(); + Instance serialized2 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original2)); assertEquals(original2.change(), serialized2.change()); assertEquals(serialized2.change().application().get().source(), original2.change().application().get().source()); - Application original3 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); - Application serialized3 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original3)); + Instance original3 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); + Instance serialized3 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original3)); assertEquals(original3.change(), serialized3.change()); assertEquals(serialized3.change().application().get().source(), original3.change().application().get().source()); - Application original4 = writable(original).withChange(Change.empty()).get(); - Application serialized4 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original4)); + Instance original4 = writable(original).withChange(Change.empty()).get(); + Instance serialized4 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original4)); assertEquals(original4.change(), serialized4.change()); - Application original5 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); - Application serialized5 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original5)); + Instance original5 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); + Instance serialized5 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original5)); assertEquals(original5.change(), serialized5.change()); - Application original6 = writable(original).withOutstandingChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); - Application serialized6 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original6)); + Instance original6 = writable(original).withOutstandingChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); + Instance serialized6 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original6)); assertEquals(original6.outstandingChange(), serialized6.outstandingChange()); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java index ea051efcd02..b8a0610bedd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java @@ -11,7 +11,7 @@ import com.yahoo.vespa.athenz.api.AthenzDomain; import com.yahoo.vespa.athenz.api.AthenzPrincipal; import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.athenz.api.OktaAccessToken; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; @@ -64,11 +64,11 @@ public class ContainerControllerTester { /** Returns the wrapped generic container tester */ public ContainerTester containerTester() { return containerTester; } - public Application createApplication() { + public Instance createApplication() { return createApplication("domain1","tenant1", "application1", "default"); } - public Application createApplication(String athensDomain, String tenant, String application, String instance) { + public Instance createApplication(String athensDomain, String tenant, String application, String instance) { AthenzDomain domain1 = addTenantAthenzDomain(athensDomain, "user"); AthenzPrincipal user = new AthenzPrincipal(new AthenzUser("user")); AthenzCredentials credentials = new AthenzCredentials(user, domain1, new OktaAccessToken("okta-token")); @@ -82,15 +82,15 @@ public class ContainerControllerTester { return controller().applications().createApplication(app, Optional.of(credentials)); } - public Application deploy(Application application, ApplicationPackage applicationPackage, ZoneId zone) { - controller().applications().deploy(application.id(), zone, Optional.of(applicationPackage), + public Instance deploy(Instance instance, ApplicationPackage applicationPackage, ZoneId zone) { + controller().applications().deploy(instance.id(), zone, Optional.of(applicationPackage), new DeployOptions(false, Optional.empty(), false, false)); - return application; + return instance; } - public void deployCompletely(Application application, ApplicationPackage applicationPackage, long projectId, + public void deployCompletely(Instance instance, ApplicationPackage applicationPackage, long projectId, boolean failStaging) { - jobCompletion(JobType.component).application(application) + jobCompletion(JobType.component).application(instance) .projectId(projectId) .uploadArtifact(applicationPackage) .submit(); @@ -99,14 +99,14 @@ public class ContainerControllerTester { for (var job : steps.jobs()) { if (!succeeding) return; var zone = job.zone(controller().system()); - deploy(application, applicationPackage, zone); + deploy(instance, applicationPackage, zone); if (failStaging && zone.environment() == Environment.staging) { succeeding = false; } if (zone.environment().isTest()) { - controller().applications().deactivate(application.id(), zone); + controller().applications().deactivate(instance.id(), zone); } - jobCompletion(job).application(application).success(succeeding).projectId(projectId).submit(); + jobCompletion(job).application(instance).success(succeeding).projectId(projectId).submit(); } } @@ -128,13 +128,13 @@ public class ContainerControllerTester { /* * Authorize action on tenantDomain/application for a given screwdriverId */ - public void authorize(AthenzDomain tenantDomain, ScrewdriverId screwdriverId, ApplicationAction action, Application application) { + public void authorize(AthenzDomain tenantDomain, ScrewdriverId screwdriverId, ApplicationAction action, Instance instance) { AthenzClientFactoryMock mock = (AthenzClientFactoryMock) containerTester.container().components() .getComponent(AthenzClientFactoryMock.class.getName()); mock.getSetup() .domains.get(tenantDomain) - .applications.get(new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(application.id().application().value())) + .applications.get(new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(instance.id().application().value())) .addRoleMember(action, HostedAthenzIdentities.from(screwdriverId)); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 8013987c772..b2494be65b1 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -21,7 +21,7 @@ import com.yahoo.vespa.athenz.api.AthenzIdentity; import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.athenz.api.OktaAccessToken; import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.LockedTenant; import com.yahoo.vespa.hosted.controller.api.application.v4.EnvironmentResource; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; @@ -1238,12 +1238,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(new AthenzDomain("another.domain"), "service"), true); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); ScrewdriverId screwdriverId = new ScrewdriverId(Long.toString(screwdriverProjectId)); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1270,12 +1270,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(ATHENZ_TENANT_DOMAIN, "service"), true); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); // Allow systemtest to succeed by notifying completion of system test controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1367,12 +1367,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(ATHENZ_TENANT_DOMAIN, "service"), false); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); // Allow systemtest to succeed by notifying completion of system test controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1404,12 +1404,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(ATHENZ_TENANT_DOMAIN, "service"), true); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); // Allow systemtest to succeed by notifying completion of system test controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1430,7 +1430,7 @@ public class ApplicationApiTest extends ControllerContainerTest { addUserToHostedOperatorRole(HostedAthenzIdentities.from(HOSTED_VESPA_OPERATOR)); tester.computeVersionStatus(); long projectId = 1; - Application app = controllerTester.createApplication(); + Instance app = controllerTester.createApplication(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -1482,7 +1482,7 @@ public class ApplicationApiTest extends ControllerContainerTest { controllerTester.containerTester().computeVersionStatus(); long projectId = 1; - Application app = controllerTester.createApplication(); + Instance app = controllerTester.createApplication(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -1511,7 +1511,7 @@ public class ApplicationApiTest extends ControllerContainerTest { @Test public void applicationWithRoutingPolicy() { - Application app = controllerTester.createApplication(); + Instance app = controllerTester.createApplication(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -1715,11 +1715,11 @@ public class ApplicationApiTest extends ControllerContainerTest { * This sets these values as if the maintainers has been ran. */ private void setDeploymentMaintainedInfo(ContainerControllerTester controllerTester) { - for (Application application : controllerTester.controller().applications().asList()) { - controllerTester.controller().applications().lockOrThrow(application.id(), lockedApplication -> { + for (Instance instance : controllerTester.controller().applications().asList()) { + controllerTester.controller().applications().lockOrThrow(instance.id(), lockedApplication -> { lockedApplication = lockedApplication.with(new ApplicationMetrics(0.5, 0.7)); - for (Deployment deployment : application.deployments().values()) { + for (Deployment deployment : instance.deployments().values()) { Map<ClusterSpec.Id, ClusterInfo> clusterInfo = new HashMap<>(); List<String> hostnames = new ArrayList<>(); hostnames.add("host1"); @@ -1752,8 +1752,8 @@ public class ApplicationApiTest extends ControllerContainerTest { new RotationStatusUpdater(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator())).run(); } - private RotationStatus rotationStatus(Application application) { - return controllerTester.controller().applications().rotationRepository().getRotation(application) + private RotationStatus rotationStatus(Instance instance) { + return controllerTester.controller().applications().rotationRepository().getRotation(instance) .map(rotation -> { var rotationStatus = controllerTester.controller().serviceRegistry().globalRoutingService().getHealthStatus(rotation.name()); var statusMap = new LinkedHashMap<ZoneId, RotationState>(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java index 35ec5b0e37e..09555dd9f2e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.restapi.deployment; import com.yahoo.config.provision.AthenzService; import com.yahoo.config.provision.Environment; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -20,13 +20,13 @@ public class BadgeApiTest extends ControllerContainerTest { @Test public void testBadgeApi() { ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles); - Application application = tester.createApplication("domain", "tenant", "application", "default"); + Instance instance = tester.createApplication("domain", "tenant", "application", "default"); ApplicationPackage packageWithService = new ApplicationPackageBuilder() .environment(Environment.prod) .athenzIdentity(com.yahoo.config.provision.AthenzDomain.from("domain"), AthenzService.from("service")) .region("us-west-1") .build(); - tester.controller().jobController().submit(application.id(), + tester.controller().jobController().submit(instance.id(), new SourceRevision("repository", "branch", "commit"), "foo@bar", 123, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java index d6620733efe..adf48ea37cb 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java @@ -6,7 +6,7 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -39,15 +39,15 @@ public class DeploymentApiTest extends ControllerContainerTest { .build(); // 3 applications deploy on current system version - Application failingApplication = tester.createApplication("domain1", "tenant1", "application1", "default"); - Application productionApplication = tester.createApplication("domain2", "tenant2", "application2", "default"); - Application applicationWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3", "default"); - tester.deployCompletely(failingApplication, applicationPackage, 1L, false); - tester.deployCompletely(productionApplication, applicationPackage, 2L, false); + Instance failingInstance = tester.createApplication("domain1", "tenant1", "application1", "default"); + Instance productionInstance = tester.createApplication("domain2", "tenant2", "application2", "default"); + Instance instanceWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3", "default"); + tester.deployCompletely(failingInstance, applicationPackage, 1L, false); + tester.deployCompletely(productionInstance, applicationPackage, 2L, false); // Deploy once so that job information is stored, then remove the deployment - tester.deployCompletely(applicationWithoutDeployment, applicationPackage, 3L, false); - tester.controller().applications().deactivate(applicationWithoutDeployment.id(), ZoneId.from("prod", "us-west-1")); + tester.deployCompletely(instanceWithoutDeployment, applicationPackage, 3L, false); + tester.controller().applications().deactivate(instanceWithoutDeployment.id(), ZoneId.from("prod", "us-west-1")); // New version released version = Version.fromString("5.1"); @@ -57,8 +57,8 @@ public class DeploymentApiTest extends ControllerContainerTest { tester.upgrader().maintain(); tester.controller().applications().deploymentTrigger().triggerReadyJobs(); tester.controller().applications().deploymentTrigger().triggerReadyJobs(); - tester.deployCompletely(failingApplication, applicationPackage, 1L, true); - tester.deployCompletely(productionApplication, applicationPackage, 2L, false); + tester.deployCompletely(failingInstance, applicationPackage, 1L, true); + tester.deployCompletely(productionInstance, applicationPackage, 2L, false); tester.controller().updateVersionStatus(censorConfigServers(VersionStatus.compute(tester.controller()), tester.controller())); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java index 4e93922784e..78f36fdf4a3 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.rotation; import com.yahoo.config.provision.SystemName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.AssignedRotation; @@ -50,27 +50,27 @@ public class RotationRepositoryTest { private DeploymentTester tester; private RotationRepository repository; - private Application application; + private Instance instance; @Before public void before() { tester = new DeploymentTester(new ControllerTester(rotationsConfig)); repository = tester.controller().applications().rotationRepository(); - application = tester.createApplication("app1", "tenant1", 11L,1L); + instance = tester.createApplication("app1", "tenant1", 11L, 1L); } @Test public void assigns_and_reuses_rotation() { // Deploying assigns a rotation - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); Rotation expected = new Rotation(new RotationId("foo-1"), "foo-1.com"); - application = tester.applications().require(application.id()); - assertEquals(List.of(expected.id()), rotationIds(application.rotations())); + instance = tester.applications().require(instance.id()); + assertEquals(List.of(expected.id()), rotationIds(instance.rotations())); assertEquals(URI.create("https://app1--tenant1.global.vespa.oath.cloud:4443/"), - application.endpointsIn(SystemName.main).main().get().url()); + instance.endpointsIn(SystemName.main).main().get().url()); try (RotationLock lock = repository.lock()) { - Rotation rotation = repository.getOrAssignRotation(tester.applications().require(application.id()), lock); + Rotation rotation = repository.getOrAssignRotation(tester.applications().require(instance.id()), lock); assertEquals(expected, rotation); } @@ -81,21 +81,21 @@ public class RotationRepositoryTest { .region("us-west-1") .searchDefinition("search foo { }") // Update application package so there is something to deploy .build(); - tester.deployCompletely(application, applicationPackage, 43); - assertEquals(List.of(expected.id()), rotationIds(tester.applications().require(application.id()).rotations())); + tester.deployCompletely(instance, applicationPackage, 43); + assertEquals(List.of(expected.id()), rotationIds(tester.applications().require(instance.id()).rotations())); } @Test public void strips_whitespace_in_rotation_fqdn() { DeploymentTester tester = new DeploymentTester(new ControllerTester(rotationsConfigWhitespaces)); RotationRepository repository = tester.controller().applications().rotationRepository(); - Application application = tester.createApplication("app2", "tenant2", 22L, - 2L); - tester.deployCompletely(application, applicationPackage); - application = tester.applications().require(application.id()); + Instance instance = tester.createApplication("app2", "tenant2", 22L, + 2L); + tester.deployCompletely(instance, applicationPackage); + instance = tester.applications().require(instance.id()); try (RotationLock lock = repository.lock()) { - Rotation rotation = repository.getOrAssignRotation(application, lock); + Rotation rotation = repository.getOrAssignRotation(instance, lock); Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com"); assertEquals(assignedRotation, rotation); } @@ -104,19 +104,19 @@ public class RotationRepositoryTest { @Test public void out_of_rotations() { // Assigns 1 rotation - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Assigns 1 more - Application application2 = tester.createApplication("app2", "tenant2", 22L, - 2L); - tester.deployCompletely(application2, applicationPackage); + Instance instance2 = tester.createApplication("app2", "tenant2", 22L, + 2L); + tester.deployCompletely(instance2, applicationPackage); // We're now out of rotations thrown.expect(IllegalStateException.class); thrown.expectMessage("no rotations available"); - Application application3 = tester.createApplication("app3", "tenant3", 33L, - 3L); - tester.deployCompletely(application3, applicationPackage); + Instance instance3 = tester.createApplication("app3", "tenant3", 33L, + 3L); + tester.deployCompletely(instance3, applicationPackage); } @Test @@ -125,11 +125,11 @@ public class RotationRepositoryTest { .globalServiceId("foo") .region("us-east-3") .build(); - Application application = tester.createApplication("app2", "tenant2", 22L, - 2L); + Instance instance = tester.createApplication("app2", "tenant2", 22L, + 2L); thrown.expect(RuntimeException.class); thrown.expectMessage("less than 2 prod zones are defined"); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); } @Test @@ -138,8 +138,8 @@ public class RotationRepositoryTest { .region("us-east-3") .region("us-west-1") .build(); - tester.deployCompletely(application, applicationPackage); - Application app = tester.applications().require(application.id()); + tester.deployCompletely(instance, applicationPackage); + Instance app = tester.applications().require(instance.id()); assertTrue(app.rotations().isEmpty()); } @@ -150,11 +150,11 @@ public class RotationRepositoryTest { .region("us-east-3") .region("us-west-1") .build(); - Application application = tester.createApplication("app2", "tenant2", 22L, - 2L); - tester.deployCompletely(application, applicationPackage); - assertEquals(List.of(new RotationId("foo-1")), rotationIds(tester.applications().require(application.id()).rotations())); - assertEquals("https://cd--app2--tenant2.global.vespa.oath.cloud:4443/", tester.applications().require(application.id()) + Instance instance = tester.createApplication("app2", "tenant2", 22L, + 2L); + tester.deployCompletely(instance, applicationPackage); + assertEquals(List.of(new RotationId("foo-1")), rotationIds(tester.applications().require(instance.id()).rotations())); + assertEquals("https://cd--app2--tenant2.global.vespa.oath.cloud:4443/", tester.applications().require(instance.id()) .endpointsIn(SystemName.cd).main().get().url().toString()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java index 94201832adb..3d12fe382ce 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java @@ -7,7 +7,7 @@ import com.yahoo.component.Vtag; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneApi; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; @@ -135,9 +135,9 @@ public class VersionStatusTest { tester.upgradeSystem(version1); // Setup applications - Application app1 = tester.createAndDeploy("app1", 11, applicationPackage); - Application app2 = tester.createAndDeploy("app2", 22, applicationPackage); - Application app3 = tester.createAndDeploy("app3", 33, applicationPackage); + Instance app1 = tester.createAndDeploy("app1", 11, applicationPackage); + Instance app2 = tester.createAndDeploy("app2", 22, applicationPackage); + Instance app3 = tester.createAndDeploy("app3", 33, applicationPackage); // version2 is released tester.upgradeSystem(version2); @@ -175,25 +175,25 @@ public class VersionStatusTest { tester.upgradeSystem(version0); // Setup applications - all running on version0 - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application canary2 = tester.createAndDeploy("canary2", 3, "canary"); - Application default0 = tester.createAndDeploy("default0", 4, "default"); - Application default1 = tester.createAndDeploy("default1", 5, "default"); - Application default2 = tester.createAndDeploy("default2", 6, "default"); - Application default3 = tester.createAndDeploy("default3", 7, "default"); - Application default4 = tester.createAndDeploy("default4", 8, "default"); - Application default5 = tester.createAndDeploy("default5", 9, "default"); - Application default6 = tester.createAndDeploy("default6", 10, "default"); - Application default7 = tester.createAndDeploy("default7", 11, "default"); - Application default8 = tester.createAndDeploy("default8", 12, "default"); - Application default9 = tester.createAndDeploy("default9", 13, "default"); - Application conservative0 = tester.createAndDeploy("conservative1", 14, "conservative"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance canary2 = tester.createAndDeploy("canary2", 3, "canary"); + Instance default0 = tester.createAndDeploy("default0", 4, "default"); + Instance default1 = tester.createAndDeploy("default1", 5, "default"); + Instance default2 = tester.createAndDeploy("default2", 6, "default"); + Instance default3 = tester.createAndDeploy("default3", 7, "default"); + Instance default4 = tester.createAndDeploy("default4", 8, "default"); + Instance default5 = tester.createAndDeploy("default5", 9, "default"); + Instance default6 = tester.createAndDeploy("default6", 10, "default"); + Instance default7 = tester.createAndDeploy("default7", 11, "default"); + Instance default8 = tester.createAndDeploy("default8", 12, "default"); + Instance default9 = tester.createAndDeploy("default9", 13, "default"); + Instance conservative0 = tester.createAndDeploy("conservative1", 14, "conservative"); // Applications that do not affect confidence calculation: // Application without deployment - Application ignored0 = tester.createApplication("ignored0", "tenant1", 1000, 1000L); + Instance ignored0 = tester.createApplication("ignored0", "tenant1", 1000, 1000L); assertEquals("All applications running on this version: High", Confidence.high, confidence(tester.controller(), version0)); @@ -310,7 +310,7 @@ public class VersionStatusTest { tester.upgradeSystem(version0); // Create and deploy application on current version - Application app = tester.createAndDeploy("app", 1, "canary"); + Instance app = tester.createAndDeploy("app", 1, "canary"); tester.computeVersionStatus(); assertEquals(Confidence.high, confidence(tester.controller(), version0)); @@ -368,9 +368,9 @@ public class VersionStatusTest { assertEquals(5, tester.hourOfDayAfter(Duration.ZERO)); Version version0 = Version.fromString("7.1"); tester.upgradeSystem(version0); - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 1, "canary"); - Application default0 = tester.createAndDeploy("default0", 1, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 1, "canary"); + Instance default0 = tester.createAndDeploy("default0", 1, "default"); tester.computeVersionStatus(); assertSame(Confidence.high, tester.controller().versionStatus().version(version0).confidence()); |