Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id B9621E00DD4; Tue, 22 Sep 2015 09:42:57 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [134.134.136.24 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 0E3D0E00B6D for ; Tue, 22 Sep 2015 09:42:57 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 22 Sep 2015 09:42:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,574,1437462000"; d="scan'208";a="774637753" Received: from martinbu-mobl.ger.corp.intel.com (HELO lp.ger.corp.intel.com) ([10.252.21.229]) by orsmga001.jf.intel.com with ESMTP; 22 Sep 2015 09:42:07 -0700 From: Elliot Smith To: toaster@yoctoproject.org Date: Tue, 22 Sep 2015 17:41:51 +0100 Message-Id: <1442940113-3062-2-git-send-email-elliot.smith@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1442940113-3062-1-git-send-email-elliot.smith@intel.com> References: <1442940113-3062-1-git-send-email-elliot.smith@intel.com> Subject: [review-request][PATCH 1/3] toaster: Always run bldcontrol migrations X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 16:42:57 -0000 The toaster startup script conditionally migrates the database tables depending on whether you are in managed mode or not. This means that if you are in analysis mode, some of the bldcontrol* database tables used by managed mode are not available. As a consequence, some of the code in toaster which refers to those tables can break in analysis mode, as there's no clean isolation of the two modes. To prevent this from happening, always run the migrations for managed mode and create the bldcontrol* tables, even if in analysis mode. Also clean up the function which starts up toaster so the logic is easier to follow. [YOCTO #8277] Signed-off-by: Elliot Smith --- bitbake/bin/toaster | 58 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index 411ce2c..1417d47 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster @@ -54,35 +54,55 @@ webserverStartAll() fi retval=0 - if [ "$TOASTER_MANAGED" '=' '1' ]; then + if [ "$TOASTER_MANAGED" = '1' ]; then python $BBBASEDIR/lib/toaster/manage.py syncdb || retval=1 else python $BBBASEDIR/lib/toaster/manage.py syncdb --noinput || retval=1 fi - python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=2 + if [ $retval -eq 1 ]; then - echo "Failed db sync, stopping system start" 1>&2 - elif [ $retval -eq 2 ]; then - printf "\nError on migration, trying to recover... \n" + echo "Failed db sync, aborting system start" 1>&2 + return $retval + fi + + python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1 + + if [ $retval -eq 1 ]; then + printf "\nError on orm migration, rolling back...\n" python $BBBASEDIR/lib/toaster/manage.py migrate orm 0001_initial --fake - retval=0 - python $BBBASEDIR/lib/toaster/manage.py migrate orm || retval=1 + return $retval fi + + python $BBBASEDIR/lib/toaster/manage.py migrate bldcontrol || retval=1 + + if [ $retval -eq 1 ]; then + printf "\nError on bldcontrol migration, rolling back...\n" + python $BBBASEDIR/lib/toaster/manage.py migrate bldcontrol 0001_initial --fake + return $retval + fi + if [ "$TOASTER_MANAGED" = '1' ]; then - python $BBBASEDIR/lib/toaster/manage.py migrate bldcontrol || retval=1 - python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1 + python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1 fi - if [ $retval -eq 0 ]; then - echo "Starting webserver..." - python $BBBASEDIR/lib/toaster/manage.py runserver "0.0.0.0:$WEB_PORT" >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid - sleep 1 - if ! cat "${BUILDDIR}/.toastermain.pid" | xargs -I{} kill -0 {} ; then - retval=1 - rm "${BUILDDIR}/.toastermain.pid" - else - echo "Webserver address: http://0.0.0.0:$WEB_PORT/" - fi + + if [ $retval -eq 1 ]; then + printf "\nError while checking settings; aborting\n" + return $retval + fi + + echo "Starting webserver..." + + python $BBBASEDIR/lib/toaster/manage.py runserver "0.0.0.0:$WEB_PORT" >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid + + sleep 1 + + if ! cat "${BUILDDIR}/.toastermain.pid" | xargs -I{} kill -0 {} ; then + retval=1 + rm "${BUILDDIR}/.toastermain.pid" + else + echo "Webserver address: http://0.0.0.0:$WEB_PORT/" fi + return $retval } -- Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.