Search in sources :

Example 81 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class IdentityDocumentGeneratorTest method generates_valid_identity_document.

@Test
public void generates_valid_identity_document() throws Exception {
    String hostname = "x.y.com";
    ApplicationId appid = ApplicationId.from(TenantName.from("tenant"), ApplicationName.from("application"), InstanceName.from("default"));
    Allocation allocation = new Allocation(appid, ClusterMembership.from("container/default/0/0", Version.fromString("1.2.3")), Generation.inital(), false);
    Node n = Node.create("ostkid", ImmutableSet.of("127.0.0.1"), new HashSet<>(), hostname, Optional.empty(), new MockNodeFlavors().getFlavorOrThrow("default"), NodeType.tenant).with(allocation);
    NodeRepository nodeRepository = mock(NodeRepository.class);
    when(nodeRepository.getNode(eq(hostname))).thenReturn(Optional.of(n));
    AutoGeneratedKeyProvider keyProvider = new AutoGeneratedKeyProvider();
    String dnsSuffix = "vespa.dns.suffix";
    AthenzProviderServiceConfig config = getAthenzProviderConfig("domain", "service", dnsSuffix, ZONE);
    IdentityDocumentGenerator identityDocumentGenerator = new IdentityDocumentGenerator(config, nodeRepository, ZONE, keyProvider);
    SignedIdentityDocument signedIdentityDocument = identityDocumentGenerator.generateSignedIdentityDocument(hostname);
    // Verify attributes
    assertEquals(hostname, signedIdentityDocument.identityDocument.instanceHostname);
    String environment = "dev";
    String region = "us-north-1";
    String expectedZoneDnsSuffix = environment + "-" + region + "." + dnsSuffix;
    assertEquals(expectedZoneDnsSuffix, signedIdentityDocument.dnsSuffix);
    ProviderUniqueId expectedProviderUniqueId = new ProviderUniqueId("tenant", "application", environment, region, "default", "default", 0);
    assertEquals(expectedProviderUniqueId, signedIdentityDocument.identityDocument.providerUniqueId);
    // Validate signature
    assertTrue("Message", InstanceValidator.isSignatureValid(keyProvider.getPublicKey(0), signedIdentityDocument.rawIdentityDocument, signedIdentityDocument.signature));
}
Also used : MockNodeFlavors(com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors) Allocation(com.yahoo.vespa.hosted.provision.node.Allocation) Node(com.yahoo.vespa.hosted.provision.Node) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) AutoGeneratedKeyProvider(com.yahoo.vespa.hosted.athenz.instanceproviderservice.AutoGeneratedKeyProvider) AthenzProviderServiceConfig(com.yahoo.vespa.hosted.athenz.instanceproviderservice.config.AthenzProviderServiceConfig) ApplicationId(com.yahoo.config.provision.ApplicationId) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 82 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class ApplicationRepository method verifyTenantAndApplication.

public Tenant verifyTenantAndApplication(ApplicationId applicationId) {
    TenantName tenantName = applicationId.tenant();
    if (!tenants.checkThatTenantExists(tenantName)) {
        throw new IllegalArgumentException("Tenant " + tenantName + " was not found.");
    }
    Tenant tenant = tenants.getTenant(tenantName);
    List<ApplicationId> applicationIds = listApplicationIds(tenant);
    if (!applicationIds.contains(applicationId)) {
        throw new IllegalArgumentException("No such application id: " + applicationId);
    }
    return tenant;
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 83 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class ApplicationRepository method redeployAllApplications.

void redeployAllApplications() throws InterruptedException {
    ExecutorService executor = Executors.newFixedThreadPool(configserverConfig.numParallelTenantLoaders(), new DaemonThreadFactory("redeploy apps"));
    // Keep track of deployment per application
    Map<ApplicationId, Future<?>> futures = new HashMap<>();
    tenants.getAllTenants().forEach(tenant -> listApplicationIds(tenant).forEach(appId -> deployFromLocalActive(appId).ifPresent(deployment -> futures.put(appId, executor.submit(deployment::activate)))));
    for (Map.Entry<ApplicationId, Future<?>> f : futures.entrySet()) {
        try {
            f.getValue().get();
        } catch (ExecutionException e) {
            throw new RuntimeException("Redeploying of " + f.getKey() + " failed", e);
        }
    }
    executor.shutdown();
    // Timeout should never happen
    executor.awaitTermination(365, TimeUnit.DAYS);
}
Also used : ApplicationMetaData(com.yahoo.config.application.api.ApplicationMetaData) FileDistributionStatus(com.yahoo.vespa.config.server.application.FileDistributionStatus) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) Inject(com.google.inject.Inject) Vtag(com.yahoo.component.Vtag) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) DeployLogger(com.yahoo.config.application.api.DeployLogger) TenantName(com.yahoo.config.provision.TenantName) LogServerLogGrabber(com.yahoo.vespa.config.server.application.LogServerLogGrabber) Future(java.util.concurrent.Future) Path(com.yahoo.path.Path) Rotations(com.yahoo.vespa.config.server.tenant.Rotations) Provisioner(com.yahoo.config.provision.Provisioner) Duration(java.time.Duration) Map(java.util.Map) LogLevel(com.yahoo.log.LogLevel) CompressedApplicationInputStream(com.yahoo.vespa.config.server.http.CompressedApplicationInputStream) URI(java.net.URI) Application(com.yahoo.vespa.config.server.application.Application) Instant(java.time.Instant) Logger(java.util.logging.Logger) Executors(java.util.concurrent.Executors) HostFilter(com.yahoo.config.provision.HostFilter) RestartActions(com.yahoo.vespa.config.server.configchange.RestartActions) List(java.util.List) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) Optional(java.util.Optional) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) HttpResponse(com.yahoo.container.jdisc.HttpResponse) ConfigChangeActions(com.yahoo.vespa.config.server.configchange.ConfigChangeActions) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) Slime(com.yahoo.slime.Slime) DaemonThreadFactory(com.yahoo.concurrent.DaemonThreadFactory) Tenant(com.yahoo.vespa.config.server.tenant.Tenant) HashMap(java.util.HashMap) IOUtils(com.yahoo.io.IOUtils) TenantApplications(com.yahoo.vespa.config.server.application.TenantApplications) ApplicationConvergenceChecker(com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker) Level(java.util.logging.Level) RefeedActions(com.yahoo.vespa.config.server.configchange.RefeedActions) Files(com.google.common.io.Files) NestedTransaction(com.yahoo.transaction.NestedTransaction) PrepareParams(com.yahoo.vespa.config.server.session.PrepareParams) ExecutorService(java.util.concurrent.ExecutorService) HttpProxy(com.yahoo.vespa.config.server.application.HttpProxy) PrepareResult(com.yahoo.vespa.config.server.http.v2.PrepareResult) SilentDeployLogger(com.yahoo.vespa.config.server.session.SilentDeployLogger) LocalSessionRepo(com.yahoo.vespa.config.server.session.LocalSessionRepo) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet) Environment(com.yahoo.config.provision.Environment) IOException(java.io.IOException) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) SessionFactory(com.yahoo.vespa.config.server.session.SessionFactory) File(java.io.File) Deployment(com.yahoo.vespa.config.server.deploy.Deployment) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) SimpleHttpFetcher(com.yahoo.vespa.config.server.http.SimpleHttpFetcher) Clock(java.time.Clock) Session(com.yahoo.vespa.config.server.session.Session) InputStream(java.io.InputStream) HashMap(java.util.HashMap) DaemonThreadFactory(com.yahoo.concurrent.DaemonThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) ApplicationId(com.yahoo.config.provision.ApplicationId) ExecutionException(java.util.concurrent.ExecutionException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 84 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class SessionZooKeeperClientTest method assertApplicationIdParse.

private void assertApplicationIdParse(String sessionId, String idString, String expectedIdString) {
    SessionZooKeeperClient zkc = createSessionZKClient(sessionId);
    String path = "/" + sessionId + "/" + SessionZooKeeperClient.APPLICATION_ID_PATH;
    configCurator.putData(path, idString);
    ApplicationId zkId = zkc.readApplicationId();
    assertThat(zkId.serializedForm(), is(expectedIdString));
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 85 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class SessionZooKeeperClientTest method require_that_application_id_is_read_from_zk.

@Test
public void require_that_application_id_is_read_from_zk() {
    ApplicationId id = new ApplicationId.Builder().tenant("tenant").applicationName("bar").instanceName("quux").build();
    String idNoVersion = id.serializedForm();
    assertApplicationIdParse("3", idNoVersion, idNoVersion);
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)173 Test (org.junit.Test)102 Zone (com.yahoo.config.provision.Zone)52 Node (com.yahoo.vespa.hosted.provision.Node)30 ClusterSpec (com.yahoo.config.provision.ClusterSpec)22 TenantName (com.yahoo.config.provision.TenantName)20 Flavor (com.yahoo.config.provision.Flavor)19 List (java.util.List)16 HashSet (java.util.HashSet)15 HostSpec (com.yahoo.config.provision.HostSpec)12 Duration (java.time.Duration)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Set (java.util.Set)12 Collectors (java.util.stream.Collectors)12 Version (com.yahoo.component.Version)11 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)11 Slime (com.yahoo.slime.Slime)11 ArrayList (java.util.ArrayList)11 Optional (java.util.Optional)11