executor: resolve build root real path

This change fixes bubblewrap roles not found issues when /var/lib/zuul is a
symlink by using a realpath resolve on the jobdir root, resulting in a
consistent path with the path used for roles location.

This issue is happening since job_dir now defaults to /var/lib/zuul
and when this directory is a symlink to /srv/zuul:
- roles paths in ansible.cfg are resolved and prefixed with /srv/zuul
- executor starts bubblewrap --bind /var/lib/zuul/builds/
- job fails with:

ERROR! the role 'emit-job-header' was not found in:
  - /var/lib/zuul/builds/xx/trusted/project_0/config/playbooks/base/roles
  - /srv/zuul/builds/xx/ansible/pre_playbook_0/role_0/zuul-jobs/roles
  ...

The first path is relative to playbook path, the rest are realpaths that
are not available in the bubblewrap.

Change-Id: I234b1beb04e1d2510267a4e85682a78c383bd2a4
This commit is contained in:
Tristan Cacqueray 2019-08-14 12:20:59 +00:00
parent 618be8a063
commit b57bb86daf
1 changed files with 1 additions and 1 deletions

View File

@ -375,7 +375,7 @@ class JobDir(object):
tmpdir = root
else:
tmpdir = tempfile.gettempdir()
self.root = os.path.join(tmpdir, build_uuid)
self.root = os.path.realpath(os.path.join(tmpdir, build_uuid))
os.mkdir(self.root, 0o700)
self.work_root = os.path.join(self.root, 'work')
os.makedirs(self.work_root)