diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-05-26 19:41:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-26 19:41:55 +0200 |
commit | aefd666d6f39a37c5ca050cd4a410385b9651347 (patch) | |
tree | d72a4c8ba15c6042094bc171b215a2dd97e49889 /configserver | |
parent | f569c7e22d2519b10c2195af632ef9463d7aee94 (diff) |
Revert "Set status failed when we do not get a deployment when bootstrapping …"
Diffstat (limited to 'configserver')
6 files changed, 24 insertions, 30 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 937f9c05033..d1cf011d33a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -408,7 +408,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye Tenant tenant = tenantRepository.getTenant(application.tenant()); if (tenant == null) return Optional.empty(); - Session activeSession = getActiveLocalSession(application); + Session activeSession = getActiveLocalSession(tenant, application); if (activeSession == null) return Optional.empty(); TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout); SessionRepository sessionRepository = tenant.getSessionRepository(); @@ -1063,12 +1063,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye return null; } - public Session getActiveLocalSession(ApplicationId applicationId) { - Tenant tenant = tenantRepository.getTenant(applicationId.tenant()); - if (tenant == null) throw new IllegalArgumentException("Unknown tenant " + applicationId.tenant()); - return getActiveLocalSession(tenant, applicationId); - } - public double getQuotaUsageRate(ApplicationId applicationId) { var application = getApplication(applicationId); return application.getModel().provisioned().all().values().stream() diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java index 216ded4fec0..772c2bf5125 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigServerBootstrap.java @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -227,22 +226,13 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable ExecutorService executor = Executors.newFixedThreadPool(configserverConfig.numRedeploymentThreads(), new DaemonThreadFactory("redeploy-apps-")); // Keep track of deployment status per application - Map<ApplicationId, Future<DeploymentStatus>> deployments = new HashMap<>(); + Map<ApplicationId, Future<?>> deployments = new HashMap<>(); log.log(Level.INFO, () -> "Redeploying " + applicationIds.size() + " apps: " + applicationIds); applicationIds.forEach(appId -> deployments.put(appId, executor.submit(() -> { log.log(Level.INFO, () -> "Starting redeployment of " + appId); - Optional<Deployment> deployment = applicationRepository.deployFromLocalActive(appId, true /* bootstrap */); - if (deployment.isPresent()) { - deployment.get().activate(); - log.log(Level.INFO, () -> appId + " redeployed"); - return DeploymentStatus.done; - } else { - // For some reason a deployment is not present, which should not be possible when bootstrapping - log.log(Level.WARNING, () -> "Deployment failed for " + appId + - ", unable to get a deployment, active local session is " + - applicationRepository.getActiveLocalSession(appId)); - return DeploymentStatus.failed; - } + applicationRepository.deployFromLocalActive(appId, true /* bootstrap */) + .ifPresent(Deployment::activate); + log.log(Level.INFO, () -> appId + " redeployed"); }))); List<ApplicationId> failedDeployments = checkDeployments(deployments); @@ -255,7 +245,7 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable private enum DeploymentStatus { inProgress, done, failed}; - private List<ApplicationId> checkDeployments(Map<ApplicationId, Future<DeploymentStatus>> deployments) { + private List<ApplicationId> checkDeployments(Map<ApplicationId, Future<?>> deployments) { int applicationCount = deployments.size(); Set<ApplicationId> failedDeployments = new LinkedHashSet<>(); Set<ApplicationId> finishedDeployments = new LinkedHashSet<>(); @@ -289,9 +279,10 @@ public class ConfigServerBootstrap extends AbstractComponent implements Runnable return new ArrayList<>(failedDeployments); } - private DeploymentStatus getDeploymentStatus(ApplicationId applicationId, Future<DeploymentStatus> future) { + private DeploymentStatus getDeploymentStatus(ApplicationId applicationId, Future<?> future) { try { - return future.get(1, TimeUnit.MILLISECONDS); + future.get(1, TimeUnit.MILLISECONDS); + return DeploymentStatus.done; } catch (ExecutionException | InterruptedException e) { if (e.getCause() instanceof TransientException) { log.log(Level.INFO, "Redeploying " + applicationId + diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index 736940366e8..eff663588a9 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -154,7 +154,8 @@ public class ApplicationRepositoryTest { assertTrue(result.configChangeActions().getReindexActions().isEmpty()); assertTrue(result.configChangeActions().getRestartActions().isEmpty()); - Session session = applicationRepository.getActiveLocalSession(applicationId()); + Tenant tenant = applicationRepository.getTenant(applicationId()); + Session session = applicationRepository.getActiveLocalSession(tenant, applicationId()); session.getAllocatedHosts(); } @@ -226,7 +227,8 @@ public class ApplicationRepositoryTest { long secondSessionId = result2.sessionId(); assertNotEquals(firstSessionId, secondSessionId); - Session session = applicationRepository.getActiveLocalSession(applicationId()); + Tenant tenant = applicationRepository.getTenant(applicationId()); + Session session = applicationRepository.getActiveLocalSession(tenant, applicationId()); assertEquals(firstSessionId, session.getMetaData().getPreviousActiveGeneration()); } @@ -529,7 +531,8 @@ public class ApplicationRepositoryTest { public void require_that_provision_info_can_be_read() { prepareAndActivate(testAppJdiscOnly); - Session session = applicationRepository.getActiveLocalSession(applicationId()); + Tenant tenant = applicationRepository.getTenant(applicationId()); + Session session = applicationRepository.getActiveLocalSession(tenant, applicationId()); List<NetworkPorts.Allocation> list = new ArrayList<>(); list.add(new NetworkPorts.Allocation(8080, "container", "container/container.0", "http")); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java index 561c726bad0..1142c756f94 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java @@ -14,6 +14,7 @@ import com.yahoo.vespa.config.server.application.OrchestratorMock; import com.yahoo.vespa.config.server.http.ContentHandlerTestBase; import com.yahoo.vespa.config.server.session.PrepareParams; import com.yahoo.vespa.config.server.session.Session; +import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.tenant.TestTenantRepository; import org.junit.Before; @@ -104,7 +105,8 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase { @Test public void require_that_get_does_not_set_write_flag() throws IOException { - Session session = applicationRepository.getActiveLocalSession(appId1); + Tenant tenant1 = applicationRepository.getTenant(appId1); + Session session = applicationRepository.getActiveLocalSession(tenant1, appId1); assertContent("/test.txt", "foo\n"); assertThat(session.getStatus(), is(Session.Status.ACTIVATE)); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java index c3196fdeaa6..a51346148d2 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java @@ -20,6 +20,7 @@ import com.yahoo.vespa.config.server.model.TestModelFactory; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.session.PrepareParams; import com.yahoo.vespa.config.server.session.Session; +import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.tenant.TestTenantRepository; import com.yahoo.vespa.model.VespaModelFactory; @@ -137,7 +138,8 @@ public class SessionActiveHandlerTest { testApp); applicationRepository.prepare(sessionId, new PrepareParams.Builder().applicationId(applicationId()).build()); actResponse = handler.handle(createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.ACTIVE, sessionId, subPath)); - Session session = applicationRepository.getActiveLocalSession(applicationId()); + Tenant tenant = applicationRepository.getTenant(applicationId()); + Session session = applicationRepository.getActiveLocalSession(tenant, applicationId()); metaData = session.getMetaData(); this.sessionId = sessionId; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java index 3e7addedddc..0d4af43d3ba 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java @@ -16,6 +16,7 @@ import com.yahoo.vespa.config.server.application.OrchestratorMock; import com.yahoo.vespa.config.server.http.ContentHandlerTestBase; import com.yahoo.vespa.config.server.http.SessionHandlerTest; import com.yahoo.vespa.config.server.session.PrepareParams; +import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.tenant.TestTenantRepository; import org.junit.Before; @@ -68,7 +69,8 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase { .withConfigserverConfig(configserverConfig) .build(); applicationRepository.deploy(testApp, new PrepareParams.Builder().applicationId(applicationId()).build()); - sessionId = applicationRepository.getActiveLocalSession(applicationId()).getSessionId(); + Tenant tenant = applicationRepository.getTenant(applicationId()); + sessionId = applicationRepository.getActiveLocalSession(tenant, applicationId()).getSessionId(); handler = createHandler(); pathPrefix = "/application/v2/tenant/" + tenantName + "/session/"; |