Merge lp:~ltrager/maas/lp1597460 into lp:maas/1.9

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 4587
Proposed branch: lp:~ltrager/maas/lp1597460
Merge into: lp:maas/1.9
Diff against target: 61 lines (+22/-0)
3 files modified
docs/changelog.rst (+1/-0)
src/maasserver/bootresources.py (+6/-0)
src/maasserver/tests/test_bootresources.py (+15/-0)
To merge this branch: bzr merge lp:~ltrager/maas/lp1597460
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+298699@code.launchpad.net

Commit message

Only download filetypes from a SimpleStream which MAAS supports

Description of the change

MAAS 1.9 and below currently downloads all files in a product listing from the SimpleStream. If the product listing contains a filetype which MAAS doesn't support the form will reject it raising an exception. Blake patched MAAS 2.0 so it only downloads supported files(http://bazaar.launchpad.net/~maas-committers/maas/trunk/revision/4808). This backports that change to 1.9 so users don't run into issues when we add SquashFS images.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Looks good, with one comment.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/changelog.rst'
2--- docs/changelog.rst 2016-06-10 16:33:27 +0000
3+++ docs/changelog.rst 2016-06-30 17:37:02 +0000
4@@ -17,6 +17,7 @@
5
6 LP: #1591093 [2.0,1.9] 3rd party HP drivers (archive hostname renamed) - deployment fails
7
8+LP: #1597460 [1.9] MAAS 1.9 should only download filetypes from a SimpleStream is can process
9
10 1.9.3
11 =====
12
13=== modified file 'src/maasserver/bootresources.py'
14--- src/maasserver/bootresources.py 2015-10-05 19:18:18 +0000
15+++ src/maasserver/bootresources.py 2016-06-30 17:37:02 +0000
16@@ -52,6 +52,7 @@
17 register_persistent_error,
18 )
19 from maasserver.enum import (
20+ BOOT_RESOURCE_FILE_TYPE_CHOICES,
21 BOOT_RESOURCE_TYPE,
22 COMPONENT,
23 )
24@@ -578,6 +579,11 @@
25 :type product: dict
26 :param reader: File-like object.
27 """
28+ # Skip filetypes that we don't care about. We don't even import them.
29+ if product['ftype'] not in dict(
30+ BOOT_RESOURCE_FILE_TYPE_CHOICES).keys():
31+ return
32+
33 resource = self.get_or_create_boot_resource(product)
34 is_resource_initially_complete = (
35 resource.get_latest_complete_set() is not None)
36
37=== modified file 'src/maasserver/tests/test_bootresources.py'
38--- src/maasserver/tests/test_bootresources.py 2015-09-25 14:39:44 +0000
39+++ src/maasserver/tests/test_bootresources.py 2016-06-30 17:37:02 +0000
40@@ -946,6 +946,21 @@
41 other_file.largefile, reload_object(other_file).largefile)
42 self.assertThat(mock_save_later, MockNotCalled())
43
44+ def test_insert_doesnt_create_largefile_for_unknown_ftype(self):
45+ name, architecture, product = make_product()
46+ product['ftype'] = factory.make_name('ftype')
47+ with transaction.atomic():
48+ resource = factory.make_BootResource(
49+ rtype=BOOT_RESOURCE_TYPE.SYNCED, name=name,
50+ architecture=architecture)
51+ resource_set = factory.make_BootResourceSet(
52+ resource, version=product['version_name'])
53+ product['sha256'] = factory.make_string(size=64)
54+ product['size'] = randint(1024, 2048)
55+ store = BootResourceStore()
56+ store.insert(product, sentinel.reader)
57+ self.assertThat(reload_object(resource_set).files.all(), HasLength(0))
58+
59 def test_insert_creates_new_largefile(self):
60 name, architecture, product = make_product()
61 with transaction.atomic():

Subscribers

People subscribed via source and target branches