summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-12-13 09:30:57 -0500
committerScott Moser <smoser@brickies.net>2016-12-13 09:30:57 -0500
commitc9876b20607cf0ac1160ce85549ef30af7dd111a (patch)
treeac8c42bd96f79c26007760609074bf1666d3801d
parentf3cbd22ed83eac85c0cccd46a49dd413f3638453 (diff)
downloadvyos-cloud-init-c9876b20607cf0ac1160ce85549ef30af7dd111a.tar.gz
vyos-cloud-init-c9876b20607cf0ac1160ce85549ef30af7dd111a.zip
cherry pick c9c9197
LP: #1647708
-rw-r--r--debian/changelog4
-rw-r--r--debian/patches/cpick-c9c9197-mounts-use-mount-a-again-to-accomplish-mounts104
-rw-r--r--debian/patches/series1
3 files changed, 108 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index b7e9e593..85b90f08 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,10 @@ cloud-init (0.7.8-49-g9e904bb-0ubuntu1~16.04.3) UNRELEASED; urgency=medium
* cherry-pick a9d41de: CloudSigma: Fix bug where datasource was not
loaded in local (LP: #1648380)
+ * cherry-pick c9c9197: mounts: use mount -a again to accomplish mounts
+ (LP: #1647708)
- -- Scott Moser <smoser@ubuntu.com> Tue, 13 Dec 2016 09:30:37 -0500
+ -- Scott Moser <smoser@ubuntu.com> Tue, 13 Dec 2016 09:30:49 -0500
cloud-init (0.7.8-49-g9e904bb-0ubuntu1~16.04.2) xenial-proposed; urgency=medium
diff --git a/debian/patches/cpick-c9c9197-mounts-use-mount-a-again-to-accomplish-mounts b/debian/patches/cpick-c9c9197-mounts-use-mount-a-again-to-accomplish-mounts
new file mode 100644
index 00000000..3dd0e3cb
--- /dev/null
+++ b/debian/patches/cpick-c9c9197-mounts-use-mount-a-again-to-accomplish-mounts
@@ -0,0 +1,104 @@
+From c9c9197a3210ac24a039a4096214150d0e8cebb8 Mon Sep 17 00:00:00 2001
+From: Scott Moser <smoser@ubuntu.com>
+Date: Wed, 7 Dec 2016 09:44:41 +0100
+Subject: [PATCH] mounts: use mount -a again to accomplish mounts
+
+During recent changes to cc_mounts, on systemd systems, we started using
+ systemctl daemon-reload
+rather than 'mount -a' to get mounts done.
+
+The belief was that since entries in /etc/fstab would be written
+to tell systemd that they should be after cloud-init
+(x-systemd.requires=cloud-init.service) that the reload would then
+let systemd mount the units as expected.
+
+That doesn't seem to work, and new mount entries end up not getting
+mounted. The change here moves back to using 'mount -a', but
+then also does a systemctl daemon-reload.
+
+LP: #1647708
+---
+ cloudinit/config/cc_mounts.py | 52 ++++++++++++++++++++++++++++---------------
+ 1 file changed, 34 insertions(+), 18 deletions(-)
+
+--- a/cloudinit/config/cc_mounts.py
++++ b/cloudinit/config/cc_mounts.py
+@@ -327,6 +327,8 @@ def handle(_name, cfg, cloud, log, _args
+ if "mounts" in cfg:
+ cfgmnt = cfg["mounts"]
+
++ LOG.debug("mounts configuration is %s", cfgmnt)
++
+ for i in range(len(cfgmnt)):
+ # skip something that wasn't a list
+ if not isinstance(cfgmnt[i], list):
+@@ -423,37 +425,51 @@ def handle(_name, cfg, cloud, log, _args
+ cc_lines.append('\t'.join(line))
+
+ fstab_lines = []
++ removed = []
+ for line in util.load_file(FSTAB_PATH).splitlines():
+ try:
+ toks = WS.split(line)
+ if toks[3].find(comment) != -1:
++ removed.append(line)
+ continue
+ except Exception:
+ pass
+ fstab_lines.append(line)
+
++ for d in dirs:
++ try:
++ util.ensure_dir(d)
++ except Exception:
++ util.logexc(log, "Failed to make '%s' config-mount", d)
++
++ sadds = [WS.sub(" ", n) for n in cc_lines]
++ sdrops = [WS.sub(" ", n) for n in removed]
++
++ sops = (["- " + drop for drop in sdrops if drop not in sadds] +
++ ["+ " + add for add in sadds if add not in sdrops])
++
+ fstab_lines.extend(cc_lines)
+ contents = "%s\n" % ('\n'.join(fstab_lines))
+ util.write_file(FSTAB_PATH, contents)
+
++ activate_cmds = []
+ if needswap:
+- try:
+- util.subp(("swapon", "-a"))
+- except Exception:
+- util.logexc(log, "Activating swap via 'swapon -a' failed")
++ activate_cmds.append(["swapon", "-a"])
+
+- for d in dirs:
++ if len(sops) == 0:
++ log.debug("No changes to /etc/fstab made.")
++ else:
++ log.debug("Changes to fstab: %s", sops)
++ activate_cmds.append(["mount", "-a"])
++ if uses_systemd:
++ activate_cmds.append(["systemctl", "daemon-reload"])
++
++ fmt = "Activating swap and mounts with: %s"
++ for cmd in activate_cmds:
++ fmt = "Activate mounts: %s:" + ' '.join(cmd)
+ try:
+- util.ensure_dir(d)
+- except Exception:
+- util.logexc(log, "Failed to make '%s' config-mount", d)
+-
+- activate_cmd = ["mount", "-a"]
+- if uses_systemd:
+- activate_cmd = ["systemctl", "daemon-reload"]
+- fmt = "Activate mounts: %s:" + ' '.join(activate_cmd)
+- try:
+- util.subp(activate_cmd)
+- LOG.debug(fmt, "PASS")
+- except util.ProcessExecutionError:
+- util.logexc(log, fmt, "FAIL")
++ util.subp(cmd)
++ log.debug(fmt, "PASS")
++ except util.ProcessExecutionError:
++ log.warn(fmt, "FAIL")
++ util.logexc(log, fmt, "FAIL")
diff --git a/debian/patches/series b/debian/patches/series
index d303ed06..bbb09c74 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@ cpick-6e92c5f-net-cmdline-Consider-ip-or-ip6-on-command-line-not-only
cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system
cpick-2d2ec70-OpenStack-extend-physical-types-to-include-hyperv-hw_veb
cpick-a9d41de-CloudSigma-Fix-bug-where-datasource-was-not-loaded-in
+cpick-c9c9197-mounts-use-mount-a-again-to-accomplish-mounts