diff options
author | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-07-11 13:45:17 +0200 |
---|---|---|
committer | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-07-11 13:45:17 +0200 |
commit | 9549a8005480a3fe61fb087e359a4a442180819f (patch) | |
tree | e76ded2ddf9a8127cd780304105313c22640c8dc /controller-api/src/main | |
parent | 9f3a3b9f6962bd20714b99a046860de1886be600 (diff) | |
parent | 1c79079945c56fa91de8427fbc8f2170eec9ed8c (diff) |
Merge remote-tracking branch 'origin/master' into olaa/cfg-server-metric-aggregation
Conflicts:
configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java
controller-server/src/main/java/com/yahoo/vespa/hosted/controller/LockedApplication.java
controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java
Diffstat (limited to 'controller-api/src/main')
44 files changed, 431 insertions, 1285 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java index ebcebd994d1..5c279547e17 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java @@ -1,7 +1,9 @@ // 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.api.application.v4.model; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch; import com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit; import com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository; @@ -17,6 +19,7 @@ import java.util.List; @JsonIgnoreProperties(ignoreUnknown = true) public class InstanceInformation { public List<URI> serviceUrls; + public List<Endpoint> endpoints; public URI nodes; public URI yamasUrl; public RevisionId revision; @@ -27,4 +30,28 @@ public class InstanceInformation { public GitRepository gitRepository; public GitBranch gitBranch; public GitCommit gitCommit; + + public static class Endpoint { + public String cluster; + public boolean tls; + public URI url; + + @JsonCreator + public Endpoint(@JsonProperty("cluster") String cluster , + @JsonProperty("tls") boolean tls, + @JsonProperty("url") URI url) { + this.cluster = cluster; + this.tls = tls; + this.url = url; + } + + @Override + public String toString() { + return "Endpoint {" + + "cluster=" + cluster+ + ", tls='" + tls + '\'' + + ", url='" + url+ '\'' + + '}'; + } + } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantType.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantType.java index 9f89da717be..0f04a31a9ed 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantType.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantType.java @@ -6,5 +6,6 @@ package com.yahoo.vespa.hosted.controller.api.application.v4.model; */ public enum TenantType { USER, - ATHENS + ATHENS, + CLOUD } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/ApplicationCertificate.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/ApplicationCertificate.java index e4d0c8246d9..dbcb44d1711 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/ApplicationCertificate.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/ApplicationCertificate.java @@ -1,29 +1,36 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.certificates; -import java.security.cert.X509Certificate; -import java.util.List; +import java.util.Objects; /** - * Represents a certificate chain and a reference to the private key used for generating the certificate + * Represents a reference to a certificate and private key. * * @author mortent * @author andreer */ public class ApplicationCertificate { - private final List<X509Certificate> certificateChain; - private final KeyId keyId; - public ApplicationCertificate(List<X509Certificate> certificateChain, KeyId keyId) { - this.certificateChain = certificateChain; - this.keyId = keyId; + private final String secretsKeyNamePrefix; + + public ApplicationCertificate(String secretsKeyNamePrefix) { + this.secretsKeyNamePrefix = secretsKeyNamePrefix; + } + + public String secretsKeyNamePrefix() { + return secretsKeyNamePrefix; } - public List<X509Certificate> certificateChain() { - return certificateChain; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ApplicationCertificate that = (ApplicationCertificate) o; + return Objects.equals(secretsKeyNamePrefix, that.secretsKeyNamePrefix); } - public KeyId keyId() { - return keyId; + @Override + public int hashCode() { + return Objects.hash(secretsKeyNamePrefix); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/ApplicationCertificateProvider.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/ApplicationCertificateProvider.java new file mode 100644 index 00000000000..fa489a6b754 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/ApplicationCertificateProvider.java @@ -0,0 +1,12 @@ +package com.yahoo.vespa.hosted.controller.api.integration.certificates; + +import com.yahoo.config.provision.ApplicationId; + +/** + * Generates a certificate. + * + * @author andreer + */ +public interface ApplicationCertificateProvider { + ApplicationCertificate requestCaSignedCertificate(ApplicationId applicationId); +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/CertificateProvider.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/CertificateProvider.java deleted file mode 100644 index d2462eb574f..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/CertificateProvider.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.yahoo.vespa.hosted.controller.api.integration.certificates; - -import java.security.KeyPair; -import java.security.cert.X509Certificate; -import java.util.List; - -/** - * Generates a certificate. - * - * @author andreer - */ -public interface CertificateProvider { - List<X509Certificate> requestCaSignedCertificate(KeyPair keyPair, List<String> domains); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/KeyId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/KeyId.java deleted file mode 100644 index 3ab22d4a5b7..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/KeyId.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.certificates; - -/** - * Identifier for a key pair. Used for persisting/retrieving a key pair. - * - * @author mortent - * @author andreer - */ -public class KeyId { - private final String name; - private final int version; - - public KeyId(String name, int version) { - this.name = name; - this.version = version; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/KeyPairProvider.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/KeyPairProvider.java deleted file mode 100644 index a872bf63343..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/KeyPairProvider.java +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.certificates; - -import com.yahoo.config.provision.ApplicationId; - -/** - * Provides a key pair. Generates and persists the key pair if not found. - * - * @author mortent - * @author andreer - */ -public interface KeyPairProvider { - VersionedKeyPair getKeyPair(ApplicationId applicationId); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/VersionedKeyPair.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/VersionedKeyPair.java deleted file mode 100644 index c95303b9497..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/VersionedKeyPair.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.certificates; - -import java.security.KeyPair; - -/** - * Represents a key pair and an unique persistence identifier - * - * @author mortent - * @author andreer - */ -public class VersionedKeyPair { - private final KeyId keyId; - private final KeyPair keyPair; - - public VersionedKeyPair(KeyId keyId, KeyPair keyPair) { - this.keyId = keyId; - this.keyPair = keyPair; - } - - public KeyId keyId() { - return keyId; - } - - public KeyPair keyPair() { - return keyPair; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/package-info.java new file mode 100644 index 00000000000..0ba13524d33 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/package-info.java @@ -0,0 +1,5 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +@ExportPackage +package com.yahoo.vespa.hosted.controller.api.integration.certificates; + +import com.yahoo.osgi.annotation.ExportPackage;
\ No newline at end of file diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/AttributeMapping.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/AttributeMapping.java deleted file mode 100644 index 87970458855..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/AttributeMapping.java +++ /dev/null @@ -1,35 +0,0 @@ -// 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.api.integration.chef; - -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author mortent - */ -public class AttributeMapping { - - private final String attribute; - private final List<String> chefPath; - - private AttributeMapping(String attribute, List<String> chefPath) { - this.chefPath = chefPath; - this.attribute = attribute; - } - - public static AttributeMapping simpleMapping(String attribute) { - return new AttributeMapping(attribute, Collections.singletonList(attribute)); - } - - public static AttributeMapping deepMapping(String attribute, List<String> chefPath) { - return new AttributeMapping(attribute, chefPath); - } - - public String toString() { - return String.format("\"%s\": [%s]", attribute, - chefPath.stream().map(s -> String.format("\"%s\"", s)) - .collect(Collectors.joining(",")) - ); - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/Chef.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/Chef.java deleted file mode 100644 index 693947b6f61..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/Chef.java +++ /dev/null @@ -1,42 +0,0 @@ -// 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.api.integration.chef; - - -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.ChefEnvironment; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.ChefNode; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.ChefResource; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.Client; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.CookBook; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.NodeResult; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNodeResult; - -import java.net.URL; -import java.util.List; - -public interface Chef { - - ChefResource getApi(); - - ChefNode getNode(String name); - - Client getClient(String name); - - ChefNode deleteNode(String name); - - Client deleteClient(String name); - - NodeResult searchNodeByFQDN(String fqdn); - - NodeResult searchNodes(String query); - - PartialNodeResult partialSearchNodes(String query, List<AttributeMapping> attributeMappings); - - void copyChefEnvironment(String fromEnvironmentName, String toEnvironmentName); - - ChefEnvironment getChefEnvironment(String environmentName); - - CookBook getCookbook(String cookbookName, String cookbookVersion); - - String downloadResource(URL resourceURL); - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/ChefMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/ChefMock.java deleted file mode 100644 index bd19cfe6ce1..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/ChefMock.java +++ /dev/null @@ -1,122 +0,0 @@ -// 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.api.integration.chef; - -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.ChefEnvironment; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.ChefNode; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.ChefResource; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.Client; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.CookBook; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.NodeResult; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNode; -import com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNodeResult; - -import javax.ws.rs.NotFoundException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author mpolden - */ -public class ChefMock implements Chef { - - private final NodeResult result; - private final PartialNodeResult partialResult; - private final List<String> chefEnvironments; - - public ChefMock() { - result = new NodeResult(); - result.rows = new ArrayList<>(); - partialResult = new PartialNodeResult(); - partialResult.rows = new ArrayList<>(); - chefEnvironments = new ArrayList<>(); - chefEnvironments.add("hosted-verified-prod"); - chefEnvironments.add("hosted-infra-cd"); - } - - @Override - public ChefResource getApi() { - return null; - } - - @Override - public ChefNode getNode(String name) { - return null; - } - - @Override - public Client getClient(String name) { - return null; - } - - @Override - public ChefNode deleteNode(String name) { - return null; - } - - @Override - public Client deleteClient(String name) { - return null; - } - - public ChefMock addSearchResult(ChefNode node) { - result.rows.add(node); - return this; - } - - public ChefMock addPartialResult(List<PartialNode> partialNodes) { - partialResult.rows.addAll(partialNodes); - return this; - } - - @Override - public NodeResult searchNodeByFQDN(String fqdn) { - return result; - } - - @Override - public NodeResult searchNodes(String query) { - return result; - } - - @Override - public PartialNodeResult partialSearchNodes(String query, List<AttributeMapping> returnAttributes) { - PartialNodeResult partialNodeResult = new PartialNodeResult(); - partialNodeResult.rows = new ArrayList<>(); - partialNodeResult.rows.addAll(partialResult.rows); - result.rows.stream() - .map(chefNode -> { - Map<String, String> data = new HashMap<>(); - data.put("fqdn", chefNode.name); - return new PartialNode(data); - }) - .forEach(node -> partialNodeResult.rows.add(node)); - return partialNodeResult; - } - - @Override - public void copyChefEnvironment(String fromEnvironmentName, String toEnvironmentName) { - if(!chefEnvironments.contains(fromEnvironmentName)) { - throw new NotFoundException(String.format("Source chef environment %s does not exist", fromEnvironmentName)); - } - chefEnvironments.add(toEnvironmentName); - } - - @Override - public ChefEnvironment getChefEnvironment(String environmentName) { - return null; - } - - @Override - public CookBook getCookbook(String cookbookName, String cookbookVersion) { - return null; - } - - @Override - public String downloadResource(URL resourceURL) { - return ""; - } -} - diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/package-info.java deleted file mode 100644 index 5d3d4b87b74..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.integration.chef; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefEnvironment.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefEnvironment.java deleted file mode 100644 index 8576949280b..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefEnvironment.java +++ /dev/null @@ -1,110 +0,0 @@ -// 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.api.integration.chef.rest; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; - -/** - * @author mortent - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class ChefEnvironment { - - @JsonProperty("name") - private String name; - - @JsonProperty("default_attributes") - private Map<String, Object> attributes; - @JsonProperty("override_attributes") - private Map<String, Object> overrideAttributes; - @JsonProperty("description") - private String description; - @JsonProperty("cookbook_versions") - private Map<String, String> cookbookVersions; - - // internal - @JsonProperty("json_class") - private final String _jsonClass = "Chef::Environment"; - @JsonProperty("chef_type") - private final String _chefType = "environment"; - - public static Builder builder() { - return new Builder(); - } - - public String getName() { - return name; - } - - public Builder copy() { - return builder() - .name(name) - .attributes(attributes) - .overrideAttributes(overrideAttributes) - .cookbookVersions(cookbookVersions) - .description(description); - } - - public String getDescription() { - return description; - } - - public Map<String, String> getCookbookVersions() { - return cookbookVersions; - } - - public Map<String, Object> getAttributes() { - return attributes; - } - - public Map<String, Object> getOverrideAttributes() { - return overrideAttributes; - } - - public static class Builder { - private String name; - private Map<String, Object> attributes; - private String description; - private Map<String, Object> overrideAttributes; - private Map<String, String> cookbookVersions; - - public Builder name(String name){ - this.name = name; - return this; - } - - public Builder attributes(Map<String, Object> defaultAttributes) { - this.attributes = defaultAttributes; - return this; - } - - public Builder overrideAttributes(Map<String, Object> overrideAttributes) { - this.overrideAttributes = overrideAttributes; - return this; - } - - public Builder cookbookVersions(Map<String, String> cookbookVersions) { - this.cookbookVersions = cookbookVersions; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public ChefEnvironment build() { - ChefEnvironment chefEnvironment = new ChefEnvironment(); - chefEnvironment.name = name; - chefEnvironment.description = description; - chefEnvironment.cookbookVersions = cookbookVersions; - chefEnvironment.attributes = attributes; - chefEnvironment.overrideAttributes = overrideAttributes; - - return chefEnvironment; - } - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefNode.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefNode.java deleted file mode 100644 index 08d9a1045e8..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefNode.java +++ /dev/null @@ -1,118 +0,0 @@ -// 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.api.integration.chef.rest; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author mortent - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class ChefNode { - - @JsonProperty("name") - public String name; - - @JsonProperty("chef_environment") - public String chefEnvironment; - - @JsonProperty("run_list") - public List<String> runList; - - @JsonProperty("json_class") - public String jsonClass; - - @JsonProperty("chef_type") - public String chefType; - - @JsonProperty("automatic") - public Map<String, Object> automaticAttributes; - - @JsonProperty("normal") - public Map<String, Object> normalAttributes; - - @JsonProperty("default") - public Map<String, Object> defaultAttributes; - - @JsonProperty("override") - public Map<String, Object> overrideAttributes; - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(ChefNode src) { - return new Builder(src); - } - - public static class Builder { - private String name; - private String chefEnvironment; - private List<String> runList; - private String jsonClass; - private String chefType; - private Map<String, Object> automaticAttributes; - private Map<String, Object> normalAttributes; - private Map<String, Object> defaultAttributes; - private Map<String, Object> overrideAttributes; - - private Builder(){} - - private Builder(ChefNode src){ - this.name = src.name; - this.chefEnvironment = src.chefEnvironment; - this.runList = new ArrayList<>(src.runList); - this.jsonClass = src.jsonClass; - this.chefType = src.chefType; - this.automaticAttributes = new HashMap<>(src.automaticAttributes); - this.normalAttributes = new HashMap<>(src.normalAttributes); - this.defaultAttributes = new HashMap<>(src.defaultAttributes); - this.overrideAttributes = new HashMap<>(src.overrideAttributes); - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder chefEnvironment(String chefEnvironment) { - this.chefEnvironment = chefEnvironment; - return this; - } - - public ChefNode build(){ - ChefNode node = new ChefNode(); - node.name = this.name; - node.chefEnvironment = this.chefEnvironment; - node.runList = this.runList; - node.jsonClass = this.jsonClass; - node.chefType = this.chefType; - node.automaticAttributes = this.automaticAttributes; - node.overrideAttributes = this.overrideAttributes; - node.defaultAttributes = this.defaultAttributes; - node.normalAttributes = this.normalAttributes; - return node; - } - - } - - @Override - public String toString() { - return "Node{" + - "name='" + name + '\'' + - ", chefEnvironment='" + chefEnvironment + '\'' + - ", runList=" + runList + - ", jsonClass='" + jsonClass + '\'' + - ", chefType='" + chefType + '\'' + - ", automaticAttributes=" + automaticAttributes + - ", normalAttributes=" + normalAttributes + - ", defaultAttributes=" + defaultAttributes + - ", overrideAttributes=" + overrideAttributes + - '}'; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefResource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefResource.java deleted file mode 100644 index 98eeb0770fc..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/ChefResource.java +++ /dev/null @@ -1,74 +0,0 @@ -// 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.api.integration.chef.rest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import java.util.List; - -/** - * @author mortent - * @author mpolden - */ - -@Path("/") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public interface ChefResource { - - @Path("/organizations/{organization}/environments/{environment}/nodes") - @Consumes("application/json") - @GET - List<String> getNodes(@PathParam("organization") String organization, @PathParam("environment") String environment); - - @GET - @Path("/organizations/{organization}/nodes/{nodename}") - ChefNode getNode(@PathParam("organization") String organization, @PathParam("nodename") String nodename); - - @PUT - @Path("/organizations/{organization}/nodes/{nodename}") - ChefNode updateNode(@PathParam("organization") String organization, @PathParam("nodename") String nodeName, String node); - - @DELETE - @Path("/organizations/{organization}/nodes/{nodename}") - ChefNode deleteNode(@PathParam("organization") String organization, @PathParam("nodename") String nodeName); - - @GET - @Path("/organizations/{organization}/clients/{name}") - Client getClient(@PathParam("organization") String organization, @PathParam("name") String name); - - @DELETE - @Path("/organizations/{organization}/clients/{name}") - Client deleteClient(@PathParam("organization") String organization, @PathParam("name") String name); - - @GET - @Path("/organizations/{organization}/environments/{environment}") - ChefEnvironment getEnvironment(@PathParam("organization") String organization, @PathParam("environment") String environment); - - @PUT - @Path("/organizations/{organization}/environments/{name}") - String updateEnvironment(@PathParam("organization") String organization, @PathParam("name") String chefEnvironmentName, String contentAsString); - - @POST - @Path("/organizations/{organization}/environments") - String createEnvironment(@PathParam("organization") String organization, String contentAsString); - - @GET - @Path("/organizations/{organization}/search/node") - NodeResult searchNode(@PathParam("organization") String organization, @QueryParam("q") String query); - - @POST - @Path("/organizations/{organization}/search/node") - PartialNodeResult partialSearchNode(@PathParam("organization") String organization, @QueryParam("q") String query, @QueryParam("rows") int rows, String keys); - - @GET - @Path("/organizations/{organization}/cookbooks/{name}/{version}") - CookBook getCookBook(@PathParam("organization") String organization, @PathParam("name") String name, @PathParam("version") String version); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/Client.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/Client.java deleted file mode 100644 index 0ea9b0e9997..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/Client.java +++ /dev/null @@ -1,25 +0,0 @@ -// 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.api.integration.chef.rest; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * @author mpolden - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class Client { - - @JsonProperty("name") - public String name; - @JsonProperty("validator") - public boolean validator; - - @Override - public String toString() { - return "Client{" + - "name='" + name + '\'' + - ", validator=" + validator + - '}'; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/CookBook.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/CookBook.java deleted file mode 100644 index ab49ac9ff60..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/CookBook.java +++ /dev/null @@ -1,32 +0,0 @@ -// 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.api.integration.chef.rest; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * @author mortent - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class CookBook { - public final String name; - public final List<Attributes> attributes; - - public CookBook(@JsonProperty("name") String name, @JsonProperty("attributes") List<Attributes> attributes) { - this.name = name; - this.attributes = attributes; - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static class Attributes { - public final String name; - public final String url; - - public Attributes(@JsonProperty("name") String name, @JsonProperty("url") String url) { - this.name = name; - this.url = url; - } - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/NodeResult.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/NodeResult.java deleted file mode 100644 index e3ab431473f..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/NodeResult.java +++ /dev/null @@ -1,20 +0,0 @@ -// 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.api.integration.chef.rest; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * @author mpolden - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class NodeResult { - @JsonProperty("total") - public int total; - @JsonProperty("start") - public int start; - @JsonProperty("rows") - public List<ChefNode> rows; -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/PartialNode.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/PartialNode.java deleted file mode 100644 index f4aa90021b1..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/PartialNode.java +++ /dev/null @@ -1,40 +0,0 @@ -// 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.api.integration.chef.rest; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Map; -import java.util.Optional; - -/** - * @author mortent - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class PartialNode { - - @JsonProperty("data") - private final Map<String, String> data; - - @JsonCreator - public PartialNode(@JsonProperty("data") Map<String, String> data) { - this.data = data; - } - - public Optional<String> getValue(String key) { - return Optional.ofNullable(data.get(key)); - } - - public String getFqdn() { - return getValue("fqdn").orElse(""); - } - - public String getName() { - return getValue("name").orElse(""); - } - - public Double getOhaiTime() { - return Double.parseDouble(getValue("ohai_time").orElse("0.0")); - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/PartialNodeResult.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/PartialNodeResult.java deleted file mode 100644 index 9925237a193..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/PartialNodeResult.java +++ /dev/null @@ -1,20 +0,0 @@ -// 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.api.integration.chef.rest; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * @author mortent - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class PartialNodeResult { - @JsonProperty("total") - public int total; - @JsonProperty("start") - public int start; - @JsonProperty("rows") - public List<PartialNode> rows; -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/package-info.java deleted file mode 100644 index 7d06571507e..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/chef/rest/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.integration.chef.rest; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java index 6dee5783449..e706cab00fa 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java @@ -1,13 +1,15 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.configserver; +import com.yahoo.component.Version; +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions; import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus; import com.yahoo.vespa.hosted.controller.api.application.v4.model.ClusterMetrics; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname; -import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.config.provision.ApplicationId; +import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificate; import com.yahoo.vespa.serviceview.bindings.ApplicationView; import java.io.IOException; @@ -25,13 +27,11 @@ import java.util.Set; public interface ConfigServer { interface PreparedApplication { - // TODO: Remove the two methods below - void activate(); - List<Log> messages(); PrepareResponse prepareResponse(); } - PreparedApplication deploy(DeploymentId deployment, DeployOptions deployOptions, Set<String> rotationCnames, Set<String> rotationNames, byte[] content); + PreparedApplication deploy(DeploymentId deployment, DeployOptions deployOptions, Set<String> rotationNames, + Set<ContainerEndpoint> containerEndpoints, ApplicationCertificate applicationCertificate, byte[] content); void restart(DeploymentId deployment, Optional<Hostname> hostname); @@ -75,9 +75,17 @@ public interface ConfigServer { NodeRepository nodeRepository(); /** Get service convergence status for given deployment */ - Optional<ServiceConvergence> serviceConvergence(DeploymentId deployment); + default Optional<ServiceConvergence> serviceConvergence(DeploymentId deployment) { + return serviceConvergence(deployment, Optional.empty()); + } + + /** Get service convergence status for given deployment, using the nodes in the model at the given Vespa version. */ + Optional<ServiceConvergence> serviceConvergence(DeploymentId deployment, Optional<Version> version); /** Get all load balancers in given zone */ List<LoadBalancer> getLoadBalancers(ZoneId zone); + /** Get all load balancers for application in given zone */ + List<LoadBalancer> getLoadBalancers(ApplicationId application, ZoneId zone); + } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java index a2d199a38a8..20599e92aa9 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java @@ -37,7 +37,8 @@ public class ConfigServerException extends RuntimeException { OUT_OF_CAPACITY, REQUEST_TIMEOUT, UNKNOWN_VESPA_VERSION, - PARENT_HOST_NOT_READY + PARENT_HOST_NOT_READY, + CERTIFICATE_NOT_READY } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java new file mode 100644 index 00000000000..2134320bdc1 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java @@ -0,0 +1,59 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.configserver; + +import java.util.List; +import java.util.Objects; + +/** + * This represents a list of one or more names for a container cluster. + * + * @author mpolden + */ +public class ContainerEndpoint { + + private final String clusterId; + private final List<String> names; + + public ContainerEndpoint(String clusterId, List<String> names) { + this.clusterId = nonEmpty(clusterId, "message must be non-empty"); + this.names = List.copyOf(Objects.requireNonNull(names, "names must be non-null")); + } + + /** ID of the cluster to which this points */ + public String clusterId() { + return clusterId; + } + + /** + * All valid DNS names for this endpoint. This can contain both proper DNS names and synthetic identifiers used for + * routing, such as a Host header value that is not necessarily a proper DNS name. + */ + public List<String> names() { + return names; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ContainerEndpoint that = (ContainerEndpoint) o; + return clusterId.equals(that.clusterId) && + names.equals(that.names); + } + + @Override + public int hashCode() { + return Objects.hash(clusterId, names); + } + + @Override + public String toString() { + return "container endpoint for " + clusterId + " " + names; + } + + private static String nonEmpty(String s, String message) { + if (s == null || s.isBlank()) throw new IllegalArgumentException(message); + return s; + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java index 95544c23db5..916a388692e 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeRepository.java @@ -5,8 +5,13 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.zone.ZoneId; +import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList; +import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode; +import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeState; +import java.util.Collection; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -17,8 +22,38 @@ import java.util.stream.Collectors; */ public interface NodeRepository { + void addNodes(ZoneId zone, Collection<NodeRepositoryNode> nodes); + + void deleteNode(ZoneId zone, String hostname); + + void setState(ZoneId zone, NodeState nodeState, String nodename); + + NodeRepositoryNode getNode(ZoneId zone, String hostname); + + NodeList listNodes(ZoneId zone); + + NodeList listNodes(ZoneId zone, ApplicationId application); + /** List all nodes in zone owned by given application */ - List<Node> list(ZoneId zone, ApplicationId application); + default List<Node> list(ZoneId zone, ApplicationId application) { + return listNodes(zone, application).nodes().stream() + .map(n -> new Node(com.yahoo.config.provision.HostName.from(n.getHostname()), + fromJacksonState(n.getState()), + fromJacksonType(n.getType()), Optional.of(application), + Version.fromString(n.getVespaVersion()), + Version.fromString(n.getWantedVespaVersion()), + Version.fromString(n.getCurrentOsVersion()), + Version.fromString(n.getWantedOsVersion()), + fromBoolean(n.getAllowedToBeDown()), + n.getCurrentRestartGeneration(), + n.getRestartGeneration(), + n.getCurrentRebootGeneration(), + n.getRebootGeneration(), + n.getCanonicalFlavor(), + n.getMembership().clusterid, + clusterTypeOf(n.getMembership().clustertype))) + .collect(Collectors.toUnmodifiableList()); + } /** List all nodes in states, in zone owned by given application */ default List<Node> list(ZoneId zone, ApplicationId application, Set<Node.State> states) { @@ -39,4 +74,47 @@ public interface NodeRepository { /** Cancels firmware checks on all hosts in the given zone. */ void cancelFirmwareCheck(ZoneId zone); + + + private Node.ClusterType clusterTypeOf(String type) { + switch (type) { + case "admin": return Node.ClusterType.admin; + case "content": return Node.ClusterType.content; + case "container": return Node.ClusterType.container; + default: throw new IllegalArgumentException("Unknown cluster type '" + type + "'."); + } + } + + // Convert Jackson type to config.provision type + private static NodeType fromJacksonType(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeType nodeType) { + switch (nodeType) { + case tenant: return NodeType.tenant; + case host: return NodeType.host; + case proxy: return NodeType.proxy; + case proxyhost: return NodeType.proxyhost; + case config: return NodeType.config; + case confighost: return NodeType.confighost; + default: throw new IllegalArgumentException("Unknown type: " + nodeType); + } + } + + private static com.yahoo.vespa.hosted.controller.api.integration.configserver.Node.State fromJacksonState(NodeState state) { + switch (state) { + case provisioned: return Node.State.provisioned; + case ready: return Node.State.ready; + case reserved: return Node.State.reserved; + case active: return Node.State.active; + case inactive: return Node.State.inactive; + case dirty: return Node.State.dirty; + case failed: return Node.State.failed; + case parked: return Node.State.parked; + default: throw new IllegalArgumentException("Unknown state: " + state); + } + } + + private static Node.ServiceState fromBoolean(Boolean allowedDown) { + return (allowedDown == null) + ? Node.ServiceState.unorchestrated + : allowedDown ? Node.ServiceState.allowedDown : Node.ServiceState.expectedUp; + } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java index 7bbb7886306..5f8e2f886a2 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java @@ -1,19 +1,21 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.deployment; -import com.google.common.collect.ImmutableMap; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.zone.ZoneId; +import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.yahoo.config.provision.SystemName.Public; +import static com.yahoo.config.provision.SystemName.PublicCd; import static com.yahoo.config.provision.SystemName.cd; import static com.yahoo.config.provision.SystemName.main; -import static com.yahoo.config.provision.SystemName.vaas; /** Job types that exist in the build system */ public enum JobType { @@ -22,12 +24,14 @@ public enum JobType { Map.of()), systemTest ("system-test", - Map.of(main, ZoneId.from("test" , "us-east-1"), - cd , ZoneId.from("test" , "cd-us-central-1"))), + Map.of(main , ZoneId.from("test", "us-east-1"), + cd , ZoneId.from("test", "cd-us-central-1"), + PublicCd, ZoneId.from("test", "aws-us-east-1c"))), stagingTest ("staging-test", - Map.of(main, ZoneId.from("staging", "us-east-3"), - cd , ZoneId.from("staging", "cd-us-central-1"))), + Map.of(main , ZoneId.from("staging", "us-east-3"), + cd , ZoneId.from("staging", "cd-us-central-1"), + PublicCd, ZoneId.from("staging", "aws-us-east-1c"))), productionUsEast3 ("production-us-east-3", Map.of(main, ZoneId.from("prod" , "us-east-3"))), @@ -53,6 +57,9 @@ public enum JobType { productionAwsUsEast1a ("production-aws-us-east-1a", Map.of(main, ZoneId.from("prod" , "aws-us-east-1a"))), + productionAwsUsEast1c ("production-aws-us-east-1c", + Map.of(PublicCd, ZoneId.from("prod", "aws-us-east-1c"))), + productionAwsUsWest2a ("production-aws-us-west-2a", Map.of(main, ZoneId.from("prod" , "aws-us-west-2a"))), @@ -81,8 +88,9 @@ public enum JobType { devCdUsCentral1 ("dev-cd-us-central-1", Map.of(cd , ZoneId.from("dev" , "cd-us-central-1"))), - devAwsUsEast1b ("dev-aws-us-east-1b", - Map.of(vaas, ZoneId.from("dev" , "vaas-aws-us-east-1b"))), + devAwsUsEast1c ("dev-aws-us-east-1c", + Map.of(Public, ZoneId.from("dev", "aws-us-east-1c"), + PublicCd, ZoneId.from("dev", "aws-us-east-1c"))), perfUsEast3 ("perf-us-east-3", Map.of(main, ZoneId.from("perf" , "us-east-3"))); @@ -108,6 +116,10 @@ public enum JobType { return zones.get(system); } + public static List<JobType> allIn(SystemName system) { + return Stream.of(values()).filter(job -> job.zones.containsKey(system)).collect(Collectors.toUnmodifiableList()); + } + /** Returns whether this is a production job */ public boolean isProduction() { return environment() == Environment.prod; } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/ArtifactId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/ArtifactId.java new file mode 100644 index 00000000000..21f38084c22 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/ArtifactId.java @@ -0,0 +1,26 @@ +package com.yahoo.vespa.hosted.controller.api.integration.maven; + +import static java.util.Objects.requireNonNull; + +/** + * Identifier for an artifact. + * + * @author jonmv + */ +public class ArtifactId { + + private final String groupId; + private final String artifactId; + + public ArtifactId(String groupId, String artifactId) { + this.groupId = requireNonNull(groupId); + this.artifactId = requireNonNull(artifactId); + } + + /** Group ID of this. */ + public String groupId() { return groupId; } + + /** Artifact ID of this. */ + public String artifactId() { return artifactId; } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/MavenRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/MavenRepository.java new file mode 100644 index 00000000000..fb133f75654 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/MavenRepository.java @@ -0,0 +1,16 @@ +package com.yahoo.vespa.hosted.controller.api.integration.maven; + +/** + * A Maven repository which keeps released artifacts. + * + * @author jonmv + */ +public interface MavenRepository { + + /** Returns metadata about all releases of a specific artifact to this repository. */ + Metadata metadata(); + + /** Returns the id of the artifact whose releases this tracks. */ + ArtifactId artifactId(); + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/Metadata.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/Metadata.java new file mode 100644 index 00000000000..fd84a05db6a --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/Metadata.java @@ -0,0 +1,50 @@ +package com.yahoo.vespa.hosted.controller.api.integration.maven; + +import com.yahoo.component.Version; +import com.yahoo.text.XML; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +import static java.util.Objects.requireNonNull; + +/** + * Metadata about a released artifact. + * + * @author jonmv + */ +public class Metadata { + + private final ArtifactId id; + private final List<Version> versions; + + public Metadata(ArtifactId id, List<Version> versions) { + this.id = requireNonNull(id); + this.versions = versions.stream().sorted().collect(Collectors.toUnmodifiableList()); + } + + /** Creates a new Metadata object from the given XML document. */ + public static Metadata fromXml(String xml) { + Element metadata = XML.getDocument(xml).getDocumentElement(); + ArtifactId id = new ArtifactId(XML.getValue(XML.getChild(metadata, "groupId")), + XML.getValue(XML.getChild(metadata, "artifactId"))); + List<Version> versions = new ArrayList<>(); + for (Element version : XML.getChildren(XML.getChild(XML.getChild(metadata, "versioning"), "versions"))) + versions.add(Version.fromString(XML.getValue(version))); + + return new Metadata(id, versions); + } + + /** Id of the metadata this concerns. */ + public ArtifactId id() { return id; } + + /** List of available versions of this, sorted by ascending version order. */ + public List<Version> versions() { return versions; } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/package-info.java new file mode 100644 index 00000000000..d5abdf31f4b --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/maven/package-info.java @@ -0,0 +1,5 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +@ExportPackage +package com.yahoo.vespa.hosted.controller.api.integration.maven; + +import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java deleted file mode 100644 index 4b495ebf331..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/NodeRepositoryClientInterface.java +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.noderepository; - -import com.yahoo.config.provision.zone.ZoneId; - -import java.io.IOException; -import java.util.Collection; - -/** - * A complete client for the node repository REST API. - * - * @author smorgrav - * @author bjorncs - */ -// TODO: Get rid of all the checked exceptions -// TODO: Replace remaining controller-server usages of this with -// com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository and move this package back to internal -// repo -public interface NodeRepositoryClientInterface { - - enum WantTo { - Retire, - Deprovision - } - - void addNodes(ZoneId zone, Collection<NodeRepositoryNode> nodes) throws IOException; - - NodeRepositoryNode getNode(ZoneId zone, String hostname) throws IOException; - - void deleteNode(ZoneId zone, String hostname) throws IOException; - - NodeList listNodes(ZoneId zone, boolean recursive) throws IOException; - - NodeList listNodes(ZoneId zone, String tenant, String applicationId, String instance) throws IOException; - - String resetFailureInformation(ZoneId zone, String nodename) throws IOException; - - String restart(ZoneId zone, String nodename) throws IOException; - - String reboot(ZoneId zone, String nodename) throws IOException; - - String cancelReboot(ZoneId zone, String nodename) throws IOException; - - String wantTo(ZoneId zone, String nodename, WantTo... actions) throws IOException; - - String cancelRestart(ZoneId zone, String nodename) throws IOException; - - String setHardwareFailureDescription(ZoneId zone, String nodename, String hardwareFailureDescription) throws IOException; - - void setState(ZoneId zone, NodeState nodeState, String nodename) throws IOException; - - String enableMaintenanceJob(ZoneId zone, String jobName) throws IOException; - - String disableMaintenanceJob(ZoneId zone, String jobName) throws IOException; - - MaintenanceJobList listMaintenanceJobs(ZoneId zone) throws IOException; - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Billing.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Billing.java new file mode 100644 index 00000000000..f716458542c --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Billing.java @@ -0,0 +1,12 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.organization; + +import com.yahoo.config.provision.ApplicationId; + +/** + * @author olaa + */ +public interface Billing { + + void handleBilling(ApplicationId applicationId, String customerId); +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockBilling.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockBilling.java new file mode 100644 index 00000000000..20b77703160 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/MockBilling.java @@ -0,0 +1,13 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.organization; + +import com.yahoo.config.provision.ApplicationId; + +/** + * @author olaa + */ +public class MockBilling implements Billing { + + @Override + public void handleBilling(ApplicationId applicationId, String customerId) {} +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/RoutingGenerator.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/RoutingGenerator.java index 276e19da8f6..f5c82018ac6 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/RoutingGenerator.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/routing/RoutingGenerator.java @@ -1,9 +1,12 @@ // 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.api.integration.routing; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; +import java.net.URI; import java.util.List; +import java.util.Map; /** * @author bratseth @@ -16,4 +19,8 @@ public interface RoutingGenerator { * @return List of endpoints for that deploymentId */ List<RoutingEndpoint> endpoints(DeploymentId deploymentId); + + /** Returns the endpoints of each cluster in the given deployment — nothing global. */ + Map<ClusterSpec.Id, URI> clusterEndpoints(DeploymentId deploymentId); + } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMavenRepository.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMavenRepository.java new file mode 100644 index 00000000000..be1deb3997a --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMavenRepository.java @@ -0,0 +1,31 @@ +package com.yahoo.vespa.hosted.controller.api.integration.stubs; + +import com.yahoo.component.Version; +import com.yahoo.vespa.hosted.controller.api.integration.maven.ArtifactId; +import com.yahoo.vespa.hosted.controller.api.integration.maven.Metadata; +import com.yahoo.vespa.hosted.controller.api.integration.maven.MavenRepository; + +import java.util.List; + +/** + * Mock repository for maven artifacts, that returns a static metadata. + * + * @author jonmv + */ +public class MockMavenRepository implements MavenRepository { + + public static final ArtifactId id = new ArtifactId("ai.vespa", "search"); + + @Override + public Metadata metadata() { + return new Metadata(id, List.of(Version.fromString("6.0"), + Version.fromString("6.1"), + Version.fromString("6.2"))); + } + + @Override + public ArtifactId artifactId() { + return id; + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java index d0f9b769494..08702027264 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java @@ -50,7 +50,9 @@ enum PathGroup { application(Matcher.tenant, Matcher.application, Optional.of("/api"), - "/application/v4/tenant/{tenant}/application/{application}"), + "/application/v4/tenant/{tenant}/application/{application}", + "/application/v4/tenant/{tenant}/application/{application}/instance/", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}"), /** Paths used for user management on the application level. */ applicationUsers(Matcher.tenant, @@ -63,17 +65,26 @@ enum PathGroup { Matcher.application, Optional.of("/api"), "/application/v4/tenant/{tenant}/application/{application}/deploying/{*}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/deploying/{*}", "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/job/{*}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/{environment}/region/{region}/nodes", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/{environment}/region/{region}/logs", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/{environment}/region/{region}/suspended", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/{environment}/region/{region}/service/{*}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/{environment}/region/{region}/global-rotation/{*}", "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/nodes", "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/logs", "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/suspended", "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/service/{*}", - "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/global-rotation/{*}"), + "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/global-rotation/{*}", + "/application/v4/tenant/{tenant}/application/{application}/metering"), /** Path used to restart development nodes. */ developmentRestart(Matcher.tenant, Matcher.application, Optional.of("/api"), + "/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/dev/region/{region}/restart", + "/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/perf/region/{region}/restart", "/application/v4/tenant/{tenant}/application/{application}/environment/dev/region/{region}/instance/{ignored}/restart", "/application/v4/tenant/{tenant}/application/{application}/environment/perf/region/{region}/instance/{ignored}/restart"), @@ -81,6 +92,9 @@ enum PathGroup { productionRestart(Matcher.tenant, Matcher.application, Optional.of("/api"), + "/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/prod/region/{region}/restart", + "/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/test/region/{region}/restart", + "/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/staging/region/{region}/restart", "/application/v4/tenant/{tenant}/application/{application}/environment/prod/region/{region}/instance/{ignored}/restart", "/application/v4/tenant/{tenant}/application/{application}/environment/test/region/{region}/instance/{ignored}/restart", "/application/v4/tenant/{tenant}/application/{application}/environment/staging/region/{region}/instance/{ignored}/restart"), @@ -90,6 +104,10 @@ enum PathGroup { Matcher.application, Optional.of("/api"), "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/deploy/{job}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/dev/region/{region}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/dev/region/{region}/deploy", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/perf/region/{region}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/perf/region/{region}/deploy", "/application/v4/tenant/{tenant}/application/{application}/environment/dev/region/{region}/instance/{instance}", "/application/v4/tenant/{tenant}/application/{application}/environment/dev/region/{region}/instance/{instance}/deploy", "/application/v4/tenant/{tenant}/application/{application}/environment/perf/region/{region}/instance/{instance}", @@ -99,6 +117,12 @@ enum PathGroup { productionDeployment(Matcher.tenant, Matcher.application, Optional.of("/api"), + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/prod/region/{region}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/prod/region/{region}/deploy", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/test/region/{region}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/test/region/{region}/deploy", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/staging/region/{region}", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/staging/region/{region}/deploy", "/application/v4/tenant/{tenant}/application/{application}/environment/prod/region/{region}/instance/{instance}", "/application/v4/tenant/{tenant}/application/{application}/environment/prod/region/{region}/instance/{instance}/deploy", "/application/v4/tenant/{tenant}/application/{application}/environment/test/region/{region}/instance/{instance}", @@ -110,15 +134,15 @@ enum PathGroup { submission(Matcher.tenant, Matcher.application, Optional.of("/api"), - "/application/v4/tenant/{tenant}/application/{application}/submit"), + "/application/v4/tenant/{tenant}/application/{application}/submit", + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/submit"), /** Paths used for other tasks by build services. */ // TODO: This will vanish. buildService(Matcher.tenant, Matcher.application, Optional.of("/api"), "/application/v4/tenant/{tenant}/application/{application}/jobreport", - "/application/v4/tenant/{tenant}/application/{application}/promote", - "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/promote"), + "/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/jobreport"), /** Paths which contain (not very strictly) classified information about customers. */ classifiedTenantInfo(Optional.of("/api"), @@ -134,7 +158,8 @@ enum PathGroup { "/statuspage/v1/{*}"), /** Paths providing public information. */ - publicInfo("/badge/v1/{*}", + publicInfo(Optional.of("/api"), + "/badge/v1/{*}", "/zone/v1/{*}"); final List<String> pathSpecs; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/ZoneApi.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/ZoneApi.java deleted file mode 100644 index 7bb4bfc6467..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/ZoneApi.java +++ /dev/null @@ -1,35 +0,0 @@ -// 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.api.zone.v1; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.List; - -/** - * Used by build system and command-line tool. - * - * @author smorgrav - */ -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Path(ZoneApi.API_VERSION) -public interface ZoneApi { - - String API_VERSION = "v1"; - - @GET - @Path("") - List<ZoneReference.Environment> listEnvironments(); - - @GET - @Path("/environment/{environment}") - List<ZoneReference.Region> listRegions(@PathParam("environment") String env); - - @GET - @Path("/environment/{environment}/default") - ZoneReference.Region defaultRegion(@PathParam("environment") String env); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/ZoneReference.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/ZoneReference.java deleted file mode 100644 index 82d03d72acd..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/ZoneReference.java +++ /dev/null @@ -1,64 +0,0 @@ -// 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.api.zone.v1; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.net.URI; - -/** - * @author smorgrav - */ -public class ZoneReference { - - public static class Environment { - @JsonProperty("name") - private String name; - - @JsonProperty("url") - private URI url; - - public String getName() { - return name; - } - - public Environment setName(String name) { - this.name = name; - return this; - } - - public URI getUrl() { - return url; - } - - public Environment setUrl(URI url) { - this.url = url; - return this; - } - } - - public static class Region { - @JsonProperty("name") - private String name; - - @JsonProperty("url") - private URI url; - - public String getName() { - return name; - } - - public Region setName(String name) { - this.name = name; - return this; - } - - public URI getUrl() { - return url; - } - - public Region setUrl(URI url) { - this.url = url; - return this; - } - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/package-info.java deleted file mode 100644 index e3275ff35fa..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v1/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.zone.v1; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneApiV2.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneApiV2.java deleted file mode 100644 index a6d7614e862..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneApiV2.java +++ /dev/null @@ -1,302 +0,0 @@ -// 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.api.zone.v2; - -import com.fasterxml.jackson.databind.JsonNode; -import com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId; -import com.yahoo.vespa.hosted.controller.api.identifiers.EnvironmentId; -import com.yahoo.vespa.hosted.controller.api.identifiers.InstanceId; -import com.yahoo.vespa.hosted.controller.api.identifiers.RegionId; -import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId; -import com.yahoo.vespa.hosted.controller.api.integration.noderepository.MaintenanceJobList; -import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList; -import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode; -import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeState; -import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; -import com.yahoo.vespa.hosted.controller.api.integration.routing.status.StatusReply; -import com.yahoo.vespa.hosted.controller.api.integration.routing.status.ZoneStatusReply; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * Aka the controller proxy service. - * - * Proxies calls to correct config server with the additional feature of - * retry and fail detection (ping). - */ -@Path(ZoneApiV2.API_VERSION) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public interface ZoneApiV2 { - - String API_VERSION = "v2"; - - @GET - @Path("/") - ZoneReferences listZones(); - - @GET - @Path("/{environment}/{region}/{proxy_request: .+}") - Response proxyGet( - @PathParam("environment") String env, - @PathParam("region") String region, - @PathParam("proxy_request") String proxyRequest); - - @POST - @Path("/{environment}/{region}/{proxy_request: .+}") - Response proxyPost( - @PathParam("environment") String env, - @PathParam("region") String region, - @PathParam("proxy_request") String proxyRequest); - - @PUT - @Path("/{environment}/{region}/{proxy_request: .+}") - Response proxyPut( - @PathParam("environment") String env, - @PathParam("region") String region, - @PathParam("proxy_request") String proxyRequest); - - @DELETE - @Path("/{environment}/{region}/{proxy_request: .+}") - Response proxyDelete( - @PathParam("environment") String env, - @PathParam("region") String region, - @PathParam("proxy_request") String proxyRequest); - - // Explicit mappings of some proxy requests (to enable creation of proxy clients with javax.ws.rs) - - @GET - @Path("/{environmentId}/{regionId}/application/v2/tenant/{tenantId}/application/{applicationId}/environment/{environmentId}/region/{regionId}/instance/{instanceId}/serviceconverge") - Response waitForConfigConvergeV2(@PathParam("tenantId") TenantId tenantId, - @PathParam("applicationId") ApplicationId applicationId, - @PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("instanceId") InstanceId instanceId, - @QueryParam("timeout") long timeoutInSeconds); - @GET - @Path("/{environmentId}/{regionId}/application/v2/tenant/{tenantId}/application/{applicationId}/environment/{environmentId}/region/{regionId}/instance/{instanceId}/serviceconverge/{host}") - Response waitForConfigConvergeV2(@PathParam("tenantId") TenantId tenantId, - @PathParam("applicationId") ApplicationId applicationId, - @PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("instanceId") InstanceId instanceId, - @PathParam("host") String host, - @QueryParam("timeout") long timeoutInSeconds); - - @GET - @Path("/{environmentId}/{regionId}/config/v2/tenant/{tenantId}/application/{applicationId}/prelude.fastsearch.documentdb-info/{clusterid}/search/cluster.{clusterid}") - JsonNode getConfigWithDocumentTypes(@PathParam("tenantId") TenantId tenantId, - @PathParam("applicationId") ApplicationId applicationId, - @PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("clusterid") String clusterid, - @QueryParam("timeout") long timeoutInSeconds); - - @GET - @Path("/{environmentId}/{regionId}/config/v2/tenant/{tenantId}/application/{applicationId}/environment/{environmentId}/region/{regionId}/instance/{instanceId}/cloud.config.cluster-list") - JsonNode getVespaConfigClusterList(@PathParam("tenantId") TenantId tenantId, - @PathParam("applicationId") ApplicationId applicationId, - @PathParam("instanceId") InstanceId instanceId, - @PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @QueryParam("timeout") long timeoutInSeconds); - - - @POST - @Path("/{environmentId}/{regionId}/nodes/v2/node") - String addNodes(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - Collection<NodeRepositoryNode> node); - - @DELETE - @Path("/{environmentId}/{regionId}/nodes/v2/node/{hostname}") - String deleteNode(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("hostname") String hostname); - - @GET - @Path("/{environmentId}/{regionId}/nodes/v2/node/{hostname}") - NodeRepositoryNode getNode(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("hostname") String hostname); - - @POST - @Path("/{environmentId}/{regionId}/nodes/v2/node/{hostname}") - String patchNode(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("hostname") String hostname, - NodeRepositoryNode patchValues, - @HeaderParam("X-HTTP-Method-Override") String patchOverride); - - @GET - @Path("/{environmentId}/{regionId}/nodes/v2/node/") - NodeList listNodes(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @QueryParam("recursive") boolean recursive); - - @GET - @Path("/{environmentId}/{regionId}/nodes/v2/node/") - NodeList listNodes(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @QueryParam("application") String applicationString, - @QueryParam("recursive") boolean recursive); - - @PUT - @Path("/{environmentId}/{regionId}/nodes/v2/state/{state}/{hostname}") - String setNodeState(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("state") NodeState state, - @PathParam("hostname") String hostname); - - @POST - @Path("/{environmentId}/{regionId}/nodes/v2/command/reboot") - String rebootNode(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @QueryParam("hostname") String hostname); - - @POST - @Path("/{environmentId}/{regionId}/nodes/v2/command/restart") - String restartNode(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @QueryParam("hostname") String hostname); - - @GET - @Path("/{environmentId}/{regionId}/nodes/v2/maintenance/") - MaintenanceJobList listMaintenanceJobs(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId); - - @POST - @Path("/{environmentId}/{regionId}/nodes/v2/maintenance/inactive/{jobname}") - String disableMaintenanceJob(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("jobname") String jobname); - - @DELETE - @Path("/{environmentId}/{regionId}/nodes/v2/maintenance/inactive/{jobname}") - String enableMaintenanceJob(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("jobname") String jobname); - - - @GET - @Path("/{environmentId}/{regionId}/orchestrator/v1/suspensions/applications") - Set<String> getApplications(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId); - - @GET - @Path("/{environmentId}/{regionId}/orchestrator/v1/suspensions/applications/{application}") - void getApplication(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("application") String applicationIdString); - - @POST - @Path("/{environmentId}/{regionId}/orchestrator/v1/suspensions/applications") - void suspendApplication(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - String applicationIdString); - - @DELETE - @Path("/{environmentId}/{regionId}/orchestrator/v1/suspensions/applications/{application}") - void resumeApplication(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("application") String applicationIdString); - - /** - * Get names of all rotations with the status OUT - * - * @return List of rotation names. - */ - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("/{environmentId}/{regionId}/routing/v1/status") - List<String> listRotations(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId); - - /** - * Get the status of a rotation - * - * @param rotation The name of a rotation. - * @return The current status of the rotation, wrapped into a {@link StatusReply} object. The value is {@link - * RotationStatus#IN} for any rotation that has not been explicitly set to {@link RotationStatus#OUT} using {@link - * #setRotationStatus(EnvironmentId, RegionId, String, StatusReply)}. - */ - @GET - @Path("/{environmentId}/{regionId}/routing/v1/status/{rotation}") - @Produces(MediaType.APPLICATION_JSON) - StatusReply getRotationStatus(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("rotation") String rotation); - - /** - * Set or modify rotation status according to payload - * - * @param rotation The rotation (endpoint) to modify - * @param payload The name/status/agent/reason to set - * @return The updated status of the rotation wrapped into a {@link StatusReply} object. - */ - @PUT - @Path("/{environmentId}/{regionId}/routing/v1/status/{rotation}") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - StatusReply setRotationStatus(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("rotation") String rotation, - StatusReply payload); - - /** - * Set the status of a rotation to IN - * - * @param rotation The name of a rotation. - * @return The updated status of the rotation wrapped into a {@link StatusReply} object. - */ - @DELETE - @Path("/{environmentId}/{regionId}/routing/v1/status/{rotation}") - @Produces(MediaType.APPLICATION_JSON) - @Deprecated - StatusReply unsetRotation(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId, - @PathParam("rotation") String rotation); - - /** - * Set the status of the zone to OUT - * @return The updated status of the zone wrapped into a {@link ZoneStatusReply} object. - */ - @PUT - @Path("/{environmentId}/{regionId}/routing/v1/status/zone") - @Produces(MediaType.APPLICATION_JSON) - ZoneStatusReply setZoneRotationInactive(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId); - - /** - * Clears the status of the zone. The routing check will fall back to check individual rotations. - * @return The updated status of the zone wrapped into a {@link ZoneStatusReply} object. - */ - @DELETE - @Path("/{environmentId}/{regionId}/routing/v1/status/zone") - @Produces(MediaType.APPLICATION_JSON) - ZoneStatusReply unsetZoneRotationInactive(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId); - - /** - * Get the status of the zone - * @return The status of the zone wrapped into a {@link ZoneStatusReply} object. - */ - @GET - @Path("/{environmentId}/{regionId}/routing/v1/status/zone") - @Produces(MediaType.APPLICATION_JSON) - ZoneStatusReply getZoneRotationStatus(@PathParam("environmentId") EnvironmentId environmentId, - @PathParam("regionId") RegionId regionId); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneReference.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneReference.java deleted file mode 100644 index 95dc1c2ee7c..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneReference.java +++ /dev/null @@ -1,27 +0,0 @@ -// 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.api.zone.v2; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.yahoo.vespa.hosted.controller.api.configserver.Environment; -import com.yahoo.vespa.hosted.controller.api.configserver.Region; - -/** - * @author mpolden - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class ZoneReference { - - @JsonProperty("environment") - public final Environment environment; - @JsonProperty("region") - public final Region region; - - @JsonCreator - public ZoneReference(@JsonProperty("environment") Environment environment, @JsonProperty("region") Region region) { - this.environment = environment; - this.region = region; - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneReferences.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneReferences.java deleted file mode 100644 index 3a219afa0a6..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/ZoneReferences.java +++ /dev/null @@ -1,31 +0,0 @@ -// 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.api.zone.v2; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Collections; -import java.util.List; - -/** - * Wire format for listing the controller URIs for all the available zones - * - * @author smorgrav - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class ZoneReferences { - - @JsonProperty("uris") - public final List<String> uris; - - @JsonProperty("zones") - public final List<ZoneReference> zones; - - @JsonCreator - public ZoneReferences(@JsonProperty("uris") List<String> uris, @JsonProperty("zones") List<ZoneReference> zones) { - this.uris = Collections.unmodifiableList(uris); - this.zones = Collections.unmodifiableList(zones); - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/package-info.java deleted file mode 100644 index 5d4b1310981..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/zone/v2/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.zone.v2; - -import com.yahoo.osgi.annotation.ExportPackage; |