Browse Source

(fix) Fix missing parameter for node pkg list

- When compiling a list of packages to be installed on deploying nodes
  the function call to render all bootactions was missing a parameter
  introduced in [0] to secure the bootaction.
- Add unit testing for this flow

Change-Id: I9f59819d6b79290a9f72db2a5a4c3422f2c79739
Scott Hussey 6 months ago
parent
commit
2c9ec2503a

+ 4
- 2
python/drydock_provisioner/control/bootaction.py View File

@@ -23,8 +23,8 @@ import ulid2
23 23
 import falcon
24 24
 
25 25
 from drydock_provisioner.objects.fields import ActionResult
26
+from drydock_provisioner.objects.fields import BootactionAssetType
26 27
 import drydock_provisioner.objects as objects
27
-
28 28
 from .base import StatefulResource
29 29
 
30 30
 logger = logging.getLogger('drydock')
@@ -261,7 +261,9 @@ class BootactionUtils(object):
261 261
         tarbytes = io.BytesIO()
262 262
         tarball = tarfile.open(
263 263
             mode='w:gz', fileobj=tarbytes, format=tarfile.GNU_FORMAT)
264
-        asset_list = asset_list or []
264
+        asset_list = [
265
+            a for a in asset_list if a.type != BootactionAssetType.PackageList
266
+        ]
265 267
         for a in asset_list:
266 268
             fileobj = io.BytesIO(a.rendered_bytes)
267 269
             tarasset = tarfile.TarInfo(name=a.path)

+ 4
- 0
python/drydock_provisioner/orchestrator/orchestrator.py View File

@@ -627,10 +627,14 @@ class Orchestrator(object):
627 627
 
628 628
         for ba in site_design.bootactions:
629 629
             if nodename in ba.target_nodes:
630
+                # NOTE(sh8121att) the ulid generation below
631
+                # is throw away data as these assets are only used to
632
+                # get a full list of packages to deploy
630 633
                 assets = ba.render_assets(
631 634
                     nodename,
632 635
                     site_design,
633 636
                     ulid2.generate_binary_ulid(),
637
+                    ulid2.generate_binary_ulid(),
634 638
                     task.design_ref,
635 639
                     type_filter=hd_fields.BootactionAssetType.PackageList)
636 640
                 for a in assets:

+ 19
- 1
python/tests/unit/test_bootaction_asset_render.py View File

@@ -17,6 +17,8 @@ import ulid2
17 17
 import os
18 18
 
19 19
 from drydock_provisioner.statemgmt.state import DrydockState
20
+from drydock_provisioner.objects import Task
21
+from drydock_provisioner.objects import fields as hd_fields
20 22
 
21 23
 
22 24
 class TestBootactionRenderAction(object):
@@ -78,7 +80,8 @@ class TestBootactionRenderAction(object):
78 80
                                   action_key, design_ref)
79 81
 
80 82
         assert action_key.hex() in assets[2].rendered_bytes.decode('utf-8')
81
-        assert ulid2.ulid_to_base32(action_id) in assets[2].rendered_bytes.decode('utf-8')
83
+        assert ulid2.ulid_to_base32(
84
+            action_id) in assets[2].rendered_bytes.decode('utf-8')
82 85
 
83 86
     def test_bootaction_network_context(self, input_files,
84 87
                                         deckhand_orchestrator, setup):
@@ -131,3 +134,18 @@ class TestBootactionRenderAction(object):
131 134
         node_ctx = ba.asset_list[0]._get_node_context('compute01', design_data)
132 135
 
133 136
         assert node_ctx['domain'] == node_domain
137
+
138
+    def test_bootaction_pkg_list(self, input_files, deckhand_orchestrator,
139
+                                 setup):
140
+        """Test that a list of packages to be installed on a ndoe can be compiled from boot actions."""
141
+        input_file = input_files.join("deckhand_fullsite.yaml")
142
+
143
+        design_ref = "file://%s" % str(input_file)
144
+
145
+        test_task = Task(
146
+            action=hd_fields.OrchestratorAction.Noop, design_ref=design_ref)
147
+
148
+        pkg_list = deckhand_orchestrator.find_node_package_lists(
149
+            'compute01', test_task)
150
+
151
+        assert len(pkg_list) == 2

+ 4
- 0
python/tests/yaml_samples/deckhand_fullsite.yaml View File

@@ -548,6 +548,10 @@ data:
548 548
       data_pipeline:
549 549
         - utf8_decode
550 550
         - template
551
+    - type: pkg_list
552
+      data:
553
+        2ping: '3.2.1-1'
554
+        '0xffff': null
551 555
 ---
552 556
 schema: 'drydock/BootAction/v1'
553 557
 metadata:

Loading…
Cancel
Save