Troubleshooting GitLab Detective

This page addresses some common pitfalls when using GitLab Detective.

Problems when running GitLab Detective or testing checks

These docs are intended to help address some common issues that can come up when running GitLab Detective.

failed to connect to the docker API: no such host

Error when running detective setup

docker: failed to connect to the docker API at tcp://docker.local:2375: lookup docker.local: no such host

Run 'docker run --help' for more information

This error occurs when ansible-runner cannot connect to the Docker daemon. The default location (tcp://docker.local:2375) may not exist in your environment.

Solution: Set the DOCKER_HOST environment variable to point to your Docker socket.

For example, if using Colima on macOS:

export DOCKER_HOST=unix://$HOME/.colima/default/docker.sock

Unable to pull execution environment image

docker: Error response from daemon: pull access denied for <registry.gitlab.com/path/to/image>, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

The detective images should be publicly available on registry.gitlab.com. If this error occurs, try updating the execution_environment_image in your detectiverc.json file.

The path for the latest image is currently: registry.gitlab.com/gitlab-com/support/toolbox/gitlab-detective:latest

Unable to access registry image…Unauthorized

You may see errors like the following

Unable to find image 'registry.gitlab.com/gitlab-com/support/toolbox/gitlab-detective:latest' locally
docker: Error response from daemon: failed to resolve reference "registry.gitlab.com/gitlab-com/support/toolbox/gitlab-detective:latest": failed to authorize: failed to fetch oauth token: unexpected status: 401 Unauthorized
docker: Error response from daemon: Head "https://registry.gitlab.com/v2/gitlab-com/support/toolbox/gitlab-detective/manifests/MR-109-1185": unauthorized: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See https://gitlab.com/help/user/profile/account/two_factor_authentication_troubleshooting.md#error-http-basic-access-denied-if-a-password-was-provided-for-git-authentication-

This issue can occur if Docker caches old credentials that cause a bad authentication. Even if the image is public, you may still see 401 unauthorized errors.

To clear credentials, run docker logout registry.gitlab.com.

SSH identity: No such file or directory

TASK [Gathering Facts] **************************************************************************************************************************************************************************************************************************
fatal: [gitlab.example.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added 'gitlab.example.com' (ED25519) to the list of known hosts.\r\nno such identity: /root/.ssh/~/.ssh/gitlab-detective: No such file or directory\r\ngitlab.example.com: Permission denied (publickey).", "unreachable": true}

PLAY RECAP **************************************************************************************************************************************************************************************************************************************
gitlab.example.com : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0

This error happens when the full path to the ssh key is specified. Ansible-runner always mounts the user’s ~/.ssh path and expects just the key name.

A feature was added to allow users to specify the full path in later versions: Allow the user to use keys that aren’t in .ssh