Local Gitlab cicd failed 'fatal: unable to access...Could not resolve host:...' with linux runner - docker

I am trying to test my python project and run via gitlab. I have installed runner on my ubuntu notebook and complete registered with local
gitlab server.
Thus, got 2 seperate machine one runner and another one is gitlab server. Both machine can communicate each other.
Notebook(192.168.100.10) ---- GitLab(172.16.10.100)
Once I commit test, my job failed with message below;
Reinitialized existing Git repository in /builds/dz/mytest/.git/
fatal: unable to access 'http://gitlab.lab01.ng/dz/mytest.git/': Could not resolve host: gitlab.lab01.ng
Uploading artifacts for failed job
ERROR: Job failed: exit code 1
From my notebook cli, i can ping gitlab server ip but not the host name even curl also doesnt know the hostname.
I believe this is something to do with the dns that cannot resolved.
I add hostname in my notebook /etc/hosts , i can ping hostname but still failed run job with the same message.
I have tried people suggest add below inside gitlab-runner config.toml, thus I add below in config.toml (Not sure if this is correct to add in config.toml)
[[runners]]
dns_search = [""]
Still failed and got the same message could not resilve host.
What can I do on my notebook setting/runner? I dont have admin access to gitlab to check further.
Anyone face the same problem. Appreciate help and support thank you.
--For information I have tried testing the runner on my notebook with public gitlab (gitlab.com) and I can run the job successfully without any error message--

I'm assuming you are using docker as the executor for your GitLab runner since you did not specify it in your question. Docker executor does not share the /etc/hosts of the host machine but you can use extra_hosts parameter inside your config.toml to let the runner container know about the custom hostname:
[runners.docker]
extra_hosts = ["gitlab.lab01.ng:172.16.10.100"]

Related

Bitbucket pipelines: problem cloning source repository on self-hosted runner with dind

I work on a project where we have specific computers (configured specs) which pair with our products (hardware). My aim is to configure a self hosted runner so that we can run our test suite on a real product with the same computer and environment that our customers have.
I've been able to set up a self hosted agent with this code
runs-on:
"self.hosted"
"ubuntu18.04"
But this gives me a docker container on my self host.
Q1) is there any way to use bitbucket-pipelines to run the CI on the self hosted machine itself, rather than a docker container inside of the self hosted machine?
My research has suggested the answer to this Q1 is no, so I then continued to try and develop using the docker container provided by bitbucket for self hosted runner.
The problem now, was that I did not have the environment needed in the docker container provided by bitbucket. Configuring the environment with bash script is doable, but not an attractive option due to increases in build time.
I then found the docker-in-docker (dind) option so that I can run my normal build environment inside the self-hosted runner environment. Essentially then involved adding a CLONE_IMAGE argument to the docker command provided by bitbucket.
We now reach my current problem in that I get the following error in bitbucket-pipelines:
# under build tab
GIT_LFS_SKIP_SMUDGE=1 GIT_SSL_NO_VERIFY=true retry 6 git clone --branch="feature/testing-infrastructure" https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN#bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR
/tmp/7b85a726-7c76-55d5-b4f4-d7fe74abc8e0/tmp/cloneScript5351248756573077914.sh: line 13: retry: command not found
# under the docker tab
time="2022-07-13T13:38:41.939639712Z" level=info msg="Starting up"
time="2022-07-13T13:38:41.940255296Z" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
time="2022-07-13T13:38:41.940338812Z" level=warning msg="Binding to IP address without --tlsverify is insecure and gives root access on this machine to everyone who has access to your network." host="tcp://0.0.0.0:2375"
time="2022-07-13T13:38:41.940347755Z" level=warning msg="Binding to an IP address, even on localhost, can also give access to scripts run in a browser. Be safe out there!" host="tcp://0.0.0.0:2375"
The logging output from the docker container on the self-hosted runner is:
Completing step with result Result{status=ERROR, error=Some(Error{key='runner.bitbucket-pipelines.clone-container-failure', message='We couldn't clone the repository. Try rerunning the pipeline.', arguments={}})}.
Q2) What is the problem? What is this retry comment that can't be found? I tried sudo apt install retry which worked, but this is not the program that is needed.
(apologies for the formatting, it seems bitbucket-questions does not want to let me have any more code blocks (?))

GitLab runner docker executor calls back gitlab server by IP address

I have private GitLab server running in the cloud (bitnami image). I have a custom domain registered with the public IP of Gitlab Server and letsencrypt certificate generated for this domain. I can access gitlab server by https://mycustomdomain/.
I have installed gitlab-runner on linux host and successfully registered (docker executor) with gitlab server (https://mycustomdomain/).
Now when i then run the pipeline, it fails with following message:
Pulling docker image node:latest ...
Using docker image sha256:2a0d8959c8e1b967d926059e555fdd23926c8fff809a0cf5fab373e694bbce64 for node:latest ...
Running on runner-PcudM7CB-project-1-concurrent-0 via my-gitlab-worker...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/root/microcities/.git/
Created fresh repository.
fatal: unable to access 'https://<my gitlab public IP>/root/microcities.git/': SSL: no alternative certificate subject name matches target host name 'my gitlab public IP'
ERROR: Job failed: exit code 1
Why does the runner/docker container refer to gitlab server by it's IP rather than by domain name?
Solution is to update the gitlab server configuration. In my case that means running
cd /opt/bitnami/apps/gitlab
sudo ./bnconfig --machine_hostname DOMAIN-NAME
This is well covered in bitnami documentation, my bad I did miss this step.

Why doesn't TeamCity recognize docker server properties with the jetbrains/agent image?

I have an ECS Fargate service running the jetbrains/teamcity-agent image. This is connected to my TeamCity Host which is running on an EC2 instance(windows).
When I check whether the agent is capable of running docker commands, it shows the following errors:
Unmet requirements:
docker.server.osType contains linux
docker.server.version exists
Under Agent Parameters -> Configuration Parameters, I can see the docker version and the dockerCompose.version properly. Is there a setting that I am missing?
If you are trying to access a docker socket in fargate, Fargate does not support running docker commands, there is a proposed ticket for this feature.
the issue with "docker.server.osType" not showing up usually means
that the docker command run from the agent cannot connect with the
docker daemon running. This is usually due to a lack of permissions,
as docker by default only allows connections from root and users of
the group docker
Teamcity-Unmet-requirements-docker-server-osType-contains-linux
I was facing similar issues got them fixed by adding "build agent" user in "docker" group and restarted/rebooted the server.
Where build agent user ==> Means the user with which your TeamCity services are running.
Command to add a user to group
#chmod -a -G docker <userasperyourrequirement>
Command to reboot the server:
#init 6

pending jenkins doesn't have label docker-slave

I am trying to configure jenkins slave as docker container, have enabled docker API and connections works fine to the API
Have added the configuration for docker template and docker cloud but it seems that my job does not starts
I can see container getting created on my docker node but the job does not start
Docker cloud configuration image
docker template image
One thing to note is that when i run the container specifically on the docker node and then try to ssh using the same credentials that i am using in jenkins i can ssh into the container.
This message of "Jenkins doesn't have label XXXX" is rather misleading and unhelpful.
You think the problem is something you did wrong in your configuration and when you find out what happen it is nothing to do with jenkins or how you set up the docker plugin.
I run into the same problem than you, and the problem was the docker installation I was using.
The steps I followed to fix it were:
(I was using CENTOS7,jenkins 2.1.38, docker version 1.13.1)
1) Go to the logs of your jenkins (centos logs are /var/log/jenkins.log)
2) Looking into the logs you are going to find out the problem. For instance for me was this:
com.github.dockerjava.api.exception.NotFoundException: {"message":"driver failed programming external connectivity on endpoint happy_heyrovsky (cbfa0d43f8c89d2531323249468503be11e9dd603597a870530d28540c662695): exec: \"docker-proxy\": executable file not found in $PATH"}
As you see the problem is that docker it is not able to find docker-proxy ¿how to fix this?
Go to /usr/libexec/docker and you will see docker-proxy-current. so what you have to do is create a link:
sudo ln -s docker-proxy-current docker-proxy
Tha´s all. After doing this change I execute my build on jenkins and it works.

Unable to access Container url in Bluemix for Spring Boot Application

I am using Toolchain in IBM Bluemix for deploying an Simple Spring boot application.
In Delivery pipeline I have added 3 stages:
Stage-1(Maven Build)
Fetching source code from git repo and building with Maven to build jar file
Stage-2(Building Docker Image)
In this stage it is reading from a Dockerfile in source code and building a Docker image. In this stage Builder Type is "IBM Container Service".
Stage-3(Container Deploy)
In this stage I am deploying the image in Container in Bluemix. Here Deployer Type is "IBM Container Service".
After all stages are completed successfully I hit the container ip provided in deploy stage but it gives an error
A communication error occurred: "Connection refused"
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
I have checked the container status with bx ic inspect some-container-name
it shows container status running.
Any help will be appreciated.
This sounds like a problem with the application. You can investigate by either doing bx ic logs some-container-name or by connecting to the running container by doing bx ic exec -it some-container-name /bin/bash
Edit: You should also make sure you are specifying the correct port in the Container Deploy stage and when trying to connect to the IP address.

Resources