diff options
author | Morten Tokle <mortent@yahooinc.com> | 2022-09-13 14:47:17 +0200 |
---|---|---|
committer | Morten Tokle <mortent@yahooinc.com> | 2022-09-13 14:47:17 +0200 |
commit | 8c1062b6fd62c6948610eb41b72617be581b7dbf (patch) | |
tree | e4035d9fb2c33dc337cc00af82811a89a05521f2 | |
parent | 02fc1590ec8b7809ed1e7b5511fd510fd2d89be6 (diff) |
Read flag when setting up document api
2 files changed, 17 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index 4c94708d892..bb45c509b5b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -194,7 +194,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { addProcessing(deployState, spec, cluster); addSearch(deployState, spec, cluster); addDocproc(deployState, spec, cluster); - addDocumentApi(spec, cluster); // NOTE: Must be done after addSearch + addDocumentApi(deployState, spec, cluster); // NOTE: Must be done after addSearch cluster.addDefaultHandlersExceptStatus(); addStatusHandlers(cluster, context.getDeployState().isHosted()); @@ -520,8 +520,8 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { return http; } - private void addDocumentApi(Element spec, ApplicationContainerCluster cluster) { - ContainerDocumentApi containerDocumentApi = buildDocumentApi(cluster, spec); + private void addDocumentApi(DeployState deployState, Element spec, ApplicationContainerCluster cluster) { + ContainerDocumentApi containerDocumentApi = buildDocumentApi(deployState, cluster, spec); if (containerDocumentApi == null) return; cluster.setDocumentApi(containerDocumentApi); @@ -919,13 +919,15 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { : bindingPattern; } - private ContainerDocumentApi buildDocumentApi(ApplicationContainerCluster cluster, Element spec) { + private ContainerDocumentApi buildDocumentApi(DeployState deployState, ApplicationContainerCluster cluster, Element spec) { Element documentApiElement = XML.getChild(spec, "document-api"); if (documentApiElement == null) return null; ContainerDocumentApi.HandlerOptions documentApiOptions = DocumentApiOptionsBuilder.build(documentApiElement); Element ignoreUndefinedFields = XML.getChild(documentApiElement, "ignore-undefined-fields"); - OptionalInt portBindingOverride = cluster.isHostedVespa()? OptionalInt.of(HOSTED_VESPA_DATAPLANE_PORT) : OptionalInt.empty(); + OptionalInt portBindingOverride = deployState.featureFlags().useRestrictedDataPlaneBindings() && deployState.isHosted() + ? OptionalInt.of(HOSTED_VESPA_DATAPLANE_PORT) + : OptionalInt.empty(); return new ContainerDocumentApi(cluster, documentApiOptions, "true".equals(XML.getValue(ignoreUndefinedFields)), portBindingOverride); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/HandlerBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/HandlerBuilderTest.java index 0c9b87c0ae3..186842ecbf1 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/HandlerBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/HandlerBuilderTest.java @@ -115,6 +115,14 @@ public class HandlerBuilderTest extends ContainerModelBuilderTestBase { } @Test + void does_not_restrict_default_bindings_in_hosted_vespa_when_disabled() { + DeployState deployState = new DeployState.Builder() + .properties(new TestProperties().setHostedVespa(true).setUseRestrictedDataPlaneBindings(false)) + .build(); + verifyDefaultBindings(deployState, "http://*"); + } + + @Test void restricts_custom_bindings_in_hosted_vespa() { DeployState deployState = new DeployState.Builder() .properties(new TestProperties().setHostedVespa(true).setUseRestrictedDataPlaneBindings(true)) @@ -125,7 +133,7 @@ public class HandlerBuilderTest extends ContainerModelBuilderTestBase { @Test void does_not_restrict_default_bindings_in_self_hosted() { DeployState deployState = new DeployState.Builder() - .properties(new TestProperties().setHostedVespa(false).setUseRestrictedDataPlaneBindings(true)) + .properties(new TestProperties().setHostedVespa(false).setUseRestrictedDataPlaneBindings(false)) .build(); verifyDefaultBindings(deployState, "http://*"); } @@ -133,7 +141,7 @@ public class HandlerBuilderTest extends ContainerModelBuilderTestBase { @Test void does_not_restrict_custom_bindings_in_self_hosted() { DeployState deployState = new DeployState.Builder() - .properties(new TestProperties().setHostedVespa(false).setUseRestrictedDataPlaneBindings(true)) + .properties(new TestProperties().setHostedVespa(false).setUseRestrictedDataPlaneBindings(false)) .build(); verifyCustomSearchBindings(deployState, "http://*"); } |