lueschem / edi

Embedded development infrastructure.
https://www.get-edi.io
GNU Lesser General Public License v3.0
38 stars 12 forks source link

Prevent hash collision during parallel image build #69

Closed lueschem closed 1 year ago

lueschem commented 3 years ago

Desired Behaviour

It should be possible to run several image builds of the same image in parallel from different directories. The use case is e.g. a CI build slave that gets several image builds in parallel.

Actual Behaviour

The parallel build does not work because the LXD containers get the same name.

How to reproduce

  1. Check out a project like edi-cl to two different folders.
  2. In both folders start an image build: sudo edi -v image create iot-gate-imx8-buster-arm64.yml
  3. Observe that one of the builds will fail with a message such as:
    Success: The following profiles are now available: eth0_54b7c5cd49d96a026615, default_root_device_c2a6be2103e39e9fd3dc, suppress_init_991390065b10e5a460c0
    Going to launch container.
    INFO:root:Running command: ['sudo', '-u', 'lueschem', '/usr/bin/lxc', 'launch', 'local:iot-gate-imx8-buster-arm64_edicommand_lxc_import_di_93b24a0a', 'edi-tmp-53463aab595f635911b4', '-p', 'eth0_54b7c5cd49d96a026615', '-p', 'default_root_device_c2a6be2103e39e9fd3dc', '-p', 'suppress_init_991390065b10e5a460c0']
    Creating edi-tmp-53463aab595f635911b4
    Error: Launching image 'iot-gate-imx8-buster-arm64_edicommand_lxc_import_di_93b24a0a' failed with the following message:
    Error: Failed creating instance record: Add instance info to the database: This instance already exist

Solution

Currently just the project configuration is hashed when generating a name for the temporary LXD container. It would be smarter to do something like edi-tmp-PROJECTHASH-DIRECTORYHASH.

The issue got partially addressed in: https://github.com/lueschem/edi/commit/6919afc1eaabc3bbc263ca50816c3c7e9af72cee