build: Use lockfiles to guard ostree repo and `image.json` extraction
CI hit a race where parallel `buildextend-*` would race to generate
`tmp/image.json`.
We need to lock this for efficiency (avoid duplicate work) and
correctness.
@@ -234,6 +234,7 @@ def rm_allow_noent(path):
def extract_image_json(workdir, commit):
+ with Lock(os.path.join(workdir, 'tmp/image.json.lock')):
repo = os.path.join(workdir, 'tmp/repo')
path = os.path.join(workdir, 'tmp/image.json')
tmppath = path + '.tmp'
@@ -264,6 +265,7 @@ def extract_image_json(workdir, commit):
#
# Call this function to ensure that the ostree commit for a given build is in tmp/repo.
def import_ostree_commit(workdir, buildpath, buildmeta, force=False):
+ with Lock(os.path.join(workdir, 'tmp/repo.import.lock')):
repo = os.path.join(workdir, 'tmp/repo')
commit = buildmeta['ostree-commit']
tarfile = os.path.join(buildpath, buildmeta['images']['ostree']['path'])
