Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPDK: install path fixes for meson and Ubuntu 24.04 #3598

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check_exists( ..., minimum_version) considered harmful
Undoing a change I added which enabled a _minimum_version check on
_check_exists. This is a bad system because you'll end up needing to do
things like this:

if not posix_os._check_exists(pkg, minimum_version=...):
	# Now what? Was it installed or not?
	# Was it installed and just the wrong version?

The ultimate fix should be is_package_in_repo(pkg, minimum_version)
Since we should be checking if an available package is the right version
_before_ installing it blindly.

This all seems out-of-scope for fixing a bug installing meson
in _just_ the DPDK suite. So, I'm removing it. We can move the fixed
install pattern to the operating_system.py level later if anyone else
needs it.
  • Loading branch information
mcgov committed Feb 5, 2025
commit 74d880804f8576197daeab408e01d0ef7bc851ae
23 changes: 7 additions & 16 deletions lisa/operating_system.py
Original file line number Diff line number Diff line change
@@ -407,7 +407,6 @@ def uninstall_packages(
def package_exists(
self,
package: Union[str, Tool, Type[Tool]],
minimum_version: Optional[VersionInfo] = None,
) -> bool:
"""
Query if a package/tool is installed on the node.
@@ -416,15 +415,7 @@ def package_exists(
package_name = self.__resolve_package_name(package)
exists = self._package_exists(package_name)
self._log.debug(f"package '{package}' exists: {exists}")
if minimum_version is None or not exists:
return exists

actual_version = self.get_package_information(package_name=package_name)
self._log.debug(
f"package '{package}' expected min version: "
f"{str(minimum_version)}, actual version: {str(actual_version)}"
)
return actual_version >= minimum_version
return exists

def is_package_in_repo(self, package: Union[str, Tool, Type[Tool]]) -> bool:
"""
@@ -2122,14 +2113,14 @@ def _uninstall_packages(
remove_packages = " ".join(packages)
command += f" rm {remove_packages}"
self.wait_running_process("zypper")
install_result = self._node.execute(
uninstall_result = self._node.execute(
command, shell=True, sudo=True, timeout=timeout
)
assert_that(install_result.exit_code).described_as(
f"Failed to remove {remove_packages}. "
f"exit_code: {install_result.exit_code}, "
f"stderr: {install_result.stderr}"
).is_equal_to(0)
uninstall_result.assert_exit_code(
expected_exit_code=0,
message=f"Could not uninstall package(s): {remove_packages}",
include_output=True,
)
self._log.debug(f"{packages} is/are removed successfully.")

def _install_packages(
42 changes: 28 additions & 14 deletions lisa/tools/meson.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
from lisa.executable import Tool
from lisa.operating_system import Posix
from lisa.util import parse_version

from .ln import Ln
from .python import Pip
from .whoami import Whoami
@@ -40,32 +41,45 @@ def _install(self) -> bool:
package_available = ""
# packaged as 'meson' on older systems and 'python3-meson' on newer ones,
# since it's actually just a python package.
# So check for both
# But now we have a bunch of annoying cases.
# 'meson' is installed but the wrong version
# meson is installed but the right version
# meson is not installed and it's the wrong version
# meson is not installed and it's the right version
for pkg in [
"python3-meson",
"meson",
]:
if posix_os.package_exists(pkg, minimum_version=self._minimum_version):
if posix_os.package_exists(pkg):
package_installed = pkg
break
elif posix_os.is_package_in_repo(pkg):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elif to if is the same, but it means the two if blocks are actually independent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be more specific with your request from me?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif posix_os.is_package_in_repo(pkg):
if posix_os.is_package_in_repo(pkg):

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. So making just that change will introduce an unintended side effect of updating the package before we check the version of the currently installed package. Let me see if I can make the decisions more clear in the code. I was intentionally not installing an updated version from the package manager if one was already installed because it was convenient for my meson use cases... But really it would be better to write for the general case; even though it will be a little uglier and use another round trip or two.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't so bad to rework! Testing the more commented, reworked version now

package_available = pkg
break

# prefer the packaged version as long as it's the right version
if package_installed:
return self._check_exists()
# install the available package, if one was available and not installed
if package_available:
posix_os.install_packages(package_available)
# verify version is correct if it's installed from pkg manager
if not posix_os.package_exists(pkg, minimum_version=self._minimum_version):
posix_os.uninstall_packages(pkg)
package_available = ""

# otherwise, install with pip
# this can get weird on some systems since they have started
# returning an error code if you try to use pip without a venv
if not (package_available or package_installed):
package_installed = package_available

# now, if either previoulsy or newly installed package, check the version
if package_installed:
if (
posix_os.get_package_information(package_installed, use_cached=False)
< self._minimum_version
):
# and uninstall if the version is not recent enough
posix_os.uninstall_packages(package_installed)
package_installed = ""
else:
# otherwise, we're done.
return self._check_exists()

# If we get here, we couldn't find a good version from the package manager
# so we will install with pip. This is least desirable since it introduces
# unpredictable behavior when running meson or ninja with sudo.
# Like sudo ninja install, for example.
if not package_installed:
username = self.node.tools[Whoami].get_username()
self.node.tools[Pip].install_packages("meson", install_to_user=True)
self.node.tools[Ln].create_link(