summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-08-23 16:48:33 -0400
committerScott Moser <smoser@brickies.net>2016-08-23 16:48:33 -0400
commit96ae4fa29fa2f8b2ef886187d48f6c6189287eee (patch)
tree5141b27f7f20314c86250da68a381415a496a7cb
parent5316a7a9a1e1b482730787d73cf8e3d64342ac0b (diff)
downloadcloud-init-git-ubuntu/0.6.3-0ubuntu1.12.tar.gz
Import version 0.6.3-0ubuntu1.12ubuntu/0.6.3-0ubuntu1.12
Imported using git-dsc-commit.
-rw-r--r--debian/changelog9
-rw-r--r--debian/patches/lp-1269626-azure_new_instance.patch58
-rw-r--r--debian/patches/lp-1292648-azure-format-ephemeral-new.patch142
-rw-r--r--debian/patches/series2
4 files changed, 211 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 17c3a4f1..2538fa7a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+cloud-init (0.6.3-0ubuntu1.12) precise-proposed; urgency=low
+
+ * debian/patches/lp-1269626-azure_new_instance.patch: fix handling of new
+ instances on Windows Azure. Backport of fix from 14.04 (LP: #1269626).
+ * debian/patches/lp-1292648-azure-format-ephemeral-new.patch: Azure,
+ re-format ephemeral disk if necessary (LP: #1292648).
+
+ -- Ben Howard <ben.howard@ubuntu.com> Tue, 18 Mar 2014 10:58:12 -0600
+
cloud-init (0.6.3-0ubuntu1.11) precise-proposed; urgency=low
* support apt-add-archive with 'cloud-archive:' format. (LP: #1244355)
diff --git a/debian/patches/lp-1269626-azure_new_instance.patch b/debian/patches/lp-1269626-azure_new_instance.patch
new file mode 100644
index 00000000..53434458
--- /dev/null
+++ b/debian/patches/lp-1269626-azure_new_instance.patch
@@ -0,0 +1,58 @@
+Author: Ben Howard <ben.howard@ubuntu.com>
+Bug: https://launchpad.net/bugs/12696260
+Applied-Upstream: yes
+Description: Fix bug where new instances are not detected
+--- a/cloudinit/DataSourceAzure.py
++++ b/cloudinit/DataSourceAzure.py
+@@ -38,6 +38,7 @@
+ AGENT_START = ['service', 'walinuxagent', 'start']
+ BOUNCE_COMMAND = ['sh', '-xc',
+ "i=$interface; x=0; ifdown $i || x=$?; ifup $i || x=$?; exit $x"]
++DATA_DIR_CLEAN_LIST = ['SharedConfig.xml']
+
+ BUILTIN_DS_CONFIG = {
+ 'agent_command': AGENT_START,
+@@ -128,10 +129,26 @@
+ usercfg = util.get_cfg_by_path(self.cfg, DS_CFG_PATH, {})
+ self.ds_cfg = util.mergedict(usercfg, self.ds_cfg)
+ mycfg = self.ds_cfg
++ ddir = mycfg['data_dir']
++
++ if found != ddir:
++ cached_ovfenv = util.load_file(
++ os.path.join(ddir, 'ovf-env.xml'), quiet=True)
++ if cached_ovfenv != files['ovf-env.xml']:
++ # source was not walinux-agent's datadir, so we have to clean
++ # up so 'wait_for_files' doesn't return early due to stale data
++ cleaned = []
++ for f in [os.path.join(ddir, f) for f in DATA_DIR_CLEAN_LIST]:
++ if os.path.exists(f):
++ futil.del_file(f)
++ cleaned.append(f)
++ if cleaned:
++ LOG.info("removed stale file(s) in '%s': %s",
++ ddir, str(cleaned))
+
+ # walinux agent writes files world readable, but expects
+ # the directory to be protected.
+- write_files(mycfg['data_dir'], files, dirmode=0700)
++ write_files(ddir, files, dirmode=0700)
+
+ # handle the hostname 'publishing'
+ try:
+--- a/cloudinit/future_util.py
++++ b/cloudinit/future_util.py
+@@ -153,3 +153,13 @@
+ types.FunctionType,
+ types.LambdaType)):
+ return str(obj.__name__)
++
++
++def del_file(path):
++ LOG.debug("Attempting to remove %s", path)
++ try:
++ os.unlink(path)
++ except OSError as e:
++ if e.errno != errno.ENOENT:
++ raise e
++
diff --git a/debian/patches/lp-1292648-azure-format-ephemeral-new.patch b/debian/patches/lp-1292648-azure-format-ephemeral-new.patch
new file mode 100644
index 00000000..17a0ed0a
--- /dev/null
+++ b/debian/patches/lp-1292648-azure-format-ephemeral-new.patch
@@ -0,0 +1,142 @@
+Author: Ben Howard <ben.howard@ubuntu.com>
+Bug: https://launchpad.net/bugs/978127
+Applied-Upstream: revno 960
+Description: Azure: re-format ephemeral disk if necessary
+ On azure, the ephemeral disk may be destroyed and replaced with a fresh
+ ephemeral disk on any reboot or stop and start cycle.
+
+ This makes the datasource able to detect that by presence of an unformatted
+ and specifically labeled NTFS filesystem with no files on it.
+--- a/cloudinit/DataSourceAzure.py
++++ b/cloudinit/DataSourceAzure.py
+@@ -17,6 +17,7 @@
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ import base64
++import fnmatch
+ import logging
+ import os
+ import os.path
+@@ -26,6 +27,7 @@
+ import yaml
+ from xml.dom import minidom
+
++from cloudinit.CloudConfig import per_always
+ from cloudinit import DataSource as sources
+ from cloudinit import future_util as futil
+ from cloudinit import seeddir as base_seeddir
+@@ -66,7 +68,7 @@
+
+ DS_CFG_PATH = ['datasource', DS_NAME]
+ USERADD_GROUPS = 'adm,admin,cdrom'
+-
++DEF_EPHEMERAL_LABEL = 'Temporary Storage'
+
+ class DataSourceAzureNet(sources.DataSource):
+ seed_dir = base_seeddir + '/azure'
+@@ -205,6 +207,15 @@
+
+ self.metadata['public-keys'] = pubkeys
+
++ found_ephemeral = find_ephemeral_disk()
++ if found_ephemeral:
++ self.ds_cfg['disk_aliases']['ephemeral0'] = found_ephemeral
++ LOG.debug("using detected ephemeral0 of %s", found_ephemeral)
++
++ cc_modules_override = support_new_ephemeral(self.sys_cfg)
++ if cc_modules_override:
++ self.cfg['cloud_config_modules'] = cc_modules_override
++
+ return True
+
+ def device_name_to_device(self, name):
+@@ -213,6 +224,89 @@
+ def get_config_obj(self):
+ return self.cfg
+
++def count_files(mp):
++ return len(fnmatch.filter(os.listdir(mp), '*[!cdrom]*'))
++
++def find_ephemeral_part():
++ """
++ Locate the default ephmeral0.1 device. This will be the first device
++ that has a LABEL of DEF_EPHEMERAL_LABEL and is a NTFS device. If Azure
++ gets more ephemeral devices, this logic will only identify the first
++ such device.
++ """
++ c_label_devs = util.find_devs_with("LABEL=%s" % DEF_EPHEMERAL_LABEL)
++ c_fstype_devs = util.find_devs_with("TYPE=ntfs")
++ for dev in c_label_devs:
++ if dev in c_fstype_devs:
++ return dev
++ return None
++
++
++def find_ephemeral_disk():
++ """
++ Get the ephemeral disk.
++ """
++ part_dev = find_ephemeral_part()
++ if part_dev and str(part_dev[-1]).isdigit():
++ return part_dev[:-1]
++ elif part_dev:
++ return part_dev
++ return None
++
++def support_new_ephemeral(cfg):
++ """
++ Windows Azure makes ephemeral devices ephemeral to boot; a ephemeral device
++ may be presented as a fresh device, or not.
++
++ Since the knowledge of when a disk is supposed to be plowed under is
++ specific to Windows Azure, the logic resides here in the datasource. When a
++ new ephemeral device is detected, cloud-init overrides the default
++ frequency for both disk-setup and mounts for the current boot only.
++ """
++ device = find_ephemeral_part()
++ if not device:
++ LOG.debug("no default fabric formated ephemeral0.1 found")
++ return None
++ LOG.debug("fabric formated ephemeral0.1 device at %s", device)
++
++ file_count = 0
++ try:
++ file_count = util.mount_callback_umount(device, count_files)
++ except:
++ return None
++ LOG.debug("fabric prepared ephmeral0.1 has %s files on it", file_count)
++
++ if file_count >= 1:
++ LOG.debug("fabric prepared ephemeral0.1 will be preserved")
++ return None
++ else:
++ # if device was already mounted, then we need to unmount it
++ # race conditions could allow for a check-then-unmount
++ # to have a false positive. so just unmount and then check.
++ try:
++ util.subp(['umount', device])
++ except util.ProcessExecutionError as e:
++ if device in util.mounts():
++ LOG.warn("Failed to unmount %s, will not reformat.", device)
++ LOG.debug("Failed umount: %s", e)
++ return None
++
++ LOG.debug("cloud-init will format ephemeral0.1 this boot.")
++ LOG.debug("setting disk_setup and mounts modules 'always' for this boot")
++
++ cc_modules = cfg.get('cloud_config_modules')
++ if not cc_modules:
++ return None
++
++ mod_list = []
++ for mod in cc_modules:
++ if mod in ("disk-setup", "mounts"):
++ mod_list.append([mod, per_always])
++ LOG.debug("set module '%s' to 'always' for this boot", mod)
++ else:
++ mod_list.append(mod)
++ return mod_list
++
+
+ def handle_set_hostname(enabled, hostname, cfg):
+ if not futil.is_true(enabled):
diff --git a/debian/patches/series b/debian/patches/series
index ea7c2524..e0172871 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -19,3 +19,5 @@ lp-1233315-1231490-ephmeralX.Y-support.patch
lp-1247262-fix_futils_smartos.patch
lp-1272115-fix_smartos_compliance.patch
lp-1244355-cloudarchive.patch
+lp-1269626-azure_new_instance.patch
+lp-1292648-azure-format-ephemeral-new.patch