Browse Source

Fix plugin parsing for base images

If we try to add a plugin to a base image, e.g.

[neutron-base-plugin-neutron-fwaas]
type = git
location = https://github.com/openstack/neutron-fwaas
reference = master

The build will fail as it parses the above as both
"neutron-base-plugin-neutron-fwaas" and "base-plugin-neutron-fwaas".

Update the regex to ensure the image name is anchored to the beginning of the
conf section.

Change-Id: I4099ebd0d25cd28a9bb3bdc4fcfbf311ce22a3fd
Closes-Bug: #1638900
tags/4.0.0.0b1
Paul Bourke 2 years ago
parent
commit
5ddba7892d
3 changed files with 24 additions and 1 deletions
  1. 1
    1
      kolla/image/build.py
  2. 5
    0
      kolla/tests/etc/default.conf
  3. 18
    0
      kolla/tests/test_build.py

+ 1
- 1
kolla/image/build.py View File

@@ -836,7 +836,7 @@ class KollaWorker(object):
836 836
                                             image.name)
837 837
                 image.source = process_source_installation(image, image.name)
838 838
                 for plugin in [match.group(0) for match in
839
-                               (re.search('{}-plugin-.+'.format(image.name),
839
+                               (re.search('^{}-plugin-.+'.format(image.name),
840 840
                                           section) for section in
841 841
                                 self.conf.list_all_sections()) if match]:
842 842
                     try:

+ 5
- 0
kolla/tests/etc/default.conf View File

@@ -6,6 +6,11 @@ reference = master
6 6
 location = https://git.openstack.org/openstack/networking-arista
7 7
 type = git
8 8
 
9
+[neutron-base-plugin-neutron-fwaas]
10
+reference = master
11
+location = https://git.openstack.org/openstack/neutron-fwaas
12
+type = git
13
+
9 14
 [profiles]
10 15
 default = image-base
11 16
 all = image-base,image-child

+ 18
- 0
kolla/tests/test_build.py View File

@@ -195,6 +195,24 @@ class KollaWorkerTest(base.TestCase):
195 195
         else:
196 196
             self.fail('Can not find the expected neutron arista plugin')
197 197
 
198
+    def test_build_image_list_plugin_parsing(self):
199
+        """Ensure regex used to parse plugins adds them to the correct image"""
200
+        self.conf.set_override('install_type', 'source')
201
+
202
+        kolla = build.KollaWorker(self.conf)
203
+        kolla.setup_working_dir()
204
+        kolla.find_dockerfiles()
205
+        kolla.create_dockerfiles()
206
+        kolla.build_image_list()
207
+        for image in kolla.images:
208
+            if image.name == 'base':
209
+                self.assertEqual(len(image.plugins), 0,
210
+                                 'base image should not have any plugins '
211
+                                 'registered')
212
+                break
213
+        else:
214
+            self.fail('Expected to find the base image in this test')
215
+
198 216
     def _get_matched_images(self, images):
199 217
         return [image for image in images
200 218
                 if image.status == build.STATUS_MATCHED]

Loading…
Cancel
Save