[Infrastructure as Code (IaC)] Troubleshooting Common Issues with GitLab Runner Shell Executor on CentOS
Troubleshooting Common Issues with GitLab Runner Shell Executor on CentOS
As a senior software engineer, I often encounter various challenges while working with GitLab Runner on CentOS. This blog post aims to address some common issues and provide solutions that can help streamline your CI/CD pipeline. Whether you’re upgrading Git, managing permissions for Docker, or dealing with runtime errors, this guide will offer practical steps to resolve these issues efficiently.
1. Fatal Error: git fetch-pack: expected shallow list
Issue:
When running your GitLab CI/CD pipeline, you might encounter the following error:
1 | fatal: git fetch-pack: expected shallow list |
Solution:
This issue often arises due to an outdated version of Git. To resolve it, upgrade Git to the latest version.
1 | yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm |
2. Permission Denied: Docker Daemon Socket
Issue:
You may see an error stating:
1 | ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock |
Solution:
This error indicates that the gitlab-runner
user does not have the necessary permissions to access the Docker daemon. You can either add the gitlab-runner
user to the Docker group or run gitlab-runner
as the root user.
Option 1: Add gitlab-runner
to Docker group
1 | Create the Docker Group (if it doesn't already exist): |
Option 2: Run gitlab-runner
as root
Modify the GitLab Runner service file:
1 | /etc/systemd/system/gitlab-runner.service |
Then, check if the GitLab Runner is running with the correct user:
1 | ps aux | grep gitlab-runner |
3. Dubious Ownership in Repository
Issue:
Another common error you might face is:
1 | fatal: detected dubious ownership in repository at |
Solution:
To resolve this, add the repository to the list of safe directories.
1 | git config --global --add safe.directory "*" |
4. OCI Runtime Create Failed
Issue:
While starting a container, you might encounter the following error:
1 | OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:319: getting the final child's pid from pipe caused "EOF": unknown |
Solutions:
This issue can be caused by several factors. Here are three potential solutions:
Way 1: Increase kernel.pid_max
1 | sysctl -n kernel.pid_max |
Way 2: Increase user.max_user_namespaces
1 | sysctl -n user.max_user_namespaces |
Way 3: Resolve Page Allocation Failure
Check for page allocation failures:
1 | grep -w 'runc:\[1:CHILD\]: page allocation failure' /var/log/messages | tail -n 4 |
Solution 1: Drop Caches
1 | echo 3 > /proc/sys/vm/drop_caches |
Solution 2: Compact Memory
1 | echo 1 > /proc/sys/vm/compact_memory |
After applying these solutions, remember to restart the GitLab Runner for changes to take effect:
1 | systemctl restart gitlab-runner |
Conclusion
Working with GitLab Runner on CentOS can sometimes present challenges, but with the right approach and solutions, you can overcome these hurdles efficiently. By keeping your tools updated, managing permissions correctly, and tweaking system parameters, you can ensure a smooth CI/CD pipeline. If you encounter any other issues, feel free to explore the GitLab and Docker documentation or reach out to the community for further assistance.
Happy coding!