~fabricematrat/charmworld/redirect-charm

« back to all changes in this revision

Viewing changes to charmworld/models.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2014-04-22 19:06:44 UTC
  • mfrom: (504.1.2 026-3)
  • Revision ID: tarmac-20140422190644-nep5wth304pk36p8
Fix migration wrt invalid constraints.

The migration 026 for rewriting contraints to be space-separated worked for
staging.  When run on production it had errors due to some of the bundles on
production being older than the more restrictive bundle proofing
requirements.  Those bundles were in essence grandfathered in and never
subject to the stricter rules.  At least one bundle had an obsolete 'cpu'
constraint and that caused the migration to fail since it was not checking for
the thrown ValueError in this situation.

The migration now checks for ValueError and will remove the affected bundle
from the target database and proceed.

The functions are now noted to throw ValueError.

Test was added for this situation and logging checked.

https://codereview.appspot.com/90420043/

R=jcsackett.

Approved by Juju Gui Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1889
1889
 
1890
1890
    Constraints are space-separated entities, not comma-separated.  As
1891
1891
    bundle_data is a dictionary, the changes occur in place.
 
1892
 
 
1893
    Raises ValueError if any of the constraints are invalid.
1892
1894
    """
1893
1895
    services = bundle_data.get('services')
1894
1896
    if services:
1906
1908
 
1907
1909
    :input: basket - The YAML string representing the bundles.yaml file.
1908
1910
    :returns: Manipulated YAML string.
 
1911
    Raises ValueError if any of the constraints are invalid.
1909
1912
    """
1910
1913
    # Convert constraints to space-separated, whether it needs it or not.
1911
1914
    data = yaml.load(basket)
1933
1936
    :param logger: A logger.
1934
1937
    :param entry_source: A generator of (file_path, file_id) tuples to
1935
1938
        be slurped. The default entry_source only finds files.
 
1939
    Raises ValueError if any of the constraints are invalid.
1936
1940
    """
1937
1941
    if entry_source is None:
1938
1942
        def entry_source():