diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-01-21 10:59:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 10:59:06 +0100 |
commit | b63d5ee7262d7ed78742fdd01e4f7cfc2edbf0ee (patch) | |
tree | 8cccb05396a543043d45db2641ef86ee1c747799 /node-admin | |
parent | ffab16edb4a93874f0e76b03470bdb83f192d57e (diff) | |
parent | cfb499d7e64c69b0f2503e5225c321b37eba37a2 (diff) |
Merge pull request #16130 from vespa-engine/mpolden/rhel8-pkg
Handle RHEL 8 package name
Diffstat (limited to 'node-admin')
8 files changed, 92 insertions, 65 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/ContainerNetworkMode.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/ContainerNetworkMode.java new file mode 100644 index 00000000000..a63b88ab0aa --- /dev/null +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/ContainerNetworkMode.java @@ -0,0 +1,32 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.node.admin.docker; + +import java.util.Objects; + +/** + * Container network modes supported by node-admin. + * + * @author hakon + */ +public enum ContainerNetworkMode { + + /** Network Prefix-Translated networking. */ + NPT("vespa-bridge"), + + /** A host running a single container in the host network namespace. */ + HOST_NETWORK("host"), + + /** A host running multiple containers in a shared local network. */ + LOCAL("vespa-bridge"); + + private final String networkName; + + ContainerNetworkMode(String networkName) { + this.networkName = Objects.requireNonNull(networkName); + } + + public String networkName() { + return networkName; + } + +} diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/ContainerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/ContainerOperationsImpl.java index 0a1cac73882..40e1622fa0d 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/ContainerOperationsImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/ContainerOperationsImpl.java @@ -98,10 +98,10 @@ public class ContainerOperationsImpl implements ContainerOperations { if (context.node().membership().map(m -> m.type().isContent()).orElse(false)) command.withSecurityOpt("seccomp=unconfined"); - DockerNetworking networking = context.dockerNetworking(); - command.withNetworkMode(networking.getDockerNetworkMode()); + ContainerNetworkMode networkMode = context.networkMode(); + command.withNetworkMode(networkMode.networkName()); - if (networking == DockerNetworking.NPT) { + if (networkMode == ContainerNetworkMode.NPT) { Optional<? extends InetAddress> ipV4Local = ipAddresses.getIPv4Address(context.node().hostname()); Optional<? extends InetAddress> ipV6Local = ipAddresses.getIPv6Address(context.node().hostname()); @@ -109,7 +109,7 @@ public class ContainerOperationsImpl implements ContainerOperations { assertEqualIpAddresses(context.hostname(), ipV6Local, context.node().ipAddresses(), IPVersion.IPv6); if (ipV4Local.isEmpty() && ipV6Local.isEmpty()) { - throw new ConvergenceException("Container " + context.node().hostname() + " with " + networking + + throw new ConvergenceException("Container " + context.node().hostname() + " with " + networkMode + " networking must have at least 1 IP address, but found none"); } @@ -120,7 +120,7 @@ public class ContainerOperationsImpl implements ContainerOperations { ipV4Local.ifPresent(command::withIpAddress); addEtcHosts(containerData, context.node().hostname(), ipV4Local, ipV6Local); - } else if (networking == DockerNetworking.LOCAL) { + } else if (networkMode == ContainerNetworkMode.LOCAL) { var ipv4Address = ipAddresses.getIPv4Address(context.node().hostname()) .orElseThrow(() -> new IllegalArgumentException("No IPv4 address could be resolved from '" + context.hostname()+ "'")); command.withIpAddress(ipv4Address); diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerNetworking.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerNetworking.java deleted file mode 100644 index dfcb9e11df6..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerNetworking.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.node.admin.docker;// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -/** - * The types of network setup for the Docker containers. - * - * @author hakon - */ -public enum DockerNetworking { - - /** Network Prefix-Translated networking. */ - NPT("vespa-bridge"), - - /** A host running a single container in the host network namespace. */ - HOST_NETWORK("host"), - - /** A host running multiple containers in a shared local network. */ - LOCAL("vespa-bridge"); - - private final String dockerNetworkMode; - DockerNetworking(String dockerNetworkMode) { - this.dockerNetworkMode = dockerNetworkMode; - } - - public String getDockerNetworkMode() { - return dockerNetworkMode; - } - -} diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContext.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContext.java index 3c6df0c74a2..8b095a46dcf 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContext.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContext.java @@ -9,7 +9,7 @@ import com.yahoo.vespa.hosted.dockerapi.ContainerName; import com.yahoo.vespa.hosted.node.admin.component.TaskContext; import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.Acl; import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec; -import com.yahoo.vespa.hosted.node.admin.docker.DockerNetworking; +import com.yahoo.vespa.hosted.node.admin.docker.ContainerNetworkMode; import java.nio.file.FileSystem; import java.nio.file.Path; @@ -36,7 +36,7 @@ public interface NodeAgentContext extends TaskContext { AthenzIdentity identity(); - DockerNetworking dockerNetworking(); + ContainerNetworkMode networkMode(); ZoneApi zone(); diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java index 1ff8c41ade8..f93cd005fae 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentContextImpl.java @@ -14,7 +14,7 @@ import com.yahoo.vespa.flags.PermanentFlags; import com.yahoo.vespa.hosted.dockerapi.ContainerName; import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.Acl; import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec; -import com.yahoo.vespa.hosted.node.admin.docker.DockerNetworking; +import com.yahoo.vespa.hosted.node.admin.docker.ContainerNetworkMode; import java.nio.file.FileSystem; import java.nio.file.FileSystems; @@ -37,7 +37,7 @@ public class NodeAgentContextImpl implements NodeAgentContext { private final Acl acl; private final ContainerName containerName; private final AthenzIdentity identity; - private final DockerNetworking dockerNetworking; + private final ContainerNetworkMode containerNetworkMode; private final ZoneApi zone; private final FileSystem fileSystem; private final Path pathToNodeRootOnHost; @@ -48,7 +48,7 @@ public class NodeAgentContextImpl implements NodeAgentContext { private final Set<NodeAgentTask> disabledNodeAgentTasks; public NodeAgentContextImpl(NodeSpec node, Acl acl, AthenzIdentity identity, - DockerNetworking dockerNetworking, ZoneApi zone, + ContainerNetworkMode containerNetworkMode, ZoneApi zone, FileSystem fileSystem, FlagSource flagSource, Path pathToContainerStorage, Path pathToVespaHome, String vespaUser, String vespaUserOnHost, double cpuSpeedup) { @@ -59,7 +59,7 @@ public class NodeAgentContextImpl implements NodeAgentContext { this.acl = Objects.requireNonNull(acl); this.containerName = ContainerName.fromHostname(node.hostname()); this.identity = Objects.requireNonNull(identity); - this.dockerNetworking = Objects.requireNonNull(dockerNetworking); + this.containerNetworkMode = Objects.requireNonNull(containerNetworkMode); this.zone = Objects.requireNonNull(zone); this.fileSystem = Objects.requireNonNull(fileSystem); this.pathToNodeRootOnHost = requireValidPath(pathToContainerStorage).resolve(containerName.asString()); @@ -93,8 +93,8 @@ public class NodeAgentContextImpl implements NodeAgentContext { } @Override - public DockerNetworking dockerNetworking() { - return dockerNetworking; + public ContainerNetworkMode networkMode() { + return containerNetworkMode; } @Override @@ -178,17 +178,17 @@ public class NodeAgentContextImpl implements NodeAgentContext { @Override public String toString() { return "NodeAgentContextImpl{" + - "node=" + node + - ", acl=" + acl + - ", containerName=" + containerName + - ", identity=" + identity + - ", dockerNetworking=" + dockerNetworking + - ", zone=" + zone + - ", pathToNodeRootOnHost=" + pathToNodeRootOnHost + - ", pathToVespaHome=" + pathToVespaHome + - ", vespaUser='" + vespaUser + '\'' + - ", vespaUserOnHost='" + vespaUserOnHost + '\'' + - '}'; + "node=" + node + + ", acl=" + acl + + ", containerName=" + containerName + + ", identity=" + identity + + ", dockerNetworking=" + containerNetworkMode + + ", zone=" + zone + + ", pathToNodeRootOnHost=" + pathToNodeRootOnHost + + ", pathToVespaHome=" + pathToVespaHome + + ", vespaUser='" + vespaUser + '\'' + + ", vespaUserOnHost='" + vespaUserOnHost + '\'' + + '}'; } private Path requireValidPath(Path path) { @@ -208,7 +208,7 @@ public class NodeAgentContextImpl implements NodeAgentContext { private NodeSpec.Builder nodeSpecBuilder; private Acl acl; private AthenzIdentity identity; - private DockerNetworking dockerNetworking; + private ContainerNetworkMode containerNetworkMode; private ZoneApi zone; private String vespaUser; private String vespaUserOnHost; @@ -244,8 +244,8 @@ public class NodeAgentContextImpl implements NodeAgentContext { return this; } - public Builder dockerNetworking(DockerNetworking dockerNetworking) { - this.dockerNetworking = dockerNetworking; + public Builder dockerNetworking(ContainerNetworkMode containerNetworkMode) { + this.containerNetworkMode = containerNetworkMode; return this; } @@ -285,7 +285,7 @@ public class NodeAgentContextImpl implements NodeAgentContext { nodeSpecBuilder.build(), Optional.ofNullable(acl).orElse(Acl.EMPTY), Optional.ofNullable(identity).orElseGet(() -> new AthenzService("domain", "service")), - Optional.ofNullable(dockerNetworking).orElse(DockerNetworking.HOST_NETWORK), + Optional.ofNullable(containerNetworkMode).orElse(ContainerNetworkMode.HOST_NETWORK), Optional.ofNullable(zone).orElseGet(() -> new ZoneApi() { @Override public SystemName getSystemName() { diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java index 88f64e22ea5..f3fa6bc65e4 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageName.java @@ -43,9 +43,9 @@ public class YumPackageName { private static final Pattern ARCHITECTURE_PATTERN = Pattern.compile("\\.(" + ARCHITECTURES_OR + "|\\*)$"); private static final Pattern EPOCH_PATTERN = Pattern.compile("^((.+)-)?([0-9]+)$"); private static final Pattern NAME_VER_REL_PATTERN = Pattern.compile("^((.+)-)?" + - "([a-z0-9._]*[0-9][a-z0-9._]*)-" + // ver contains at least one digit - "([a-z0-9._]*[0-9][a-z0-9._]*)$"); // rel contains at least one digit - private static final Pattern NAME_PATTERN = Pattern.compile("^[()a-zA-Z0-9._-]+$"); + "([+()a-z0-9._]*[0-9][a-z0-9._]*)-" + // ver contains at least one digit + "([+()a-z0-9._]*[0-9][a-z0-9._]*)$"); // rel contains at least one digit + private static final Pattern NAME_PATTERN = Pattern.compile("^[+()a-zA-Z0-9._-]+$"); private final Optional<String> epoch; private final String name; diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumTester.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumTester.java index 270f2107b87..589362e747f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumTester.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumTester.java @@ -119,7 +119,9 @@ public class YumTester extends Yum { public YumTester andReturn(boolean value) { // Pretend package is already correctly version locked to simplify expectations terminal.expectCommand("yum --version 2>&1", 0, yumVersion.toFullString() + "\ntrailing garbage\n"); - terminal.expectCommand("yum --quiet versionlock list 2>&1", 0, packages.get(0).toVersionLockName(yumVersion)); + + String quiet = yumVersion.getMajor() < 4 ? " --quiet" : ""; + terminal.expectCommand("yum" + quiet +" versionlock list 2>&1", 0, packages.get(0).toVersionLockName(yumVersion)); return super.andReturn(value); } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java index 3a8868d70f9..0880640b84d 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/yum/YumPackageNameTest.java @@ -106,6 +106,17 @@ public class YumPackageNameTest { "x86_64", "2:docker-1.12.6-71.git3e8e77d.el7.centos.1.x86_64", "2:docker-1.12.6-71.git3e8e77d.el7.centos.1.*"); + + // name-ver-rel.arch (RHEL 8) + verifyPackageName("podman-1.9.3-2.module+el8.2.1+6867+366c07d6.x86_64", + null, + "podman", + "1.9.3", + "2.module+el8.2.1+6867+366c07d6", + "x86_64", + "podman-0:1.9.3-2.module+el8.2.1+6867+366c07d6.x86_64", + "podman-0:1.9.3-2.module+el8.2.1+6867+366c07d6.*", + YumVersion.rhel8); } private void verifyPackageName(String packageName, @@ -116,24 +127,35 @@ public class YumPackageNameTest { String architecture, String toName, String toVersionName) { - Version yumVersion = Version.fromString("3"); + verifyPackageName(packageName, epoch, name, version, release, architecture, toName, toVersionName, YumVersion.rhel7); + } + + private void verifyPackageName(String packageName, + String epoch, + String name, + String version, + String release, + String architecture, + String toName, + String toVersionName, + YumVersion yumVersion) { YumPackageName yumPackageName = YumPackageName.fromString(packageName); verifyValue(epoch, yumPackageName.getEpoch()); verifyValue(name, Optional.of(yumPackageName.getName())); verifyValue(version, yumPackageName.getVersion()); verifyValue(release, yumPackageName.getRelease()); verifyValue(architecture, yumPackageName.getArchitecture()); - verifyValue(toName, Optional.of(yumPackageName.toName(yumVersion))); + verifyValue(toName, Optional.of(yumPackageName.toName(yumVersion.asVersion()))); if (toVersionName == null) { try { - yumPackageName.toVersionLockName(yumVersion); + yumPackageName.toVersionLockName(yumVersion.asVersion()); fail(); } catch (IllegalStateException e) { assertThat(e.getMessage(), containsStringIgnoringCase("Version is missing ")); } } else { - assertEquals(toVersionName, yumPackageName.toVersionLockName(yumVersion)); + assertEquals(toVersionName, yumPackageName.toVersionLockName(yumVersion.asVersion())); } } |