Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

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 greg.paussa@broadcom.com

- 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 <greg.paussa@broadcom.com>
@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