Improve error logging in docker-machine executor

What does this MR do?

Include the actual error when logging docker-machine wrapped executor preparation failures. This provides better debugging information when troubleshooting issues.

Why was this MR needed?

When I set up a local docker-machine targeting a sandbox project without this config:

  [runners.docker]
    image = "alpine:latest"

It was failing with:

Preparing docker-machine wrapped executor failed    created=2025-10-01 17:59:15.236626 +0200 CEST m=+3.165985918 docker=tcp://34.139.14.89:2376 job=497 name=runner-wg8iwvtxz-private-1759334355-c8bf5834 now=2025-10-01 18:01:48.621923 +0200 CEST m=+156.548157668 project=19 runner=Wg8IWvTxZ usedcount=1
ERROR: Failed to remove network for build           error=networksManager is undefined job=497 network= project=19 runner=Wg8IWvTxZ
Cleaned up docker-machine                           created=2025-10-01 17:59:15.236626 +0200 CEST m=+3.165985918 docker=tcp://34.139.14.89:2376 job=497 name=runner-wg8iwvtxz-private-1759334355-c8bf5834 now=2025-10-01 18:01:48.623719 +0200 CEST m=+156.549953918 project=19 runner=Wg8IWvTxZ usedcount=1
WARNING: Preparation failed: no Docker image specified to run the build in  job=497 project=19 runner=Wg8IWvTxZ

The Preparing docker-machine wrapped executor failed message was info-level only, and the crucial piece of information of why networksManager is undefined was not clear, since it is logged after.

With this change, we now log:

ERROR: Preparing docker-machine wrapped executor failed  created=2025-10-01 18:04:54.41957 +0200 CEST m=+0.056902167 docker=tcp://34.139.14.89:2376 error=no Docker image specified to run the build in job=498 name=runner-wg8iwvtxz-private-1759334511-e2510490 now=2025-10-01 18:05:15.715243 +0200 CEST m=+21.352142209 project=19 runner=Wg8IWvTxZ usedcount=2
ERROR: Failed to remove network for build           error=networksManager is undefined job=498 network= project=19 runner=Wg8IWvTxZ
Cleaned up docker-machine                           created=2025-10-01 18:04:54.41957 +0200 CEST m=+0.056902167 docker=tcp://34.139.14.89:2376 job=498 name=runner-wg8iwvtxz-private-1759334511-e2510490 now=2025-10-01 18:05:15.719212 +0200 CEST m=+21.356110501 project=19 runner=Wg8IWvTxZ usedcount=2
WARNING: Preparation failed: no Docker image specified to run the build in  job=498 project=19 runner=Wg8IWvTxZ

While it introduces a little bit of duplication, this makes the causal chain much clearer.

What's the best way to test this MR?

I tested it locally with docker+machine.

What are the relevant issue numbers?

See also: gitlab-org/ci-cd/docker-machine!155 (merged).

Edited by Igor

Merge request reports

Loading