Source code checkout task in Bamboo fails after ever 2 successfull runs with "unable to fork" error
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article covers a scenario where Bamboo source code checkout fails intermiitently with "unable to fork" error . The problem is related to unsupported "Bamboo predator plugin"
Environment
The issue was seen on Bamboo 9.6.0 with Bamboo predator plugin version 2.0.17 but the solution will be applicable for other Bamboo versions as well with the same plugin version.
Diagnosis
Bamboo build which was failing intermittently during source code checkout task was using the Bamboo predator plugin.
<plugin>
<key>com.atlassian.bamboo.plugin.bamboo-predator-plugin</key>
<name>Bamboo Predator Plugin</name>
<version>2.0.17</version>
<vendor>Atlassian</vendor>
<status>ENABLED</status>
<vendor-url>https://www.atlassian.com/</vendor-url>
<framework-version>2</framework-version>
<bundled>User installed</bundled>
</plugin>
Looking at Bamboo build logs we can see that the source code checkout failed with the error -"fatal: unable to fork"
error 20-May-2024 07:52:40 Cannot fetch branch '(unresolved) HashAndSource{refName=[null], branch=[master], hash=[6a44f85c6184590dcc9bfdc48e4cc46532242a30]}' from 'ssh://git@stash-lab.cdk.com/bam/node_project.git' to source directory '/home/cmbuild/bamboo-agent-home/xml-data/build-dir/BUT-NODE-JOB1'. com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git ls-remote ssh://85c608f7-5e2e-4728-87df-9d08ca7e3bc0@127.0.0.1:42667/bam/node_project.git] failed with code 128. Working directory was [/tmp]., stderr:fatal: cannot run /tmp/bamboo-ssh.2958cbb8.sh: No such file or directoryfatal: unable to fork
simple 20-May-2024 07:52:40 Warning: failed to retrieve source code to working directory '/home/cmbuild/bamboo-agent-home/xml-data/build-dir/BUT-NODE-JOB1', trying to recover...
simple 20-May-2024 07:52:40 Cleaned source directory '/home/cmbuild/bamboo-agent-home/xml-data/build-dir/BUT-NODE-JOB1'...
simple 20-May-2024 07:52:40 Creating local git repository in '/home/cmbuild/bamboo-agent-home/xml-data/build-dir/BUT-NODE-JOB1/.git'.
simple 20-May-2024 07:52:40 Initialized empty Git repository in /home/cmbuild/bamboo-agent-home/xml-data/build-dir/BUT-NODE-JOB1/.git/
error 20-May-2024 07:52:40 Cannot fetch branch '(unresolved) HashAndSource{refName=[null], branch=[master], hash=[6a44f85c6184590dcc9bfdc48e4cc46532242a30]}' from 'ssh://git@stash-lab.cdk.com/bam/node_project.git' to source directory '/home/cmbuild/bamboo-agent-home/xml-data/build-dir/BUT-NODE-JOB1'. com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git ls-remote ssh://269eaaba-4bb9-48e4-8bdb-0c86a6267889@127.0.0.1:42667/bam/node_project.git] failed with code 128. Working directory was [/tmp]., stderr:fatal: cannot run /tmp/bamboo-ssh.2958cbb8.sh: No such file or directoryfatal: unable to fork
simple 20-May-2024 07:52:40 Failed to execute git operations on any configured Bitbucket instances. Proceeding with final failing...
error 20-May-2024 07:52:40 Error occurred while running Task 'Source Code Checkout(1)' of type com.atlassian.bamboo.plugins.vcs:task.vcs.checkout.
error 20-May-2024 07:52:40 java.lang.RuntimeException: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: Could not connect to Bitbucket
error 20-May-2024 07:52:40 Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git ls-remote ssh://269eaaba-4bb9-48e4-8bdb-0c86a6267889@127.0.0.1:42667/bam/node_project.git] failed with code 128. Working directory was [/tmp]., stderr:
error 20-May-2024 07:52:40 fatal: cannot run /tmp/bamboo-ssh.2958cbb8.sh: No such file or directory
error 20-May-2024 07:52:40 fatal: unable to fork
Cause
Bamboo predator plugin version i.e 2.0.17 which was used in the Bamboo build was incompatible with the Bamboo version 9.6. This plugin was interfering during the source code checkout task causing the build to fail.
Solution
1. Update the plugin to the latest version 2.0.22 which is compatible with Bamboo 9.6.0
2. Uninstall the plugin if its not required .You can check this KB which helps to identify which project/plan is using a specific plugin.
3. This plugin is responsible for Killing old processes and files from your Bamboo agents before any build. If you are planning to uninstall this plugin ,the best alternative for this is using Bamboo Ephermal agents. From Bamboo 9.3 onwards we’ve introduced a new type of remote agent known as an ephemeral agent. Ephemeral agents are short-lived remote agents that start on demand inside a Kubernetes cluster to carry out a single build or deployment before being shut down.