diff options
3 files changed, 87 insertions, 12 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index 679af1a5a8c..fdce18f46b2 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -44,9 +44,7 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.UncheckedIOException; import java.math.BigInteger; -import java.net.InetAddress; import java.net.URI; -import java.net.UnknownHostException; import java.security.KeyPair; import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateNotYetValidException; @@ -67,7 +65,6 @@ import java.util.stream.Collectors; import static com.yahoo.config.application.api.Notifications.Role.author; import static com.yahoo.config.application.api.Notifications.When.failing; import static com.yahoo.config.application.api.Notifications.When.failingCommit; -import static com.yahoo.log.LogLevel.DEBUG; import static com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException.ErrorCode.ACTIVATION_CONFLICT; import static com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException.ErrorCode.APPLICATION_LOCK_FAILURE; import static com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException.ErrorCode.BAD_REQUEST; @@ -627,7 +624,7 @@ public class InternalStepRunner implements StepRunner { /** Returns the application package for the tester application, assembled from a generated config, fat-jar and services.xml. */ private ApplicationPackage testerPackage(RunId id) { - ApplicationVersion version = controller.jobController().run(id).get().versions().targetApplication(); + Versions versions = controller.jobController().run(id).get().versions(); DeploymentSpec spec = controller.applications().require(id.application()).deploymentSpec(); ZoneId zone = id.type().zone(controller.system()); @@ -636,11 +633,12 @@ public class InternalStepRunner implements StepRunner { byte[] servicesXml = servicesXml(controller.zoneRegistry().accessControlDomain(), ! controller.system().isPublic(), useTesterCertificate, + versions.targetPlatform().getMajor() == 6, testerFlavorFor(id, spec) .map(NodeResources::fromLegacyName) .orElse(zone.region().value().contains("aws-") ? DEFAULT_TESTER_RESOURCES_AWS : DEFAULT_TESTER_RESOURCES)); - byte[] testPackage = controller.applications().applicationStore().get(id.tester(), version); + byte[] testPackage = controller.applications().applicationStore().get(id.tester(), versions.targetApplication()); byte[] deploymentXml = deploymentXml(spec.athenzDomain(), spec.athenzService(zone.environment(), zone.region())); try (ZipBuilder zipBuilder = new ZipBuilder(testPackage.length + servicesXml.length + 1000)) { @@ -688,15 +686,22 @@ public class InternalStepRunner implements StepRunner { /** Returns the generated services.xml content for the tester application. */ static byte[] servicesXml(AthenzDomain domain, boolean useAthenzCredentials, boolean useTesterCertificate, - NodeResources resources) { + boolean isVespa6, NodeResources resources) { int jdiscMemoryGb = 2; // 2Gb memory for tester application (excessive?). int jdiscMemoryPct = (int) Math.ceil(100 * jdiscMemoryGb / resources.memoryGb()); // Of the remaining memory, split 50/50 between Surefire running the tests and the rest int testMemoryMb = (int) (1024 * (resources.memoryGb() - jdiscMemoryGb) / 2); - String resourceString = String.format(Locale.ENGLISH, - "<resources vcpu=\"%.2f\" memory=\"%.2fGb\" disk=\"%.2fGb\"/>", resources.vcpu(), resources.memoryGb(), resources.diskGb()); + String nodes = isVespa6 ? + String.format(Locale.ENGLISH, + " <nodes count=\"1\" flavor=\"d-%.0f-%.0f-%.0f\" allocated-memory=\"%d%%\" />\n", + Math.ceil(resources.vcpu()), Math.ceil(resources.memoryGb()), Math.ceil(resources.diskGb()), jdiscMemoryPct): + String.format(Locale.ENGLISH, + " <nodes count=\"1\" allocated-memory=\"%d%%\">\n" + + " <resources vcpu=\"%.2f\" memory=\"%.2fGb\" disk=\"%.2fGb\"/>\n" + + " </nodes>\n", + jdiscMemoryPct, resources.vcpu(), resources.memoryGb(), resources.diskGb()); AthenzDomain idDomain = ("vespa.vespa.cd".equals(domain.value()) ? AthenzDomain.from("vespa.vespa") : domain); String servicesXml = @@ -759,9 +764,7 @@ public class InternalStepRunner implements StepRunner { " </filtering>\n" + " </http>\n" + "\n" + - " <nodes count=\"1\" allocated-memory=\"" + jdiscMemoryPct + "%\">\n" + - " " + resourceString + "\n" + - " </nodes>\n" + + nodes + " </container>\n" + "</services>\n"; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index 20259acff90..a362ffe9607 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -47,7 +47,6 @@ import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import static com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type.debug; import static com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type.error; import static com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type.info; import static com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type.warning; @@ -439,9 +438,20 @@ public class InternalStepRunnerTest { assertFile("test_runner_services.xml-cd", new String(InternalStepRunner.servicesXml(AthenzDomain.from("vespa.vespa.cd"), true, false, + false, new NodeResources(2, 12, 75, 1)))); } + @Test + public void generates_correct_services_xml_vespa_6() { + assertFile("test_runner_services.xml-vespa-6", new String(InternalStepRunner.servicesXml(AthenzDomain.from("vespa.vespa.cd"), + true, + false, + true, + new NodeResources(2, 12, 75, 1)))); + } + + private void assertFile(String resourceName, String actualContent) { try { Path path = Paths.get("src/test/resources/").resolve(resourceName); diff --git a/controller-server/src/test/resources/test_runner_services.xml-vespa-6 b/controller-server/src/test/resources/test_runner_services.xml-vespa-6 new file mode 100644 index 00000000000..bf796abffb0 --- /dev/null +++ b/controller-server/src/test/resources/test_runner_services.xml-vespa-6 @@ -0,0 +1,62 @@ +<?xml version='1.0' encoding='UTF-8'?> +<services xmlns:deploy='vespa' version='1.0'> + <container version='1.0' id='tester'> + + <component id="com.yahoo.vespa.hosted.testrunner.TestRunner" bundle="vespa-testrunner-components"> + <config name="com.yahoo.vespa.hosted.testrunner.test-runner"> + <artifactsPath>artifacts</artifactsPath> + <surefireMemoryMb>5120</surefireMemoryMb> + <useAthenzCredentials>true</useAthenzCredentials> + <useTesterCertificate>false</useTesterCertificate> + </config> + </component> + + <handler id="com.yahoo.vespa.hosted.testrunner.TestRunnerHandler" bundle="vespa-testrunner-components"> + <binding>http://*/tester/v1/*</binding> + </handler> + + <http> + <!-- Make sure 4080 is the first port. This will be used by the config server. --> + <server id='default' port='4080'/> + <server id='testertls4443' port='4443'> + <config name="jdisc.http.connector"> + <tlsClientAuthEnforcer> + <enable>true</enable> + <pathWhitelist> + <item>/status.html</item> + <item>/state/v1/config</item> + </pathWhitelist> + </tlsClientAuthEnforcer> + </config> + <ssl> + <private-key-file>/var/lib/sia/keys/vespa.vespa.tenant.key.pem</private-key-file> + <certificate-file>/var/lib/sia/certs/vespa.vespa.tenant.cert.pem</certificate-file> + <client-authentication>want</client-authentication> + </ssl> + </server> + <filtering> + <access-control domain='vespa.vespa.cd'> + <exclude> + <binding>http://*/tester/v1/*</binding> + </exclude> + </access-control> + <request-chain id="testrunner-api"> + <filter id='authz-filter' class='com.yahoo.jdisc.http.filter.security.athenz.AthenzAuthorizationFilter' bundle="jdisc-security-filters"> + <config name="jdisc.http.filter.security.athenz.athenz-authorization-filter"> + <credentialsToVerify>TOKEN_ONLY</credentialsToVerify> + <roleTokenHeaderName>Yahoo-Role-Auth</roleTokenHeaderName> + </config> + <component id="com.yahoo.jdisc.http.filter.security.athenz.StaticRequestResourceMapper" bundle="jdisc-security-filters"> + <config name="jdisc.http.filter.security.athenz.static-request-resource-mapper"> + <resourceName>vespa.vespa.cd:tester-application</resourceName> + <action>deploy</action> + </config> + </component> + </filter> + </request-chain> + </filtering> + </http> + + <nodes count="1" flavor="d-2-12-75" allocated-memory="17%" /> + </container> +</services> |