Hi, Since I've moved from Pants 2.16 to 2.17, I o...
# general
h
Hi, Since I've moved from Pants 2.16 to 2.17, I occasionally see sporadic failures in CI (Jenkins) with the following error-message pattern:
Copy code
pants --version
07:57:59.01 [ERROR] Work directory ../current-branch-name escapes build root /path/to/jenkins/workspace/some-other-random-branch
I'm not sure if it is something I can control, or is it a Pants bug. I didn't find a ticket for it in GitHub or seen it mentioned on Slack. My current solution is each time it happens to SSH into the CI instance and
rm -rf
the folder of the other branch. Has anyone else experienced it or have a suggestion?
1
g
You have pantsd living from the old branch/directory colliding with the new pants for some reason. If you have concurrent builds on one machine you'll have to disable
pantsd
, otherwise just killing
pantsd
at the end of a build or at the start of the next should fix it. Edit: from below repro`,
rm -rf .pids
should work equally well since it should be unique per directory.
(Just failed my own repro; hm.)
Alright, found another repro that is 100%.
Copy code
pkill pantsd
rm -rf .pids ../copy2/.pids
pants --version
cp -r .pids ../copy2/.pids
(cd ../copy2 && pants --version)
Which doesn't say much about why it happens for you though. Does jenkins do something smart like cache repositories or copy from main to avoid doing full pulls?
h
It runs CI for each branch in a dedicated folder and it keep that folder from one run to the other. But I don't think it should matter. For some reason, it looks like Pants is looking for a path which is not in the current copy of the project and not one of the configured paths. By "configured paths", I mean:
Copy code
local_execution_root_dir = "/var/jenkins_home/pants/tmp"
local_store_dir = "/var/jenkins_home/pants/lmdb_store"
named_caches_dir = "/var/jenkins_home/pants/named_caches"
pants_subprocessdir = "/var/jenkins_home/pants/pids"
Actually, it looks like the
pids
folder is shared...
g
Yeah this repros 100% just like my copy repro from above.
Copy code
pkill pantsd
pants --pants-subprocessdir=/tmp/pids --version
(cd ../copy2 && pants --pants-subprocessdir=/tmp/pids --version)
h
Does pants support interpolation in the config? That is, can I make it something like
pants_subprocessdir = "/var/jenkins_home/pants/{version}/pids"
?
g
Yes; https://www.pantsbuild.org/docs/options#config-file-interpolation. But I don't think that'll help to make this work. What are you trying to achieve with this setting?
h
Specifically with
pants_subprocessdir
I'm not sure. The documentation says about it:
Copy code
The directory to use for tracking subprocess metadata. This should live outside of the dir used by pants_workdir to allow for tracking subprocesses that outlive the workdir data.
So if for each branch, I have a different copy of the repo, does it mean I need to not share it between them? Though it probably won't help me anyway, as if I run CI for a branch, then update Pants' version and then run CI again for the same branch, the
.pids
folder will be shared again.
g
The way I read it is if you're doing something like
Copy code
git clone ...
(cd ... && run-ci)
rm -rf ...
this setting would allow you to keep pantsd running despite the dir disappearing. Or if you run multiple pants processes in the same directory for different CI runs, maybe. I'd skip setting it and see if anything breaks with your specific setup, but I don't think so. The version-bump is fine; that would cause a panstd restart since the options have changed.
h
I'll give it a go, thanks!