Bug 6512

Summary: Cannot use Daisy client with Current Master database code
Product: [Build System, Metadata & Runtime] Toaster Reporter: Craig Neth <craig.neth>
Component: toasterAssignee: Craig Neth <craig.neth>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: Medium CC: alexandru.damian, belen.barros.pena, cristiana.voicu
Version: unspecified   
Target Milestone: 1.7.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Craig Neth 2014-07-08 14:36:51 UTC
It seems like there has been an incompatible schema change made to the toaster database somewhere between the released daisy branch and the current master.

Attempting to perform toaster builds with Daisy clients against the current master results in numerous errors; see the output from the 'toaster_ui.log' below.

We are using a 'production' setup where we run the toaster server on a separate machine using a mysql database.

Steps to reproduce:

Pull the poky master (this was reproduced with commit:a5531a2b8983318b99c119a87b78a92cf84160b8), and then:

mysql> drop database toaster;
mysql> create database toaster;

python bitbake/lib/toaster/manage.py syncdb
python bitbake/lib/toaster/manage.py migrate orm
python bitbake/lib/toaster/manage.py migrate bldcontrol

(The wiki page does not mention this last one but the ‘syncdb' command
mentions that this one is also 'not synced’.)

To start the master, I have written a short upstart script that does the
following:

DATABASE_URL='mysql://user:pass@node:3306/toaster' python
$BASEDIR/bitbake/lib/toaster/manage.py runserver

After running this command, I verified that the server is up and running (I see the "This is Toaster" page).

Then try to run a client build based on the released 1.6 (client:5306aaab07a7a9b3b0c7e8008dabbd2e89daec28) Poky:

$ bitbake --postread conf/toaster.conf --server-only -t xmlrpc -B localhost:0 && export BBSERVER=localhost:-1
$ nohup bitbake --observe-only -u toasterui &
$ bitbake <some-image>

Expected Result: 

+ A build would be recorded in the remote toaster instance

Actual result:

+ No build is recorded
+ Numerous errors are posted to the toaster log on the client, see below for examples:

ERROR: Field 'project_id' doesn't have a default value
Traceback (most recent call last):
  File "/poky/bitbake/lib/bb/ui/toasterui.py", line 110, in main
    buildinfohelper.store_started_build(event)
  File "/poky/bitbake/lib/bb/ui/buildinfohelper.py", line 603, in store_started_build
    build_obj = self.orm_wrapper.create_build_object(build_information)
  File "/poky/bitbake/lib/bb/ui/buildinfohelper.py", line 66, in create_build_object
    bitbake_version=build_info['bitbake_version'])
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 149, in create
    return self.get_query_set().create(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 414, in create
    obj.save(force_insert=True, using=self.db)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 546, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 650, in save_base
    result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 215, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1673, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 937, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 41, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 120, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 176, in execute
    if not self._defer_warnings: self._warning_check()
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 92, in _warning_check
    warn(w[-1], self.Warning, 3)
Warning: Field 'project_id' doesn't have a default value
NOTE: Preparing runqueue
ERROR: 
Traceback (most recent call last):
  File "/poky/bitbake/lib/bb/ui/toasterui.py", line 270, in main
    buildinfohelper.store_dependency_information(event)
  File "/poky/bitbake/lib/bb/ui/buildinfohelper.py", line 822, in store_dependency_information
    layer_version_obj = self._get_layer_version_for_path(path[1:]) # paths start with a ^
  File "/poky/bitbake/lib/bb/ui/buildinfohelper.py", line 533, in _get_layer_version_for_path
    assert 'build' in self.internal_state
AssertionError
ERROR: 
Traceback (most recent call last):
  File "/poky/bitbake/lib/bb/ui/toasterui.py", line 246, in main
    buildinfohelper.store_missed_state_tasks(event)
  File "/poky/bitbake/lib/bb/ui/buildinfohelper.py", line 761, in store_missed_state_tasks
    recipe_information = self._get_recipe_information_from_taskfile(fn)
  File "/poky/bitbake/lib/bb/ui/buildinfohelper.py", line 551, in _get_recipe_information_from_taskfile
    layer_version_obj = self._get_layer_version_for_path(localfilepath)
  File "/poky/bitbake/lib/bb/ui/buildinfohelper.py", line 533, in _get_layer_version_for_path
    assert 'build' in self.internal_state
Comment 1 Alexandru Damian 2014-11-03 12:05:38 UTC
The instructions that you follow are correct.

* For the daisy clients, i.e. toaster running in 1.6 mode, please do not sync "bldcontrol" database. (I edited the wiki page).

The original error of "Field 'project_id' doesn't have a default value" has been fixed.

With the current head of "daisy" and "master" branches, I cannot reproduce this bug.