CONCURRENT_PROJECT_ID not unique in 2 different jobs causing a conflict in the builds directory

Summary

One of our customers reported a job failure caused by a conflict when trying to access the builds directory:

rm: can't remove '/builds/<short-token>/<concurrent-id>/<namespace>/<project-name>': Directory not empty

After further investigation, I noticed that there was another job using the same directory to clone the repository. This happened because the for both jobs was the same, when it seems like it should've been unique for each job:

If you make the /builds directory a host-bound storage, your builds are stored in: /builds/<short-token>/<concurrent-id>/<namespace>/<project-name>, where:

  • <short-token> is a shortened version of the Runner’s token (first 8 letters).
  • <concurrent-id> is a unique number that identifies the local job ID of the particular runner in context of the project.

Actual behavior

<concurrent-id> (or CONCURRENT_PROJECT_ID) is not unique between 2 different jobs

Expected behavior

<concurrent-id> (or CONCURRENT_PROJECT_ID) should be unique for each job

Possible fixes

🤷