X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FContainerUtils.py;h=158eb4bc483ff8466476febbcceaeac95036320a;hb=06d9ceaaffd3183155610a60e4897ebbab64384e;hp=75acf0027aa66a98f16ad3c87eb66ecc627ab61a;hpb=d255d2545ee6cdc871bc35314fad72c3c48b225b;p=csit.git diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index 75acf0027a..158eb4bc48 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2023 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -205,8 +205,8 @@ class ContainerManager: dut_cnt = len( Counter( [ - self.containers[container].node[u"host"] - for container in self.containers + f"{container.node['host']}{container.node['port']}" + for container in self.containers.values() ] ) ) @@ -581,12 +581,17 @@ class ContainerEngine: def start_vpp(self, verify=True): """Start VPP inside a container.""" self.execute( - u"setsid /usr/bin/vpp -c /etc/vpp/startup.conf " - u">/tmp/vppd.log 2>&1 < /dev/null &") + u"/usr/bin/vpp -c /etc/vpp/startup.conf") topo_instance = BuiltIn().get_library_instance( u"resources.libraries.python.topology.Topology" ) + topo_instance.add_new_socket( + self.container.node, + SocketType.CLI, + self.container.name, + self.container.cli_socket, + ) topo_instance.add_new_socket( self.container.node, SocketType.PAPI, @@ -630,7 +635,7 @@ class ContainerEngine: # Execute puts the command into single quotes, # so inner arguments are enclosed in qouble quotes here. self.execute( - u'vppctl show pci 2>&1 | ' + u'/usr/bin/vppctl show pci 2>&1 | ' u'fgrep -v "Connection refused" | ' u'fgrep -v "No such file or directory"' ) @@ -688,7 +693,6 @@ class ContainerEngine: vpp_config = VppConfigGenerator() vpp_config.set_node(self.container.node) vpp_config.add_unix_cli_listen() - vpp_config.add_unix_nodaemon() vpp_config.add_unix_exec(u"/tmp/running.exec") vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH) if cpuset_cpus: @@ -702,9 +706,10 @@ class ContainerEngine: vpp_config.add_plugin(u"enable", u"memif_plugin.so") vpp_config.add_plugin(u"enable", u"perfmon_plugin.so") vpp_config.add_main_heap_size(u"2G") - vpp_config.add_main_heap_page_size(u"2M") + vpp_config.add_main_heap_page_size(self.container.page_size) + vpp_config.add_default_hugepage_size(self.container.page_size) vpp_config.add_statseg_size(u"2G") - vpp_config.add_statseg_page_size(u"2M") + vpp_config.add_statseg_page_size(self.container.page_size) vpp_config.add_statseg_per_node_counters(u"on") return vpp_config @@ -800,18 +805,6 @@ class ContainerEngine: :type name: str :raises RuntimeError: If applying cgroup settings via cgset failed. """ - ret, _, _ = self.container.ssh.exec_command_sudo( - u"cgset -r cpuset.cpu_exclusive=0 /" - ) - if int(ret) != 0: - raise RuntimeError(u"Failed to apply cgroup settings.") - - ret, _, _ = self.container.ssh.exec_command_sudo( - u"cgset -r cpuset.mem_exclusive=0 /" - ) - if int(ret) != 0: - raise RuntimeError(u"Failed to apply cgroup settings.") - ret, _, _ = self.container.ssh.exec_command_sudo( f"cgcreate -g cpuset:/{name}" ) @@ -819,13 +812,13 @@ class ContainerEngine: raise RuntimeError(u"Failed to copy cgroup settings from root.") ret, _, _ = self.container.ssh.exec_command_sudo( - f"cgset -r cpuset.cpu_exclusive=0 /{name}" + f"cgset -r cpuset.cpus=0 /{name}" ) if int(ret) != 0: raise RuntimeError(u"Failed to apply cgroup settings.") ret, _, _ = self.container.ssh.exec_command_sudo( - f"cgset -r cpuset.mem_exclusive=0 /{name}" + f"cgset -r cpuset.mems=0 /{name}" ) if int(ret) != 0: raise RuntimeError(u"Failed to apply cgroup settings.") @@ -856,7 +849,7 @@ class LXC(ContainerEngine): else u"amd64" image = self.container.image if self.container.image \ - else f"-d ubuntu -r focal -a {target_arch}" + else f"-d ubuntu -r jammy -a {target_arch}" cmd = f"lxc-create -t download --name {self.container.name} " \ f"-- {image} --no-validate" @@ -1121,8 +1114,8 @@ class Docker(ContainerEngine): if self.container.mnt else u"" cmd = f"docker run --privileged --detach --interactive --tty --rm " \ - f"--cgroup-parent docker {cpuset_cpus} {cpuset_mems} {publish} " \ - f"{env} {volume} --name {self.container.name} " \ + f"--cgroup-parent docker.slice {cpuset_cpus} {cpuset_mems} " \ + f"{publish} {env} {volume} --name {self.container.name} " \ f"{self.container.image} {command}" ret, _, _ = self.container.ssh.exec_command_sudo(cmd) @@ -1276,6 +1269,7 @@ class Container: path = f"/tmp/vpp_sockets/{value}" self.__dict__[u"socket_dir"] = path self.__dict__[u"api_socket"] = f"{path}/api.sock" + self.__dict__[u"cli_socket"] = f"{path}/cli.sock" self.__dict__[u"stats_socket"] = f"{path}/stats.sock" self.__dict__[attr] = value else: