From 4088732b856d7551b4d99786afd82b6151b6de4e Mon Sep 17 00:00:00 2001 From: Tudor Tabacel Date: Thu, 12 Sep 2024 21:00:44 +0200 Subject: [PATCH] node model: adapt to node_properties The nodes are receiving flags from Nodepool via the node_properties attribute on the Node instance. These node_properties need to end up in the nodepool dictionary produced by Zuul when generating the inventory.yaml file. By having the properties in the inventory.yaml file, it is possible at job runtime or in the post analysis to determine certain details about the node that is/was used for the job. Change-Id: I977107332ef3fe4d168c419fbcb9c6cd2607b580 --- doc/source/job-content.rst | 8 ++++++++ tests/base.py | 3 ++- zuul/executor/server.py | 3 ++- zuul/model.py | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/source/job-content.rst b/doc/source/job-content.rst index 737fd7981c..e06753d917 100644 --- a/doc/source/job-content.rst +++ b/doc/source/job-content.rst @@ -1461,6 +1461,14 @@ executor running the job is available: A private IPv6 address of the node. + .. var:: node_properties + + Arbitrary mapping of node properties, such as boolean flags representing + criteria that were taken into account when a node is allocated to Zuul by + Nodepool. Notable properties are `spot` for when a node is an AWS spot + instance or `fleet` when the node was created by Nodepool using the AWS + fleet API. + SSH Keys -------- diff --git a/tests/base.py b/tests/base.py index 28e7fc404a..05c456838e 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1301,7 +1301,8 @@ class FakeNodepool(object): image_id=None, host_keys=host_keys, executor='fake-nodepool', - hold_expiration=None) + hold_expiration=None, + node_properties={"spot": False}) if self.resources: data['resources'] = self.resources if self.remote_ansible: diff --git a/zuul/executor/server.py b/zuul/executor/server.py index f28bc8705f..b3b61208bf 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -2119,7 +2119,8 @@ class AnsibleJob(object): public_ipv4=node.public_ipv4, private_ipv4=node.private_ipv4, public_ipv6=node.public_ipv6, - private_ipv6=node.private_ipv6))) + private_ipv6=node.private_ipv6, + node_properties=node.node_properties))) # Ansible >=2.8 introduced "auto" as an # ansible_python_interpreter argument that looks up diff --git a/zuul/model.py b/zuul/model.py index 0f512750a7..b0ef6fa1ab 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -1895,6 +1895,7 @@ class Node(ConfigObject): self.attributes = {} self.tenant_name = None self.requestor = None + self.node_properties = {} @property def state(self):