← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1514051] [NEW] Networking info (network_data.json) exist only into ConfigDrive if content is not empty.

 

Public bug reported:

Networking info (network_data.json) exist only into ConfigDrive if
content is not empty.

Blueprint: https://blueprints.launchpad.net/nova/+spec/metadata-service-
network-info

Environment:
centos 7 
openstack liberty.

Steps to reproduce:
1. Up two instances:

# nova boot \
	--flavor 2 \
	--image fedora23 \
	--config-drive=True \
	--nic net-id=a5d1181f-bedd-40a5-8b4a-5574b74dba61 \
	--nic net-id=286b3e3c-9075-496f-8899-c9890397f087 \
	--nic net-id=a3931414-73c3-40c9-a39b-d93ae38844a2 \
	--user-data=/root/cloud-config \
	test

# nova boot \
	--flavor 2 \
	--image fedora23 \
	--config-drive=True \
	--nic net-id=a5d1181f-bedd-40a5-8b4a-5574b74dba61 \
	--nic net-id=286b3e3c-9075-496f-8899-c9890397f087 \
	--nic net-id=a3931414-73c3-40c9-a39b-d93ae38844a2 \
	--user-data=/root/cloud-config \
	--file test_file=test_file \
	test2

Different between two calls - instance name (test and test2) and --file
parameter (for test2 instance).

Content of the test_file is:

test_file

Logon on two instances and exec on every instance:

# mount /dev/disk/by-label/config-2 /mnt

After it check files into the /mnt folder.

test instance:

# find /mnt
/mnt
/mnt/ec2
/mnt/ec2/2009-04-04
/mnt/ec2/2009-04-04/meta-data.json
/mnt/ec2/2009-04-04/user-data
/mnt/ec2/latest
/mnt/ec2/latest/meta-data.json
/mnt/ec2/latest/user-data
/mnt/openstack
/mnt/openstack/2012-08-10
/mnt/openstack/2012-08-10/meta_data.json
/mnt/openstack/2012-08-10/user_data
/mnt/openstack/2013-04-04
/mnt/openstack/2013-04-04/meta_data.json
/mnt/openstack/2013-04-04/user_data
/mnt/openstack/2013-10-17
/mnt/openstack/2013-10-17/meta_data.json
/mnt/openstack/2013-10-17/user_data
/mnt/openstack/2013-10-17/vendor_data.json
/mnt/openstack/2015-10-15
/mnt/openstack/2015-10-15/meta_data.json
/mnt/openstack/2015-10-15/user_data
/mnt/openstack/2015-10-15/vendor_data.json
/mnt/openstack/latest
/mnt/openstack/latest/meta_data.json
/mnt/openstack/latest/user_data
/mnt/openstack/latest/vendor_data.json

test2 instance:

# find /mnt
/mnt
/mnt/ec2
/mnt/ec2/2009-04-04
/mnt/ec2/2009-04-04/meta-data.json
/mnt/ec2/2009-04-04/user-data
/mnt/ec2/latest
/mnt/ec2/latest/meta-data.json
/mnt/ec2/latest/user-data
/mnt/openstack
/mnt/openstack/2012-08-10
/mnt/openstack/2012-08-10/meta_data.json
/mnt/openstack/2012-08-10/user_data
/mnt/openstack/2013-04-04
/mnt/openstack/2013-04-04/meta_data.json
/mnt/openstack/2013-04-04/user_data
/mnt/openstack/2013-10-17
/mnt/openstack/2013-10-17/meta_data.json
/mnt/openstack/2013-10-17/user_data
/mnt/openstack/2013-10-17/vendor_data.json
/mnt/openstack/2015-10-15
/mnt/openstack/2015-10-15/meta_data.json
/mnt/openstack/2015-10-15/user_data
/mnt/openstack/2015-10-15/vendor_data.json
/mnt/openstack/content
/mnt/openstack/content/0000
/mnt/openstack/latest
/mnt/openstack/latest/meta_data.json
/mnt/openstack/latest/network_data.json
/mnt/openstack/latest/user_data
/mnt/openstack/latest/vendor_data.json

Different between two instances: file /mnt/openstack/latest/network_data.json and file /mnt/openstack/content/0000. 
The file network_data.json exist into the test2 instance and does not exist into the test instance.

How created ConfigDrive?

File /usr/lib/python2.7/site-packages/nova/api/metadata/base.py

    446     def metadata_for_config_drive(self):
    447         """Yields (path, value) tuples for metadata elements."""
...
    479 
    480         for (cid, content) in six.iteritems(self.content):
    481             if self._check_version(LIBERTY, version, ALL_OPENSTACK_VERSIONS):
    482                 path = 'openstack/%s/%s' % (version, NW_JSON_NAME)
    483                 yield (path, self.lookup(path))
    484 
    485             yield ('%s/%s/%s' % ("openstack", CONTENT_DIR, cid), content)


For test instance self.content = {}
For test2 instance self.content = {'0000': 'test_file\n'}

If self.content is empty, NW_JSON_NAME will not be added to ConfigDrive.

Patch:

--- /tmp/base.py	2015-11-07 08:16:06.981000000 +0000
+++ /usr/lib/python2.7/site-packages/nova/api/metadata/base.py	2015-11-07 08:28:55.972000000 +0000
@@ -477,11 +477,11 @@
                 path = 'openstack/%s/%s' % (version, VD_JSON_NAME)
                 yield (path, self.lookup(path))
 
-        for (cid, content) in six.iteritems(self.content):
             if self._check_version(LIBERTY, version, ALL_OPENSTACK_VERSIONS):
                 path = 'openstack/%s/%s' % (version, NW_JSON_NAME)
                 yield (path, self.lookup(path))
 
+        for (cid, content) in six.iteritems(self.content):
             yield ('%s/%s/%s' % ("openstack", CONTENT_DIR, cid), content)

Atfer patching:

Content of the ConfigDrive for test instance:

[root@test ~]# mount /dev/disk/by-label/config-2 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@test ~]# find /mnt
/mnt
/mnt/ec2
/mnt/ec2/2009-04-04
/mnt/ec2/2009-04-04/meta-data.json
/mnt/ec2/2009-04-04/user-data
/mnt/ec2/latest
/mnt/ec2/latest/meta-data.json
/mnt/ec2/latest/user-data
/mnt/openstack
/mnt/openstack/2012-08-10
/mnt/openstack/2012-08-10/meta_data.json
/mnt/openstack/2012-08-10/user_data
/mnt/openstack/2013-04-04
/mnt/openstack/2013-04-04/meta_data.json
/mnt/openstack/2013-04-04/user_data
/mnt/openstack/2013-10-17
/mnt/openstack/2013-10-17/meta_data.json
/mnt/openstack/2013-10-17/user_data
/mnt/openstack/2013-10-17/vendor_data.json
/mnt/openstack/2015-10-15
/mnt/openstack/2015-10-15/meta_data.json
/mnt/openstack/2015-10-15/network_data.json
/mnt/openstack/2015-10-15/user_data
/mnt/openstack/2015-10-15/vendor_data.json
/mnt/openstack/latest
/mnt/openstack/latest/meta_data.json
/mnt/openstack/latest/network_data.json
/mnt/openstack/latest/user_data
/mnt/openstack/latest/vendor_data.json

network_data.json file was added to 2015-10-15 and latest folders.

** Affects: nova
     Importance: Undecided
         Status: New


** Tags: config-drive metadata

** Patch added: "configDrive.patch"
   https://bugs.launchpad.net/bugs/1514051/+attachment/4514700/+files/configDrive.patch

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1514051

Title:
  Networking info (network_data.json) exist only into ConfigDrive if
  content is not empty.

Status in OpenStack Compute (nova):
  New

Bug description:
  Networking info (network_data.json) exist only into ConfigDrive if
  content is not empty.

  Blueprint: https://blueprints.launchpad.net/nova/+spec/metadata-
  service-network-info

  Environment:
  centos 7 
  openstack liberty.

  Steps to reproduce:
  1. Up two instances:

  # nova boot \
  	--flavor 2 \
  	--image fedora23 \
  	--config-drive=True \
  	--nic net-id=a5d1181f-bedd-40a5-8b4a-5574b74dba61 \
  	--nic net-id=286b3e3c-9075-496f-8899-c9890397f087 \
  	--nic net-id=a3931414-73c3-40c9-a39b-d93ae38844a2 \
  	--user-data=/root/cloud-config \
  	test

  # nova boot \
  	--flavor 2 \
  	--image fedora23 \
  	--config-drive=True \
  	--nic net-id=a5d1181f-bedd-40a5-8b4a-5574b74dba61 \
  	--nic net-id=286b3e3c-9075-496f-8899-c9890397f087 \
  	--nic net-id=a3931414-73c3-40c9-a39b-d93ae38844a2 \
  	--user-data=/root/cloud-config \
  	--file test_file=test_file \
  	test2

  Different between two calls - instance name (test and test2) and
  --file parameter (for test2 instance).

  Content of the test_file is:

  test_file

  Logon on two instances and exec on every instance:

  # mount /dev/disk/by-label/config-2 /mnt

  After it check files into the /mnt folder.

  test instance:

  # find /mnt
  /mnt
  /mnt/ec2
  /mnt/ec2/2009-04-04
  /mnt/ec2/2009-04-04/meta-data.json
  /mnt/ec2/2009-04-04/user-data
  /mnt/ec2/latest
  /mnt/ec2/latest/meta-data.json
  /mnt/ec2/latest/user-data
  /mnt/openstack
  /mnt/openstack/2012-08-10
  /mnt/openstack/2012-08-10/meta_data.json
  /mnt/openstack/2012-08-10/user_data
  /mnt/openstack/2013-04-04
  /mnt/openstack/2013-04-04/meta_data.json
  /mnt/openstack/2013-04-04/user_data
  /mnt/openstack/2013-10-17
  /mnt/openstack/2013-10-17/meta_data.json
  /mnt/openstack/2013-10-17/user_data
  /mnt/openstack/2013-10-17/vendor_data.json
  /mnt/openstack/2015-10-15
  /mnt/openstack/2015-10-15/meta_data.json
  /mnt/openstack/2015-10-15/user_data
  /mnt/openstack/2015-10-15/vendor_data.json
  /mnt/openstack/latest
  /mnt/openstack/latest/meta_data.json
  /mnt/openstack/latest/user_data
  /mnt/openstack/latest/vendor_data.json

  test2 instance:

  # find /mnt
  /mnt
  /mnt/ec2
  /mnt/ec2/2009-04-04
  /mnt/ec2/2009-04-04/meta-data.json
  /mnt/ec2/2009-04-04/user-data
  /mnt/ec2/latest
  /mnt/ec2/latest/meta-data.json
  /mnt/ec2/latest/user-data
  /mnt/openstack
  /mnt/openstack/2012-08-10
  /mnt/openstack/2012-08-10/meta_data.json
  /mnt/openstack/2012-08-10/user_data
  /mnt/openstack/2013-04-04
  /mnt/openstack/2013-04-04/meta_data.json
  /mnt/openstack/2013-04-04/user_data
  /mnt/openstack/2013-10-17
  /mnt/openstack/2013-10-17/meta_data.json
  /mnt/openstack/2013-10-17/user_data
  /mnt/openstack/2013-10-17/vendor_data.json
  /mnt/openstack/2015-10-15
  /mnt/openstack/2015-10-15/meta_data.json
  /mnt/openstack/2015-10-15/user_data
  /mnt/openstack/2015-10-15/vendor_data.json
  /mnt/openstack/content
  /mnt/openstack/content/0000
  /mnt/openstack/latest
  /mnt/openstack/latest/meta_data.json
  /mnt/openstack/latest/network_data.json
  /mnt/openstack/latest/user_data
  /mnt/openstack/latest/vendor_data.json

  Different between two instances: file /mnt/openstack/latest/network_data.json and file /mnt/openstack/content/0000. 
  The file network_data.json exist into the test2 instance and does not exist into the test instance.

  How created ConfigDrive?

  File /usr/lib/python2.7/site-packages/nova/api/metadata/base.py

      446     def metadata_for_config_drive(self):
      447         """Yields (path, value) tuples for metadata elements."""
  ...
      479 
      480         for (cid, content) in six.iteritems(self.content):
      481             if self._check_version(LIBERTY, version, ALL_OPENSTACK_VERSIONS):
      482                 path = 'openstack/%s/%s' % (version, NW_JSON_NAME)
      483                 yield (path, self.lookup(path))
      484 
      485             yield ('%s/%s/%s' % ("openstack", CONTENT_DIR, cid), content)

  
  For test instance self.content = {}
  For test2 instance self.content = {'0000': 'test_file\n'}

  If self.content is empty, NW_JSON_NAME will not be added to
  ConfigDrive.

  Patch:

  --- /tmp/base.py	2015-11-07 08:16:06.981000000 +0000
  +++ /usr/lib/python2.7/site-packages/nova/api/metadata/base.py	2015-11-07 08:28:55.972000000 +0000
  @@ -477,11 +477,11 @@
                   path = 'openstack/%s/%s' % (version, VD_JSON_NAME)
                   yield (path, self.lookup(path))
   
  -        for (cid, content) in six.iteritems(self.content):
               if self._check_version(LIBERTY, version, ALL_OPENSTACK_VERSIONS):
                   path = 'openstack/%s/%s' % (version, NW_JSON_NAME)
                   yield (path, self.lookup(path))
   
  +        for (cid, content) in six.iteritems(self.content):
               yield ('%s/%s/%s' % ("openstack", CONTENT_DIR, cid), content)

  Atfer patching:

  Content of the ConfigDrive for test instance:

  [root@test ~]# mount /dev/disk/by-label/config-2 /mnt
  mount: /dev/sr0 is write-protected, mounting read-only
  [root@test ~]# find /mnt
  /mnt
  /mnt/ec2
  /mnt/ec2/2009-04-04
  /mnt/ec2/2009-04-04/meta-data.json
  /mnt/ec2/2009-04-04/user-data
  /mnt/ec2/latest
  /mnt/ec2/latest/meta-data.json
  /mnt/ec2/latest/user-data
  /mnt/openstack
  /mnt/openstack/2012-08-10
  /mnt/openstack/2012-08-10/meta_data.json
  /mnt/openstack/2012-08-10/user_data
  /mnt/openstack/2013-04-04
  /mnt/openstack/2013-04-04/meta_data.json
  /mnt/openstack/2013-04-04/user_data
  /mnt/openstack/2013-10-17
  /mnt/openstack/2013-10-17/meta_data.json
  /mnt/openstack/2013-10-17/user_data
  /mnt/openstack/2013-10-17/vendor_data.json
  /mnt/openstack/2015-10-15
  /mnt/openstack/2015-10-15/meta_data.json
  /mnt/openstack/2015-10-15/network_data.json
  /mnt/openstack/2015-10-15/user_data
  /mnt/openstack/2015-10-15/vendor_data.json
  /mnt/openstack/latest
  /mnt/openstack/latest/meta_data.json
  /mnt/openstack/latest/network_data.json
  /mnt/openstack/latest/user_data
  /mnt/openstack/latest/vendor_data.json

  network_data.json file was added to 2015-10-15 and latest folders.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1514051/+subscriptions