diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-04-14 09:09:06 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-04-14 09:09:06 +0200 |
commit | e4c098e2a56a46b973924d4889e3e8f73ef8f6a3 (patch) | |
tree | fda13057dd62fc05442789defec6186196337daa /config-model | |
parent | 92a0e866562662d5be4b3aa01da2a115bc9a2a00 (diff) |
Do not request download of files for tenant hosts when on hosted
The request for download of files for tenant hosts will work, but
the download itself will not, since the application will need to be
activated before rpc request for a new file is authorized (authorizer
only knows about files for an active application and this happens in
when preparing an application)
Diffstat (limited to 'config-model')
7 files changed, 25 insertions, 15 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/test/MockRoot.java b/config-model/src/main/java/com/yahoo/config/model/test/MockRoot.java index f9492398f9f..87d6554f691 100644 --- a/config-model/src/main/java/com/yahoo/config/model/test/MockRoot.java +++ b/config-model/src/main/java/com/yahoo/config/model/test/MockRoot.java @@ -67,7 +67,7 @@ public class MockRoot extends AbstractConfigProducerRoot { super(rootConfigId); hostSystem = new HostSystem(this, "hostsystem", deployState.getProvisioner(), deployState.getDeployLogger()); this.deployState = deployState; - fileDistributor = new FileDistributor(deployState.getFileRegistry(), List.of()); + fileDistributor = new FileDistributor(deployState.getFileRegistry(), List.of(), deployState.isHosted()); } public FileDistributionConfigProducer getFileDistributionConfigProducer() { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java index 2ad394d1521..6f2123f248c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java @@ -210,7 +210,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri /** Creates a mutable model with no services instantiated */ public static VespaModel createIncomplete(DeployState deployState) throws IOException, SAXException { return new VespaModel(new NullConfigModelRegistry(), deployState, false, - new FileDistributor(deployState.getFileRegistry(), List.of())); + new FileDistributor(deployState.getFileRegistry(), List.of(), deployState.isHosted())); } private void validateWrapExceptions() { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminBuilderBase.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminBuilderBase.java index a146e2cd7e7..d2f06da992c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminBuilderBase.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminBuilderBase.java @@ -71,7 +71,7 @@ public abstract class DomAdminBuilderBase extends VespaDomBuilder.DomConfigProdu Monitoring monitoring = getMonitoring(XML.getChild(adminElement,"monitoring"), deployState.isHosted()); Metrics metrics = new MetricsBuilder(applicationType, predefinedMetricSets) .buildMetrics(XML.getChild(adminElement, "metrics")); - FileDistributionConfigProducer fileDistributionConfigProducer = getFileDistributionConfigProducer(parent); + FileDistributionConfigProducer fileDistributionConfigProducer = getFileDistributionConfigProducer(parent, deployState.isHosted()); Admin admin = new Admin(parent, monitoring, metrics, multitenant, fileDistributionConfigProducer, deployState.isHosted()); admin.setApplicationType(applicationType); @@ -81,8 +81,8 @@ public abstract class DomAdminBuilderBase extends VespaDomBuilder.DomConfigProdu return admin; } - private FileDistributionConfigProducer getFileDistributionConfigProducer(AbstractConfigProducer parent) { - return new FileDistributionConfigProducer(parent, fileRegistry, configServerSpecs); + private FileDistributionConfigProducer getFileDistributionConfigProducer(AbstractConfigProducer parent, boolean isHosted) { + return new FileDistributionConfigProducer(parent, fileRegistry, configServerSpecs, isHosted); } protected abstract void doBuildAdmin(DeployState deployState, Admin admin, Element adminE); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributionConfigProducer.java b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributionConfigProducer.java index a86b74e963a..2c6808b5773 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributionConfigProducer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributionConfigProducer.java @@ -21,8 +21,8 @@ public class FileDistributionConfigProducer extends AbstractConfigProducer { private final FileDistributor fileDistributor; public FileDistributionConfigProducer(AbstractConfigProducer ancestor, FileRegistry fileRegistry, - List<ConfigServerSpec> configServerSpec) { - this(ancestor, new FileDistributor(fileRegistry, configServerSpec)); + List<ConfigServerSpec> configServerSpec, boolean isHosted) { + this(ancestor, new FileDistributor(fileRegistry, configServerSpec, isHosted)); } private FileDistributionConfigProducer(AbstractConfigProducer parent, FileDistributor fileDistributor) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java index 591d2b2851d..5ccf86f9ba8 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java @@ -11,7 +11,10 @@ import com.yahoo.vespa.model.Host; import java.util.*; /** - * Responsible for directing distribution of files to hosts. + * Sends RPC requests to hosts (tenant hosts and config servers) to start download of files. This is used during prepare + * of an application. Services themselves will also request files, the work done in this class is done so that hosts can + * start downloading files before services gets new config that needs these files. This also tries to make sure that + * all config servers (not just the one where the application was deployed) have the files available. * * @author Tony Vaagenes */ @@ -19,13 +22,15 @@ public class FileDistributor { private final FileRegistry fileRegistry; private final List<ConfigServerSpec> configServerSpecs; + private final boolean isHosted; /** A map from file reference to the hosts to which that file reference should be distributed */ private final Map<FileReference, Set<Host>> filesToHosts = new LinkedHashMap<>(); - public FileDistributor(FileRegistry fileRegistry, List<ConfigServerSpec> configServerSpecs) { + public FileDistributor(FileRegistry fileRegistry, List<ConfigServerSpec> configServerSpecs, boolean isHosted) { this.fileRegistry = fileRegistry; this.configServerSpecs = configServerSpecs; + this.isHosted = isHosted; } /** @@ -87,14 +92,19 @@ public class FileDistributor { public void sendDeployedFiles(FileDistribution dbHandler) { String fileSourceHost = fileSourceHost(); - getTargetHosts().stream() - .filter(host -> ! host.getHostname().equals(fileSourceHost)) - .forEach(host -> dbHandler.startDownload(host.getHostname(), ConfigProxy.BASEPORT, filesToSendToHost(host))); - // Ask other config servers to download, for redundancy configServerSpecs.stream() .filter(spec -> !spec.getHostName().equals(fileSourceHost)) .forEach(spec -> dbHandler.startDownload(spec.getHostName(), spec.getConfigServerPort(), allFilesToSend())); + + // Skip starting download for application hosts when on hosted, since this is just a hint and requests for files + // will fail until the application is activated (this call is done when preparing an application deployment) + // due to authorization of RPC requests on config servers only considering files belonging to active applications + if (isHosted) return; + + getTargetHosts().stream() + .filter(host -> ! host.getHostname().equals(fileSourceHost)) + .forEach(host -> dbHandler.startDownload(host.getHostname(), ConfigProxy.BASEPORT, filesToSendToHost(host))); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java index b5915ecf033..b1550d90f35 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java @@ -60,7 +60,7 @@ public class ContentClusterUtils { public static ContentCluster createCluster(String clusterXml, MockRoot root) { Document doc = XML.getDocument(clusterXml); Admin admin = new Admin(root, new DefaultMonitoring("vespa", 60), new Metrics(), false, - new FileDistributionConfigProducer(root, new MockFileRegistry(), List.of()), + new FileDistributionConfigProducer(root, new MockFileRegistry(), List.of(), false), root.getDeployState().isHosted()); ConfigModelContext context = ConfigModelContext.create(null, root.getDeployState(), null,null, root, null); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java index 39ded69b710..55672c5aa16 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java @@ -25,7 +25,7 @@ public class FileDistributorTestCase { public void fileDistributor() { MockHosts hosts = new MockHosts(); - FileDistributor fileDistributor = new FileDistributor(new MockFileRegistry(), List.of()); + FileDistributor fileDistributor = new FileDistributor(new MockFileRegistry(), List.of(), false); String file1 = "component/path1"; String file2 = "component/path2"; |