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

Handle Docker version string with +dfsg1 #6732

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kripper
Copy link
Contributor

@kripper kripper commented Feb 14, 2025

The docker builder fails with this kind of docker version string:

$ docker -v
Docker version 20.10.24+dfsg1, build 297e128

Error message is:

ValueError: invalid literal for int() with base 10: '24+dfsg1'

Here is the trace:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/runtime/conftest.py:265: in _load_runtime
    call_async_from_sync(runtime.connect)
openhands/utils/async_utils.py:50: in call_async_from_sync
    result = future.result()
/usr/local/lib/python3.12/concurrent/futures/_base.py:449: in result
    return self.__get_result()
/usr/local/lib/python3.12/concurrent/futures/_base.py:401: in __get_result
    raise self._exception
/usr/local/lib/python3.12/concurrent/futures/thread.py:59: in run
    result = self.fn(*self.args, **self.kwargs)
openhands/utils/async_utils.py:44: in run
    return asyncio.run(arun())
/usr/local/lib/python3.12/asyncio/runners.py:194: in run
    return runner.run(main)
/usr/local/lib/python3.12/asyncio/runners.py:118: in run
    return self._loop.run_until_complete(task)
/usr/local/lib/python3.12/asyncio/base_events.py:686: in run_until_complete
    return future.result()
openhands/utils/async_utils.py:37: in arun
    result = await coro
openhands/runtime/impl/docker/docker_runtime.py:130: in connect
    self.runtime_container_image = build_runtime_image(
openhands/runtime/utils/runtime_build.py:137: in build_runtime_image
    result = build_runtime_image_in_folder(
openhands/runtime/utils/runtime_build.py:236: in build_runtime_image_in_folder
    _build_sandbox_image(
openhands/runtime/utils/runtime_build.py:365: in _build_sandbox_image
    image_name = runtime_builder.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <openhands.runtime.builder.docker.DockerRuntimeBuilder object at 0x7f1e38f74aa0>, path = '/tmp/tmpxvv24pmq'
tags = ['ghcr.io/all-hands-ai/runtime:oh_v0.23.0_vj75ao18sa3s9xzo_o8jfa0p9az1s25qr', 'ghcr.io/all-hands-ai/runtime:oh_v0.23.0_vj75ao18sa3s9xzo', 'ghcr.io/all-hands-ai/runtime:oh_v0.23.0_nikolaik_s_python-nodejs_t_python3.12-nodejs22']
platform = None, extra_build_args = None, use_local_cache = False

    def build(
        self,
        path: str,
        tags: list[str],
        platform: str | None = None,
        extra_build_args: list[str] | None = None,
        use_local_cache: bool = False,
    ) -> str:
        """Builds a Docker image using BuildKit and handles the build logs appropriately.

        Args:
            path (str): The path to the Docker build context.
            tags (list[str]): A list of image tags to apply to the built image.
            platform (str, optional): The target platform for the build. Defaults to None.
            use_local_cache (bool, optional): Whether to use and update the local build cache. Defaults to True.
            extra_build_args (list[str], optional): Additional arguments to pass to the Docker build command. Defaults to None.

        Returns:
            str: The name of the built Docker image.

        Raises:
            AgentRuntimeBuildError: If the Docker server version is incompatible or if the build process fails.

        Note:
            This method uses Docker BuildKit for improved build performance and caching capabilities.
            If `use_local_cache` is True, it will attempt to use and update the build cache in a local directory.
            The `extra_build_args` parameter allows for passing additional Docker build arguments as needed.
        """
        self.docker_client = docker.from_env()
        version_info = self.docker_client.version()
        server_version = version_info.get('Version', '').replace('-', '.')
>       if tuple(map(int, server_version.split('.'))) < (18, 9):
E       ValueError: invalid literal for int() with base 10: '24+dfsg1'

openhands/runtime/builder/docker.py:71: ValueError
================================================================== short test summary info ==================================================================
FAILED tests/runtime/test_browsing_html.py::test_simple_browse[DockerRuntime-True] - ValueError: invalid literal for int() with base 10: '24+dfsg1'
===================================================================== 1 failed in 7.38s =====================================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant