From 577cd11b38b4dc4319a87b81003fcdd3ad539ad9 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Mon, 30 Jan 2017 17:48:00 +0200 Subject: [PATCH 1/3] Lock build_debuian.sh execution to prevent issue with parallel access to docker engine. --- slave.mk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/slave.mk b/slave.mk index 485f8ff9206c..9f9f7775d1f2 100644 --- a/slave.mk +++ b/slave.mk @@ -315,7 +315,19 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform chmod +x sonic_debian_extension.sh, ) - ./build_debian.sh "$(USERNAME)" "$(shell perl -e 'print crypt("$(PASSWORD)", "salt"),"\n"')" $(LOG) + # Lock build_debian.sh execution to prevent issue with parallel accessing to docker engine. + INSTALLER_LOCK=/var/lock/sonic-buildimage-inÑ–taller.lock + while true; do + [ mkdir $(INSTALLER_LOCK) &>/dev/null ] && { + ./build_debian.sh "$(USERNAME)" "$(shell perl -e 'print crypt("$(PASSWORD)", "salt"),"\n"')" $(LOG) || { + rm -rf $(INSTALLER_LOCK_FILE) + exit 1 + } + + rm -rf $(INSTALLER_LOCK_FILE) + } + done + TARGET_MACHINE=$($*_MACHINE) IMAGE_TYPE=$($*_IMAGE_TYPE) ./build_image.sh $(LOG) $(foreach docker, $($*_DOCKERS), \ From c3b2bf66712a794f7bab710b5a8cb6b365efbf25 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Mon, 30 Jan 2017 17:58:18 +0200 Subject: [PATCH 2/3] Update slave.mk --- slave.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/slave.mk b/slave.mk index 9f9f7775d1f2..125896709bed 100644 --- a/slave.mk +++ b/slave.mk @@ -325,6 +325,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform } rm -rf $(INSTALLER_LOCK_FILE) + break } done From 3ed3a46aefab0e92855b373f359bd55be1a249db Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Mon, 30 Jan 2017 23:18:45 +0200 Subject: [PATCH 3/3] Update sonic_debian_extension.j2 --- files/build_templates/sonic_debian_extension.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 00fcf6732131..bebebbf9affb 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -110,7 +110,7 @@ sudo LANG=C chroot $FILESYSTEM_ROOT depmod -a {{kversion}} {% for image in installer_images.strip().split(' ') -%} sudo LANG=C chroot $FILESYSTEM_ROOT docker load < {{image}} {% endfor %} -sudo chroot $FILESYSTEM_ROOT service docker stop +sudo chroot $FILESYSTEM_ROOT service docker stop || true {% for script in installer_start_scrips.split(' ') -%} sudo cp {{script}} $FILESYSTEM_ROOT/usr/bin/ {% endfor %}