Skip to content

Switch docker build telemetry from plain-text regex parsing to rawjson + metadata-file #2425

@simonrosenberg

Description

@simonrosenberg

Problem

The current docker build telemetry in openhands-agent-server/openhands/agent_server/docker/build.py is extracted by regex-parsing BuildKit plain-text progress output from docker buildx build. That works, but it is inherently tied to human-readable progress strings like exporting cache to, pushing layers, and exporting manifest, which is a fragile boundary for SDK telemetry.

Proposed change

Replace the regex-based plain-text parsing with Buildx/BuildKit’s structured outputs:

  • pass --progress=rawjson to docker buildx build
  • pass --metadata-file <tmpfile> to capture final build metadata
  • parse JSON-line progress events for timing/progress telemetry
  • parse the metadata file for final build metadata
  • remove the regex parser rather than keeping a plain-text fallback

Why

  • rawjson is the machine-oriented progress mode exposed by docker buildx build
  • --metadata-file gives structured final result metadata
  • this is a cleaner and more reliable telemetry boundary than parsing terminal-oriented text output

Scope

  • update build_with_telemetry() to request rawjson progress and a metadata file
  • replace _parse_buildkit_telemetry() with JSON-based parsing
  • thread any useful metadata-file fields into the telemetry/result model where appropriate
  • update tests to validate JSON progress parsing instead of regex matching plain-text stderr

Acceptance criteria

  • no regex parsing of BuildKit plain-text progress remains in the telemetry path
  • telemetry still includes the currently useful phase timings/counts where available
  • final build metadata is captured from --metadata-file
  • tests cover successful builds and failed builds under the new parsing path

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions