aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2019-01-09 17:10:33 +0100
committerGitHub <noreply@github.com>2019-01-09 17:10:33 +0100
commit13ca7e60c64bd7f446b8dd7b0b3e6f41c7dc51c2 (patch)
treeeb39b527eaa29a4601377b8e26c9b6879c0088b0
parent0fd28cdba07b24f2452b1cc54b9786d8c65cb469 (diff)
parent55440a5d9e7e0fa4fe33412dcb61982234e0a9f9 (diff)
Merge pull request #8074 from vespa-engine/jvenstad/allow-v4-applications-without-athenz-service
Allow submissions of applications without an athenz service
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java11
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java10
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java8
3 files changed, 16 insertions, 13 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 14222ca96d2..81a4e30feac 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
@@ -504,7 +504,7 @@ public class InternalStepRunner implements StepRunner {
DeploymentSpec spec = controller.applications().require(id.application()).deploymentSpec();
ZoneId zone = id.type().zone(controller.system());
- byte[] deploymentXml = deploymentXml(spec.athenzDomain().get(), spec.athenzService(zone.environment(), zone.region()).get());
+ byte[] deploymentXml = deploymentXml(spec.athenzDomain(), spec.athenzService(zone.environment(), zone.region()));
try (ZipBuilder zipBuilder = new ZipBuilder(testPackage.length + servicesXml.length + 1000)) {
zipBuilder.add(testPackage);
@@ -591,11 +591,14 @@ public class InternalStepRunner implements StepRunner {
return servicesXml.getBytes();
}
- /** Returns a dummy deployment xml which sets up the service identity for the tester. */
- static byte[] deploymentXml(AthenzDomain domain, AthenzService service) {
+ /** Returns a dummy deployment xml which sets up the service identity for the tester, if present. */
+ private static byte[] deploymentXml(Optional<AthenzDomain> athenzDomain, Optional<AthenzService> athenzService) {
String deploymentSpec =
"<?xml version='1.0' encoding='UTF-8'?>\n" +
- "<deployment version=\"1.0\" athenz-domain=\"" + domain.value() + "\" athenz-service=\"" + service.value() + "\" />";
+ "<deployment version=\"1.0\" " +
+ athenzDomain.map(domain -> "athenz-domain=\"" + domain.value() + "\" ").orElse("") +
+ athenzService.map(service -> "athenz-service=\"" + service.value() + "\" ").orElse("")
+ + "/>";
return deploymentSpec.getBytes(StandardCharsets.UTF_8);
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index f727baf0b8f..8f8a3ad7f55 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -1321,10 +1321,10 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
String authorEmail = submitOptions.field("authorEmail").asString();
long projectId = Math.max(1, submitOptions.field("projectId").asLong());
- ApplicationPackage applicationPackage = new ApplicationPackage(dataParts.get(EnvironmentResource.APPLICATION_ZIP));
- if ( ! applicationPackage.deploymentSpec().athenzDomain().isPresent())
- throw new IllegalArgumentException("Application must define an Athenz service in deployment.xml!");
- controller.applications().verifyApplicationIdentityConfiguration(TenantName.from(tenant), applicationPackage, Optional.of(getUserPrincipal(request).getIdentity()));
+ byte[] applicationZip = dataParts.get(EnvironmentResource.APPLICATION_ZIP);
+ controller.applications().verifyApplicationIdentityConfiguration(TenantName.from(tenant),
+ new ApplicationPackage(applicationZip),
+ Optional.of(getUserPrincipal(request).getIdentity()));
return JobControllerApiHandlerHelper.submitResponse(controller.jobController(),
tenant,
@@ -1332,7 +1332,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
sourceRevision,
authorEmail,
projectId,
- applicationPackage.zippedContent(),
+ applicationZip,
dataParts.get(EnvironmentResource.APPLICATION_TEST_ZIP));
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
index d455218f4e9..5f17ea1c5c6 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
@@ -435,13 +435,13 @@ public class ApplicationApiTest extends ControllerContainerTest {
"Deactivated tenant/tenant1/application/application1/environment/prod/region/us-central-1/instance/default");
// POST an application package and a test jar, submitting a new application for internal pipeline deployment.
- // First attempt does not have an Athenz service definition in deployment spec, and fails.
+ // First attempt does not have an Athenz service definition in deployment spec, and is accepted.
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/submit", POST)
.screwdriverIdentity(SCREWDRIVER_ID)
.data(createApplicationSubmissionData(applicationPackage)),
- "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Application must define an Athenz service in deployment.xml!\"}", 400);
+ "{\"version\":\"1.0.43-d00d\"}");
- // Second attempt has a service under a different domain than the tenant of the application, and fails as well.
+ // Second attempt has a service under a different domain than the tenant of the application, and fails.
ApplicationPackage packageWithServiceForWrongDomain = new ApplicationPackageBuilder()
.environment(Environment.prod)
.athenzIdentity(com.yahoo.config.provision.AthenzDomain.from(ATHENZ_TENANT_DOMAIN_2.getName()), AthenzService.from("service"))
@@ -461,7 +461,7 @@ public class ApplicationApiTest extends ControllerContainerTest {
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/submit", POST)
.screwdriverIdentity(SCREWDRIVER_ID)
.data(createApplicationSubmissionData(packageWithService)),
- "{\"version\":\"1.0.43-d00d\"}");
+ "{\"version\":\"1.0.44-d00d\"}");
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/default/badge", GET)
.userIdentity(USER_ID),