diff options
author | jonmv <venstad@gmail.com> | 2024-01-19 09:09:05 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2024-01-19 09:09:05 +0100 |
commit | 5fc81a76b3350ddd41918e9ed9be2b729d8561c4 (patch) | |
tree | 6fab17ab9ca840c1ca1ef1419707beb7390ab44b /configserver/src | |
parent | 690e3c6cd32c157c31679e1a9516ec9afc58982f (diff) |
Restore prepareandactivate response
Diffstat (limited to 'configserver/src')
3 files changed, 27 insertions, 9 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java index 0823f8f75c2..737fb787937 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java @@ -8,6 +8,7 @@ import com.yahoo.config.provision.ApplicationLockException; import com.yahoo.config.provision.ParentHostUnavailableException; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Zone; +import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.utils.MultiPartFormParser; @@ -63,15 +64,18 @@ public class ApplicationApiHandler extends SessionHandler { private final TenantRepository tenantRepository; private final Duration zookeeperBarrierTimeout; private final long maxApplicationPackageSize; + private final Zone zone; @Inject public ApplicationApiHandler(Context ctx, ApplicationRepository applicationRepository, - ConfigserverConfig configserverConfig) { + ConfigserverConfig configserverConfig, + Zone zone) { super(ctx, applicationRepository); this.tenantRepository = applicationRepository.tenantRepository(); this.zookeeperBarrierTimeout = Duration.ofSeconds(configserverConfig.zookeeper().barrierTimeout()); this.maxApplicationPackageSize = configserverConfig.maxApplicationPackageSize(); + this.zone = zone; } @Override @@ -127,7 +131,7 @@ public class ApplicationApiHandler extends SessionHandler { try (compressedStream) { PrepareAndActivateResult result = applicationRepository.deploy(compressedStream, prepareParams); - return new SessionPrepareAndActivateResponse(result, prepareParams.getApplicationId()); + return new SessionPrepareAndActivateResponse(result, prepareParams.getApplicationId(), request, zone); } catch (IOException e) { throw new UncheckedIOException(e); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/response/SessionPrepareAndActivateResponse.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/response/SessionPrepareAndActivateResponse.java index 11ce933b6f3..f5d8efbe4e5 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/response/SessionPrepareAndActivateResponse.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/response/SessionPrepareAndActivateResponse.java @@ -9,7 +9,6 @@ import com.yahoo.restapi.SlimeJsonResponse; import com.yahoo.slime.Cursor; import com.yahoo.vespa.config.server.configchange.ConfigChangeActionsSlimeConverter; import com.yahoo.vespa.config.server.http.v2.PrepareAndActivateResult; -import com.yahoo.vespa.config.server.http.v2.PrepareResult; /** * Creates a response for ApplicationApiHandler. @@ -18,7 +17,7 @@ import com.yahoo.vespa.config.server.http.v2.PrepareResult; */ public class SessionPrepareAndActivateResponse extends SlimeJsonResponse { - public SessionPrepareAndActivateResponse(PrepareAndActivateResult result, ApplicationId applicationId) { + public SessionPrepareAndActivateResponse(PrepareAndActivateResult result, ApplicationId applicationId, HttpRequest request, Zone zone) { super(result.prepareResult().deployLogger().slime()); TenantName tenantName = applicationId.tenant(); @@ -27,8 +26,15 @@ public class SessionPrepareAndActivateResponse extends SlimeJsonResponse { Cursor root = slime.get(); root.setString("message", message); - root.setString("sessionId", Long.toString(result.prepareResult().sessionId())); + root.setString("session-id", Long.toString(result.prepareResult().sessionId())); root.setBool("activated", result.activationFailure() == null); + root.setString("tenant", tenantName.value()); + root.setString("url", "http://" + request.getHost() + ":" + request.getPort() + + "/application/v2/tenant/" + tenantName + + "/application/" + applicationId.application().value() + + "/environment/" + zone.environment().value() + + "/region/" + zone.region().value() + + "/instance/" + applicationId.instance().value()); new ConfigChangeActionsSlimeConverter(result.prepareResult().configChangeActions()).toSlime(root); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandlerTest.java index 3fb5aa45a36..36892860295 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandlerTest.java @@ -6,6 +6,7 @@ import com.yahoo.config.model.provision.InMemoryProvisioner; import com.yahoo.config.provision.ApplicationLockException; import com.yahoo.config.provision.ParentHostUnavailableException; import com.yahoo.config.provision.TenantName; +import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.ThreadedHttpRequestHandler.Context; import com.yahoo.jdisc.http.HttpRequest.Method; @@ -108,7 +109,8 @@ class ApplicationApiHandlerTest { .build(); handler = new ApplicationApiHandler(new Context(Runnable::run, null), applicationRepository, - configserverConfig); + configserverConfig, + Zone.defaultZone()); } private HttpResponse put(long sessionId, Map<String, String> parameters) throws IOException { @@ -158,8 +160,10 @@ class ApplicationApiHandlerTest { { "log": [ ], "message": "Session 2 for tenant 'test' prepared and activated.", - "sessionId": "2", + "session-id": "2", "activated": true, + "tenant": "test", + "url": "http://host:123/application/v2/tenant/test/application/default/environment/prod/region/default/instance/default", "configChangeActions": { "restart": [ ], "refeed": [ ], @@ -216,8 +220,10 @@ class ApplicationApiHandlerTest { { "log": [ ], "message": "Session 2 for tenant 'test' prepared, but activation failed: host still booting", - "sessionId": "2", + "session-id": "2", "activated": false, + "tenant": "test", + "url": "http://host:123/application/v2/tenant/test/application/default/environment/prod/region/default/instance/default", "configChangeActions": { "restart": [ ], "refeed": [ ], @@ -234,8 +240,10 @@ class ApplicationApiHandlerTest { { "log": [ ], "message": "Session 3 for tenant 'test' prepared, but activation failed: lock timeout", - "sessionId": "3", + "session-id": "3", "activated": false, + "tenant": "test", + "url": "http://host:123/application/v2/tenant/test/application/default/environment/prod/region/default/instance/default", "configChangeActions": { "restart": [ ], "refeed": [ ], |