Merge ~barryprice/ubuntu-mirror-charm/+git/ubuntu-mirror-charm:master into ubuntu-mirror-charm:master

Proposed by Barry Price
Status: Merged
Approved by: Paul Collins
Approved revision: eda73357a80f2d1a768588d541af3e3af71b453f
Merged at revision: 4cb13e3cd856cb2897a270c21ea06a10e7d55dad
Proposed branch: ~barryprice/ubuntu-mirror-charm/+git/ubuntu-mirror-charm:master
Merge into: ubuntu-mirror-charm:master
Diff against target: 56 lines (+6/-6)
2 files modified
hooks/hooks.py (+1/-1)
tests/unit/test_charm.py (+5/-5)
Reviewer Review Type Date Requested Status
Paul Collins lgtm Approve
Canonical IS Reviewers Pending
Review via email: mp+390792@code.launchpad.net

Commit message

Use nofail for all new bind mount entries

Suggested upgrade path here from the previous revno is, to avoid duplicated fstab entries:

1. Manually replace "defaults,bind" in /etc/fstab with "defaults,bind,nofail" on each unit
2. Upgrade-charm to a version with this update

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Paul Collins (pjdc) wrote :

I can't quite tell - is this going to add new lines or update the existing lines?

I didn't cowboy nofail because there was a nonzero chance of a hook firing and I wasn't sure what would happen.

review: Needs Information
Revision history for this message
Paul Collins (pjdc) wrote :

Barry says that new lines will be added, but I don't think this is a big deal to work around.

review: Approve (lgtm)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 4cb13e3cd856cb2897a270c21ea06a10e7d55dad

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/hooks.py b/hooks/hooks.py
2index 2757b35..350058b 100755
3--- a/hooks/hooks.py
4+++ b/hooks/hooks.py
5@@ -245,7 +245,7 @@ def configure_bind_mounts(conf, hostname):
6 dir_name = os.path.basename(os.path.normpath(path))
7 target = os.path.join("/srv/ftp.root", dir_name)
8 print("DEBUG: configure_bind_mounts needs to bind-mount {} to {}".format(path, target))
9- fstab_line = "{} {} none defaults,bind 0 0".format(path, target)
10+ fstab_line = "{} {} none defaults,bind,nofail 0 0".format(path, target)
11 required_mounts.append(fstab_line)
12
13 update_bind_mounts(required_mounts)
14diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py
15index 9be689a..31764d4 100644
16--- a/tests/unit/test_charm.py
17+++ b/tests/unit/test_charm.py
18@@ -162,13 +162,13 @@ class TestUbuntuMirrorCharm(unittest.TestCase):
19 "__builtin__.open",
20 mock_open(
21 read_data="LABEL=cloudimg-rootfs / ext4 defaults 0 0\n"
22- "/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind 0 0"
23+ "/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind,nofail 0 0"
24 " # Bind mount managed by the ubuntu-mirror charm\n"
25 )
26 ) as m:
27 self.assertEqual(
28 get_managed_mounts(),
29- ["/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind 0 0", ]
30+ ["/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind,nofail 0 0", ]
31 )
32 m.assert_called_once_with("/etc/fstab", "r")
33
34@@ -179,7 +179,7 @@ class TestUbuntuMirrorCharm(unittest.TestCase):
35 @freezegun.freeze_time("2020-09-09 12:00:01")
36 def test_add_bind_mount(self, _copyfile, _rename, _mkdir, _check_call):
37 with patch("__builtin__.open", mock_open()) as m:
38- add_bind_mount("/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind 0 0")
39+ add_bind_mount("/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind,nofail 0 0")
40 m.assert_called_with("/etc/fstab_temp_2020-09-09_12:00:01", "a")
41 _check_call.assert_called_once_with(["mount", "/srv/ftp.root/ubuntu-ports"])
42 _mkdir.assert_called_once_with("/srv/ftp.root/ubuntu-ports")
43@@ -195,11 +195,11 @@ class TestUbuntuMirrorCharm(unittest.TestCase):
44 "__builtin__.open",
45 mock_open(
46 read_data="LABEL=cloudimg-rootfs / ext4 defaults 0 0\n"
47- "/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind 0 0"
48+ "/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind,nofail 0 0"
49 " # Bind mount managed by the ubuntu-mirror charm\n"
50 )
51 ) as m:
52- remove_bind_mount("/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind 0 0")
53+ remove_bind_mount("/srv2/ftp.root/ubuntu-ports /srv/ftp.root/ubuntu-ports none defaults,bind,nofail 0 0")
54 m.assert_any_call("/etc/fstab", "r")
55 m.assert_called_with("/etc/fstab_temp_2020-09-09_12:00:01", "w")
56 m().write.assert_called_once_with("LABEL=cloudimg-rootfs / ext4 defaults 0 0\n")

Subscribers

People subscribed via source and target branches