Bug 8476

Summary: mysql port must be specified in settings.py even though marked as optional
Product: [Build System, Metadata & Runtime] Toaster Reporter: Michael Wood <michael.g.wood>
Component: toasterAssignee: Elliot Smith <elliot.smith>
Status: VERIFIED FIXED QA Contact: Alexandru Roman <alexandru.costinx.roman>
Severity: normal    
Priority: Low CC: belen.barros.pena, bogdanx.a.voiculescu, jessica.zhang, stanciux.mihail
Version: 2.1   
Target Milestone: 2.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Michael Wood 2015-10-09 22:29:31 UTC
The DATABASE_URL environ variable seems to be set/used by bitbake

If you do as advised/supported by django/db backend and leave the port as an empty string then the DATABASE_URL regex match goes wrong and bitbake refuses to start.

toastermain/settings.py
...
        'HOST': 'localhost', 
        'PORT': '3306',                      # Set to empty string for default.
    }


...

    elif dburl.startswith('mysql://'):

        # URL must be in this form: mysql://user:pass@host:port/name
        result = re.match(r"mysql://([^:]*):([^@]*)@([^:]*):(\d+)/([^/]*)", dburl)
        if result is None:
            raise Exception("ERROR: Could not read mysql database url: %s" % dburl)
Comment 1 Michael Wood 2016-01-05 15:34:30 UTC
commit c464f34d5bd3aa4119aa3d1591ee7d55afe9b35f
Author: Elliot Smith <elliot.smith@intel.com>
Date:   Wed Dec 9 19:56:37 2015 -0800

    bitbake: toaster: Amend regex for MySQL database URLs
    
    The database URL detection doesn't admit a MySQL URL without a port.
    
    As this is a common case (e.g. you would set the HOST to a mysql.sock
    path if pointing at a local MySQL server, with no port setting),
    amend the regex so it will correctly recognise paths, as well
    as HOST:PORT URLs.

    (Bitbake rev: 89386aab888f806d5aa4a8083c06566e48d9445b)
Comment 2 Alexandru Roman 2016-01-08 09:51:06 UTC
Verified on master: 0f3ad7c77aa0f8bb7641af1886e1420cdfa8419f