Skip to content

Fix builder plugin import error: declare Docker SDK in requirements.txt - #3428

Open
CloudCorpRecords wants to merge 1 commit into
apache:masterfrom
CloudCorpRecords:fix/3424-builder-docker-sdk
Open

CloudCorpRecords wants to merge 1 commit into
apache:masterfrom
CloudCorpRecords:fix/3424-builder-docker-sdk

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

Description

Fixes #3424: starting CALDERA (e.g. from the Docker image) logs
ERROR Error importing plugin=builder, No module named 'docker' and the
builder plugin fails to load.

Root cause: the builder plugin imports the Python Docker SDK at module
load (import docker in plugins/builder/app/build_svc.py) and pins
docker~=6.1.0 in plugins/builder/requirements.txt, but the core
runtime environment never installs it. The Dockerfile runtime stage
installs only requirements.txt, which did not declare the SDK.

Fix: declare the SDK in requirements.txt, pinned exactly as the
plugin itself declares it (docker~=6.1.0). The Dockerfile runtime
stage already installs requirements.txt, so the image gains the
module with no Dockerfile change, and non-Docker installs (the
CONTRIBUTING.md setup path) are fixed too.

A regression test (tests/test_builder_plugin_dependency.py) asserts
the SDK is declared in requirements.txt and importable in an
environment built from it; both assertions fail without this change.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Reproduced first in a clean venv built exactly like the runtime
(pip install -r requirements.txt, Python 3.12):

  • python -c "import docker" -> ModuleNotFoundError: No module named 'docker'
  • python -c "import plugins.builder.app.build_svc" -> same error at
    plugins/builder/app/build_svc.py, line 6 (import docker)

After the change, in a venv rebuilt from the updated requirements.txt:

  • import docker succeeds (docker 6.1.3); plugins.builder.app.build_svc
    imports cleanly.
  • New tests, before fix: 2 failed. After fix: 2 passed.
  • pytest --asyncio-mode=auto tests/test_builder_plugin_dependency.py tests/api/v2/handlers/test_plugins_api.py tests/services/test_app_svc.py
    -> 13 passed (the 11 pre-existing tests in the two relevant suites
    also pass on unmodified master).
  • Directory-by-directory run of the rest of the suite on this Windows
    machine shows failures identical to unmodified master (pre-existing
    environment issues, proven by re-running the same chunks on a
    pristine checkout): tests/contacts 1 failed, tests/obfuscators
    2 errors, tests/services 1 failed / 111 passed, tests/web_server
    8 errors, tests/api does not finish within 240s — all unchanged
    with and without this patch.
  • pip-audit -r requirements.txt (the tox safety gate): no findings
    for docker; the 15 findings reported are all in pre-existing pins.
  • flake8 tests/test_builder_plugin_dependency.py clean.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

The builder plugin imports the Python Docker SDK at module load
(`import docker` in plugins/builder/app/build_svc.py) and pins
`docker~=6.1.0` in plugins/builder/requirements.txt, but the core
runtime never installed it: the Dockerfile runtime stage installs
only requirements.txt, which did not declare it. CALDERA therefore
logged "Error importing plugin=builder, No module named 'docker'"
and the plugin failed to load.

Declare the SDK in requirements.txt, pinned exactly as the plugin
itself declares it (`docker~=6.1.0`). The Dockerfile runtime stage
already installs requirements.txt, so the image gains the module
with no Dockerfile change, and non-Docker installs are fixed too.

Fixes apache#3424

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
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.

Error importing plugin=builder

1 participant