diff options
author | Scott Moser <smoser@brickies.net> | 2020-11-10 09:51:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 09:51:16 -0500 |
commit | 2730521fd566f855863c5ed049a1df26abcd0770 (patch) | |
tree | 2e42132a711888ebfc4117376a4577a33d0fe71a | |
parent | 57349eb7df1c422d9e9558e54b201c85778997ae (diff) | |
download | vyos-cloud-init-2730521fd566f855863c5ed049a1df26abcd0770.tar.gz vyos-cloud-init-2730521fd566f855863c5ed049a1df26abcd0770.zip |
Fix stacktrace in DataSourceRbxCloud if no metadata disk is found (#632)
Largely speaking, ds-identify protects from this scenario being
hit, but if DataSourceRbxCloud ran and there was no metadata
disks found (LABEL=CLOUDMD), then it would stacktrace.
The fix is just to clean up the get_md function a little
bit, and the explicitly check for False as a return value in _get_data.
-rw-r--r-- | cloudinit/sources/DataSourceRbxCloud.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cloudinit/sources/DataSourceRbxCloud.py b/cloudinit/sources/DataSourceRbxCloud.py index e064c8d6..0b8994bf 100644 --- a/cloudinit/sources/DataSourceRbxCloud.py +++ b/cloudinit/sources/DataSourceRbxCloud.py @@ -71,11 +71,13 @@ def gratuitous_arp(items, distro): def get_md(): - rbx_data = None + """Returns False (not found or error) or a dictionary with metadata.""" devices = set( util.find_devs_with('LABEL=CLOUDMD') + util.find_devs_with('LABEL=cloudmd') ) + if not devices: + return False for device in devices: try: rbx_data = util.mount_cb( @@ -84,17 +86,17 @@ def get_md(): mtype=['vfat', 'fat', 'msdosfs'] ) if rbx_data: - break + return rbx_data except OSError as err: if err.errno != errno.ENOENT: raise except util.MountFailedError: util.logexc(LOG, "Failed to mount %s when looking for user " "data", device) - if not rbx_data: - util.logexc(LOG, "Failed to load metadata and userdata") - return False - return rbx_data + + LOG.debug("Did not find RbxCloud data, searched devices: %s", + ",".join(devices)) + return False def generate_network_config(netadps): @@ -223,6 +225,8 @@ class DataSourceRbxCloud(sources.DataSource): is used to perform instance configuration. """ rbx_data = get_md() + if rbx_data is False: + return False self.userdata_raw = rbx_data['userdata'] self.metadata = rbx_data['metadata'] self.gratuitous_arp = rbx_data['gratuitous_arp'] |