← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1849731] [NEW] Introduction of subplatform around 18.5 broke ConfigDrive

 

Public bug reported:

I create custom LXD images from Ubuntu minimal images for an OpenStack environment based on LXD containers and the images I created worked on Ubuntu 18.04 hosts until around the cloud-init v18.5 release where subplatform was introduced. My images produced this error:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 760, in find_source
    if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 649, in update_metadata
    result = self.get_data()
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 276, in get_data
    self.persist_instance_data()
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 306, in persist_instance_data
    self._get_standardized_metadata())
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 246, in _get_standardized_metadata
    'subplatform': self.subplatform}}
  File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 419, in subplatform
    self._subplatform = self._get_subplatform()
  File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceConfigDrive.py", line 170, in _get_subplatform
    return '%s (%s)' % (subplatform_type, self.source)

This code uses and if/elif which leaves subplatform_type undefined on my image. I don't have any idea what this is supposed to be, but looking at other DataSources, they use an if/else so that subplatform_type is alway defined. This diff makes the code work for my image:
diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
index c3627152..f77923c2 100644
--- a/cloudinit/sources/DataSourceConfigDrive.py
+++ b/cloudinit/sources/DataSourceConfigDrive.py
@@ -163,10 +163,10 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
 
     def _get_subplatform(self):
         """Return the subplatform metadata source details."""
-        if self.seed_dir in self.source:
-            subplatform_type = 'seed-dir'
-        elif self.source.startswith('/dev'):
+        if self.source.startswith('/dev'):
             subplatform_type = 'config-disk'
+        else:
+            subplatform_type = 'seed-dir'
         return '%s (%s)' % (subplatform_type, self.source)

** Affects: cloud-init
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1849731

Title:
  Introduction of subplatform around 18.5 broke ConfigDrive

Status in cloud-init:
  New

Bug description:
  I create custom LXD images from Ubuntu minimal images for an OpenStack environment based on LXD containers and the images I created worked on Ubuntu 18.04 hosts until around the cloud-init v18.5 release where subplatform was introduced. My images produced this error:
  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 760, in find_source
      if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):
    File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 649, in update_metadata
      result = self.get_data()
    File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 276, in get_data
      self.persist_instance_data()
    File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 306, in persist_instance_data
      self._get_standardized_metadata())
    File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 246, in _get_standardized_metadata
      'subplatform': self.subplatform}}
    File "/usr/lib/python3/dist-packages/cloudinit/sources/__init__.py", line 419, in subplatform
      self._subplatform = self._get_subplatform()
    File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceConfigDrive.py", line 170, in _get_subplatform
      return '%s (%s)' % (subplatform_type, self.source)

  This code uses and if/elif which leaves subplatform_type undefined on my image. I don't have any idea what this is supposed to be, but looking at other DataSources, they use an if/else so that subplatform_type is alway defined. This diff makes the code work for my image:
  diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
  index c3627152..f77923c2 100644
  --- a/cloudinit/sources/DataSourceConfigDrive.py
  +++ b/cloudinit/sources/DataSourceConfigDrive.py
  @@ -163,10 +163,10 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
   
       def _get_subplatform(self):
           """Return the subplatform metadata source details."""
  -        if self.seed_dir in self.source:
  -            subplatform_type = 'seed-dir'
  -        elif self.source.startswith('/dev'):
  +        if self.source.startswith('/dev'):
               subplatform_type = 'config-disk'
  +        else:
  +            subplatform_type = 'seed-dir'
           return '%s (%s)' % (subplatform_type, self.source)

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1849731/+subscriptions


Follow ups