diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-04-30 18:24:58 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-04-30 18:24:58 +0200 |
commit | 59abe4286a6b9c550c83c59b0a114c37b01db726 (patch) | |
tree | 6ff7d7776bdd0029335beb43fb4e7ef10c1a9fd0 /node-admin/src/test/java | |
parent | f3c67d39861da9138f2948998435d502008442c8 (diff) |
Mount /etc/machine-id and /var/log/journal
When /var/log/journal is mounted explicitly (/var/log is already mounted, but
that's not sufficient), Docker/systemd will not mount the container's
/var/log/journal/MACHINE-ID on the host's /var/log/journal/MACHINE-ID.
Also, upgrades and restarts of a container will now reuse the same machine ID,
as /etc/machine-id is written once and mounted in. Dirtying the container node
means a new machine ID must be written for the same hostname later.
Diffstat (limited to 'node-admin/src/test/java')
2 files changed, 7 insertions, 6 deletions
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java index 1c6a82d0bef..bacebcc42c0 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImplTest.java @@ -3,7 +3,6 @@ package com.yahoo.vespa.hosted.node.admin.docker; import com.google.common.net.InetAddresses; import com.yahoo.config.provision.DockerImage; -import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.hosted.dockerapi.Container; import com.yahoo.vespa.hosted.dockerapi.ContainerName; import com.yahoo.vespa.hosted.dockerapi.Docker; @@ -14,11 +13,12 @@ import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContextImpl; import com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddresses; import com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddressesMock; import com.yahoo.vespa.hosted.node.admin.task.util.process.TestTerminal; +import com.yahoo.vespa.test.file.TestFileSystem; import org.junit.Test; import org.mockito.InOrder; import java.net.InetAddress; -import java.nio.file.Paths; +import java.nio.file.FileSystem; import java.util.Optional; import java.util.OptionalLong; @@ -36,8 +36,9 @@ public class DockerOperationsImplTest { private final Docker docker = mock(Docker.class); private final TestTerminal terminal = new TestTerminal(); private final IPAddresses ipAddresses = new IPAddressesMock(); + private final FileSystem fileSystem = TestFileSystem.create(); private final DockerOperationsImpl dockerOperations = new DockerOperationsImpl( - docker, terminal, ipAddresses, new InMemoryFlagSource()); + docker, terminal, ipAddresses, fileSystem); @Test public void processResultFromNodeProgramWhenSuccess() { @@ -98,7 +99,7 @@ public class DockerOperationsImplTest { dockerOperations.addEtcHosts(containerData, hostname, Optional.empty(), Optional.of(ipV6Local)); verify(containerData, times(1)).addFile( - Paths.get("/etc/hosts"), + fileSystem.getPath("/etc/hosts"), "# This file was generated by com.yahoo.vespa.hosted.node.admin.docker.DockerOperationsImpl\n" + "127.0.0.1 localhost\n" + "::1 localhost ip6-localhost ip6-loopback\n" + @@ -111,7 +112,7 @@ public class DockerOperationsImplTest { dockerOperations.addEtcHosts(containerData, hostname, Optional.of(ipV4Local), Optional.of(ipV6Local)); verify(containerData, times(1)).addFile( - Paths.get("/etc/hosts"), + fileSystem.getPath("/etc/hosts"), "# This file was generated by com.yahoo.vespa.hosted.node.admin.docker.DockerOperationsImpl\n" + "127.0.0.1 localhost\n" + "::1 localhost ip6-localhost ip6-loopback\n" + diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java index a1ea3558504..19f991b2ce8 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/integrationTests/DockerTester.java @@ -81,7 +81,7 @@ public class DockerTester implements AutoCloseable { Clock clock = Clock.systemUTC(); Metrics metrics = new Metrics(); FileSystem fileSystem = TestFileSystem.create(); - DockerOperations dockerOperations = new DockerOperationsImpl(docker, terminal, ipAddresses, flagSource); + DockerOperations dockerOperations = new DockerOperationsImpl(docker, terminal, ipAddresses, fileSystem); NodeAgentFactory nodeAgentFactory = (contextSupplier, nodeContext) -> new NodeAgentImpl( contextSupplier, nodeRepository, orchestrator, dockerOperations, storageMaintainer, flagSource, |