Merge lp:~ltrager/maas/lp1655721_2.1 into lp:maas/2.1

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 5581
Proposed branch: lp:~ltrager/maas/lp1655721_2.1
Merge into: lp:maas/2.1
Diff against target: 83 lines (+28/-2)
3 files modified
docs/changelog.rst (+2/-0)
src/provisioningserver/import_images/boot_resources.py (+7/-1)
src/provisioningserver/import_images/tests/test_boot_resources.py (+19/-1)
To merge this branch: bzr merge lp:~ltrager/maas/lp1655721_2.1
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+315188@code.launchpad.net

Commit message

Backport r5643 from trunk: Only reload TGT config when a TGT config file exists.

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :
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 2017-01-19 17:51:07 +0000
3+++ docs/changelog.rst 2017-01-19 23:48:57 +0000
4@@ -16,6 +16,8 @@
5
6 LP: #1656425 Ephemeral environments using the wrong kernel
7
8+LP: #1655721 MAAS shouldn't update TGT config when there are no boot sources
9+
10 2.1.3
11 =====
12
13
14=== modified file 'src/provisioningserver/import_images/boot_resources.py'
15--- src/provisioningserver/import_images/boot_resources.py 2016-10-26 07:31:57 +0000
16+++ src/provisioningserver/import_images/boot_resources.py 2017-01-19 23:48:57 +0000
17@@ -1,4 +1,4 @@
18-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
19+# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
20 # GNU Affero General Public License version 3 (see the file LICENSE).
21
22 __all__ = [
23@@ -199,6 +199,12 @@
24
25 # Update the tgt config.
26 targets_conf = os.path.join(snapshot, 'maas.tgt')
27+
28+ # The targets_conf may not exist in the event the BootSource is broken
29+ # and images havn't been imported yet. This fixes LP:1655721
30+ if not os.path.exists(targets_conf):
31+ return
32+
33 call_and_check([
34 'sudo',
35 '/usr/sbin/tgt-admin',
36
37=== modified file 'src/provisioningserver/import_images/tests/test_boot_resources.py'
38--- src/provisioningserver/import_images/tests/test_boot_resources.py 2016-11-02 08:27:51 +0000
39+++ src/provisioningserver/import_images/tests/test_boot_resources.py 2017-01-19 23:48:57 +0000
40@@ -1,4 +1,4 @@
41-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
42+# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
43 # GNU Affero General Public License version 3 (see the file LICENSE).
44
45 """Tests for the boot_resources module."""
46@@ -25,12 +25,14 @@
47 )
48
49 from maastesting.factory import factory
50+from maastesting.fixtures import TempDirectory
51 from maastesting.matchers import (
52 MockAnyCall,
53 MockCalledOnce,
54 MockCalledOnceWith,
55 MockCalledWith,
56 MockCallsMatch,
57+ MockNotCalled,
58 )
59 from maastesting.testcase import (
60 MAASTestCase,
61@@ -596,6 +598,22 @@
62 boot_resources.update_targets_conf(factory.make_name("snapshot"))
63 self.assertThat(mock_ensureService, MockCalledOnceWith("tgt"))
64
65+ def test_update_targets_only_runs_when_conf_exists(self):
66+ # Regression test for LP:1655721
67+ temp_dir = self.useFixture(TempDirectory()).path
68+ self.useFixture(ClusterConfigurationFixture(tftp_root=temp_dir))
69+ mock_ensureService = self.patch(
70+ boot_resources.service_monitor, "ensureService")
71+ mock_call_and_check = self.patch(boot_resources, "call_and_check")
72+ mock_path_exists = self.patch(boot_resources.os.path, 'exists')
73+ mock_path_exists.return_value = False
74+ boot_resources.update_targets_conf(temp_dir)
75+ self.assertThat(mock_ensureService, MockCalledOnceWith("tgt"))
76+ self.assertThat(
77+ mock_path_exists,
78+ MockCalledOnceWith(os.path.join(temp_dir, 'maas.tgt')))
79+ self.assertThat(mock_call_and_check, MockNotCalled())
80+
81
82 class TestMetaContains(MAASTestCase):
83 """Tests for the `meta_contains` function."""

Subscribers

People subscribed via source and target branches

to all changes: