Skip to content

[baseimage] Avoid race condition in sonic-platform-common#3457

Merged
lguohan merged 1 commit intosonic-net:masterfrom
gpaussabrcm:avoid_race_sonic_platform_common
Sep 14, 2019
Merged

[baseimage] Avoid race condition in sonic-platform-common#3457
lguohan merged 1 commit intosonic-net:masterfrom
gpaussabrcm:avoid_race_sonic_platform_common

Conversation

@gpaussabrcm
Copy link
Contributor

  • rules/sonic-platform-common.mk

Both python2 and python3 wheels being built out of the same
source directory can interfere with each other when
SONIC_BUILD_JOBS > 1.

Signed-off-by: Greg Paussa [email protected]

- What I did
Resolved a build-time race condition between the python2 and python3 targets for the src/sonic-platform-common package. This issue can randomly occur when SONIC_BUILD_JOBS is greater than 1 (I'm using 8), and manifests itself as an error in either of the target/python-wheels/sonic_platform_common-1.0-py2-none-any.whl or target/python-wheels/sonic_platform_common-1.0-py3-none-any.whl targets.

The exact error reported in the corresponding .log file varies, but here is one example:

creating build/bdist.linux-x86_64/wheel/sonic_platform_common-1.0.dist-info/WHEEL
error: [Errno 39] Directory not empty: 'build/bdist.linux-x86_64/wheel'
[  FAIL LOG END  ] [ target/python-wheels/sonic_platform_common-1.0-py3-none-any.whl ]
make: *** [target/python-wheels/sonic_platform_common-1.0-py3-none-any.whl] Error 1

- How I did it
Added the following _DEPENDS statement to rules/sonic-platform-common.mk, ensuring python3 is built after python2 is complete:

# Synthetic dependency just to avoid race condition
$(SONIC_PLATFORM_COMMON_PY3)_DEPENDS = $(SONIC_PLATFORM_COMMON_PY2)

This change is patterned after a similar statement in rules/swsssdk-py3.mk that addressed a previous race condition in that package.

- How to verify it

  1. Build SONiC successfully.
  2. rm target/python-wheels/sonic_platform_common-1.0-py*.whl
  3. rm target/sonic-vs.img.gz
  4. make SONIC_BUILD_JOBS=8 target/sonic-vs.img.gz

Note: In steps 3 and 4, substitute whatever target image file name corresponds to the configured .platform.

Without the fix, either py2 or py3 fails to build. With the fix, py2 always builds before py3.

- Description for the changelog

Avoid race condition in src/sonic-platform-common when building multiple sub-targets in parallel.

- A picture of a cute animal (not mandatory but encouraged)

* rules/sonic-platform-common.mk

Both python2 and python3 wheels being built out of the same
source directory can interfere with each other when
SONIC_BUILD_JOBS > 1.

Signed-off-by: Greg Paussa <[email protected]>
@jleveque
Copy link
Contributor

Retest this please

@lguohan lguohan merged commit a2cd26a into sonic-net:master Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants