From e32da7145da30dd9c326fe6d98657536f169c074 Mon Sep 17 00:00:00 2001 From: rpotla Date: Wed, 20 Aug 2025 22:18:51 -0400 Subject: [PATCH 1/7] add label to nodepool --- plugins/modules/lke_cluster.py | 33 +++++++++++++++++++ plugins/modules/lke_node_pool.py | 12 +++++++ .../targets/lke_cluster_basic/tasks/main.yaml | 4 +++ .../lke_node_pool_basic/tasks/main.yaml | 4 +++ 4 files changed, 53 insertions(+) diff --git a/plugins/modules/lke_cluster.py b/plugins/modules/lke_cluster.py index 518f62c5..acef634a 100644 --- a/plugins/modules/lke_cluster.py +++ b/plugins/modules/lke_cluster.py @@ -134,6 +134,12 @@ } linode_lke_cluster_node_pool_spec = { + "label": SpecField( + type=FieldType.string, + editable=True, + description=["A unique label for this Node Pool."], + required=False, + ), "count": SpecField( type=FieldType.integer, editable=True, @@ -567,6 +573,20 @@ def _update_cluster(self, cluster: LKECluster) -> None: current_pool.labels = pool.get("labels") current_pool.save() + + if ( + "label" in pool + and current_pool.label != pool["label"] + ): + self.register_action( + "Updated label for Node Pool {}".format( + current_pool.id + ) + ) + + current_pool.label = pool.get("label") + current_pool.save() + pools_handled[k] = True should_keep[i] = True break @@ -635,6 +655,19 @@ def _update_cluster(self, cluster: LKECluster) -> None: existing_pool.labels = pool["labels"] should_update = True + if ( + "label" in pool + and existing_pool.label != pool["label"] + ): + self.register_action( + "Updated label for Node Pool {}".format( + existing_pool.id + ) + ) + + existing_pool.label = pool["label"] + should_update = True + if should_update: existing_pool.save() diff --git a/plugins/modules/lke_node_pool.py b/plugins/modules/lke_node_pool.py index 910acd94..4a063465 100644 --- a/plugins/modules/lke_node_pool.py +++ b/plugins/modules/lke_node_pool.py @@ -111,6 +111,12 @@ editable=True, description=["The number of nodes in the Node Pool."], ), + "label": SpecField( + type=FieldType.string, + editable=True, + description=["A unique label for this Node Pool."], + required=False, + ), "disks": SpecField( type=FieldType.list, element_type=FieldType.dict, @@ -319,6 +325,7 @@ def _update_pool(self, pool: LKENodePool) -> LKENodePool: new_count = params.pop("count") new_taints = params.pop("taints") if "taints" in params else None new_labels = params.pop("labels") if "labels" in params else None + new_label = params.pop("label") if "label" in params else None new_k8s_version = ( params.pop("k8s_version") if "k8s_version" in params else None ) @@ -362,6 +369,11 @@ def _update_pool(self, pool: LKENodePool) -> LKENodePool: pool.labels = new_labels should_update = True + if new_label is not None and pool.label != new_label: + self.register_action("Updated label for Node Pool") + pool.label = new_label + should_update = True + if new_k8s_version is not None and pool.k8s_version != new_k8s_version: self.register_action("Updated k8s version for Node Pool") pool.k8s_version = new_k8s_version diff --git a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml index 49669453..19ca7df5 100644 --- a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml +++ b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml @@ -40,6 +40,7 @@ effect: NoExecute - type: g6-standard-4 count: 1 + label: pool-with-autoscaler autoscaler: enabled: true min: 1 @@ -55,6 +56,7 @@ - create_cluster.cluster.region == 'us-southeast' - create_cluster.node_pools[0].type == 'g6-standard-1' - create_cluster.node_pools[0].count == 3 + - create_cluster.node_pools[0].label == 'pool-with-autoscaler' - create_cluster.node_pools[0].labels['foo.example.com/test'] == 'bar' - create_cluster.node_pools[0].labels['foo.example.com/test2'] == 'foo' - create_cluster.node_pools[0].taints[0].key == 'foo.example.com/test2' @@ -73,6 +75,7 @@ node_pools: - type: g6-standard-1 count: 2 + label: updated-pool-label labels: foo.example.com/update: updated foo.example.com/test2: foo @@ -97,6 +100,7 @@ - update_pools.node_pools[0].type == 'g6-standard-1' - update_pools.node_pools[0].count == 2 + - update_pools.node_pools[0].label == 'updated-pool-label' - update_pools.node_pools[0].id == create_cluster.node_pools[0].id - update_pools.node_pools[0].labels['foo.example.com/update'] == 'updated' diff --git a/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml b/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml index f6f32da1..2c25cbd2 100644 --- a/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml +++ b/tests/integration/targets/lke_node_pool_basic/tasks/main.yaml @@ -44,6 +44,7 @@ tags: ['my-pool'] type: g6-standard-1 count: 2 + label: new-pool-label labels: foo.example.com/test: bar foo.example.com/test2: foo @@ -58,6 +59,7 @@ assert: that: - new_pool.node_pool.count == 2 + - new_pool.node_pool.label == 'new-pool-label' - new_pool.node_pool.type == 'g6-standard-1' - new_pool.node_pool.nodes[0].status == 'ready' - new_pool.node_pool.nodes[1].status == 'ready' @@ -86,6 +88,7 @@ type: g6-standard-1 count: 1 skip_polling: true + label: updated-pool-label autoscaler: enabled: true min: 1 @@ -104,6 +107,7 @@ assert: that: - update_pool.node_pool.count == 1 + - update_pool.node_pool.label == 'updated-pool-label' - update_pool.node_pool.type == 'g6-standard-1' - update_pool.node_pool.autoscaler.enabled - update_pool.node_pool.autoscaler.min == 1 From a7c09a140dd88f943e27d16e0669199fd8513b9a Mon Sep 17 00:00:00 2001 From: rpotla Date: Wed, 20 Aug 2025 22:37:04 -0400 Subject: [PATCH 2/7] fix linter --- plugins/modules/lke_cluster.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/modules/lke_cluster.py b/plugins/modules/lke_cluster.py index acef634a..534123af 100644 --- a/plugins/modules/lke_cluster.py +++ b/plugins/modules/lke_cluster.py @@ -573,11 +573,7 @@ def _update_cluster(self, cluster: LKECluster) -> None: current_pool.labels = pool.get("labels") current_pool.save() - - if ( - "label" in pool - and current_pool.label != pool["label"] - ): + if "label" in pool and current_pool.label != pool["label"]: self.register_action( "Updated label for Node Pool {}".format( current_pool.id @@ -655,10 +651,7 @@ def _update_cluster(self, cluster: LKECluster) -> None: existing_pool.labels = pool["labels"] should_update = True - if ( - "label" in pool - and existing_pool.label != pool["label"] - ): + if "label" in pool and existing_pool.label != pool["label"]: self.register_action( "Updated label for Node Pool {}".format( existing_pool.id From b1fc93c80c588ea860cc038108c990ba0e3a7d12 Mon Sep 17 00:00:00 2001 From: rpotla Date: Thu, 21 Aug 2025 11:19:47 -0400 Subject: [PATCH 3/7] update docs --- docs/inventory/instance.rst | 16 ++++++++-------- docs/modules/lke_cluster.md | 1 + docs/modules/lke_node_pool.md | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/inventory/instance.rst b/docs/inventory/instance.rst index b35fe27b..a6ebb030 100644 --- a/docs/inventory/instance.rst +++ b/docs/inventory/instance.rst @@ -76,19 +76,19 @@ Parameters **parent_group (type=str):** - \• parent group for keyed group + \• parent group for keyed group. **prefix (type=str):** - \• A keyed group name will start with this prefix + \• A keyed group name will start with this prefix. **separator (type=str, default=_):** - \• separator used to build the keyed group name + \• separator used to build the keyed group name. **key (type=str):** - \• The key from input dictionary used to generate groups + \• The key from input dictionary used to generate groups. **default_value (type=str):** @@ -98,7 +98,7 @@ Parameters **trailing_separator (type=bool, default=True):** - \• Set this option to :literal:`False` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is an empty string. + \• Set this option to :literal:`false` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is an empty string. \• This option is mutually exclusive with :literal:`keyed\_groups[].default\_value`. @@ -109,13 +109,13 @@ Parameters **leading_separator (type=boolean, default=True):** - \• Use in conjunction with keyed\_groups. + \• Use in conjunction with :literal:`keyed\_groups`. \• By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore. - \• This is because the default prefix is "" and the default separator is "\_". + \• This is because the default prefix is :literal:`""` and the default separator is :literal:`"\_"`. - \• Set this option to False to omit the leading underscore (or other separator) if no prefix is given. + \• Set this option to :literal:`false` to omit the leading underscore (or other separator) if no prefix is given. \• If the group name is derived from a mapping the separator is still used to concatenate the items. diff --git a/docs/modules/lke_cluster.md b/docs/modules/lke_cluster.md index c472f6cc..cf84cf04 100644 --- a/docs/modules/lke_cluster.md +++ b/docs/modules/lke_cluster.md @@ -89,6 +89,7 @@ Manage Linode LKE clusters. |-----------|------|----------|------------------------------------------------------------------------------| | `count` |
`int`
|
**Required**
| The number of nodes in the Node Pool. **(Updatable)** | | `type` |
`str`
|
**Required**
| The Linode Type for all of the nodes in the Node Pool. | +| `label` |
`str`
|
Optional
| A unique label for this Node Pool. **(Updatable)** | | [`autoscaler` (sub-options)](#autoscaler) |
`dict`
|
Optional
| When enabled, the number of nodes autoscales within the defined minimum and maximum values. **(Updatable)** | | `labels` |
`dict`
|
Optional
| Key-value pairs added as labels to nodes in the node pool. Labels help classify your nodes and to easily select subsets of objects. **(Updatable)** | | [`taints` (sub-options)](#taints) |
`list`
|
Optional
| Kubernetes taints to add to node pool nodes. Taints help control how pods are scheduled onto nodes, specifically allowing them to repel certain pods. **(Updatable)** | diff --git a/docs/modules/lke_node_pool.md b/docs/modules/lke_node_pool.md index 18787a4f..a24df30d 100644 --- a/docs/modules/lke_node_pool.md +++ b/docs/modules/lke_node_pool.md @@ -57,6 +57,7 @@ Manage Linode LKE cluster node pools. | `state` |
`str`
|
**Required**
| The desired state of the target. **(Choices: `present`, `absent`)** | | [`autoscaler` (sub-options)](#autoscaler) |
`dict`
|
Optional
| When enabled, the number of nodes autoscales within the defined minimum and maximum values. **(Updatable)** | | `count` |
`int`
|
Optional
| The number of nodes in the Node Pool. **(Updatable)** | +| `label` |
`str`
|
Optional
| A unique label for this Node Pool. **(Updatable)** | | [`disks` (sub-options)](#disks) |
`list`
|
Optional
| This Node Pool’s custom disk layout. Each item in this array will create a new disk partition for each node in this Node Pool. | | `type` |
`str`
|
Optional
| The Linode Type for all of the nodes in the Node Pool. Required if `state` == `present`. | | `skip_polling` |
`bool`
|
Optional
| If true, the module will not wait for all nodes in the node pool to be ready. **(Default: `False`)** | From c8782b9587393271d2fcae41b2f8a483b0172957 Mon Sep 17 00:00:00 2001 From: rpotla Date: Mon, 8 Sep 2025 18:26:57 -0400 Subject: [PATCH 4/7] upgrade python sdk --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 15f37ced..df97a767 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -linode-api4>=5.34.0 +linode-api4>=5.35.0 polling==0.3.2 ansible-specdoc>=0.0.19 From 65ffc06a5bed334de72f77413a3f4721332fe123 Mon Sep 17 00:00:00 2001 From: rammanoj Date: Fri, 12 Sep 2025 14:49:02 -0400 Subject: [PATCH 5/7] Update tests/integration/targets/lke_cluster_basic/tasks/main.yaml Co-authored-by: Erik Zilber --- tests/integration/targets/lke_cluster_basic/tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml index 19ca7df5..79d78368 100644 --- a/tests/integration/targets/lke_cluster_basic/tasks/main.yaml +++ b/tests/integration/targets/lke_cluster_basic/tasks/main.yaml @@ -56,7 +56,7 @@ - create_cluster.cluster.region == 'us-southeast' - create_cluster.node_pools[0].type == 'g6-standard-1' - create_cluster.node_pools[0].count == 3 - - create_cluster.node_pools[0].label == 'pool-with-autoscaler' + - create_cluster.node_pools[1].label == 'pool-with-autoscaler' - create_cluster.node_pools[0].labels['foo.example.com/test'] == 'bar' - create_cluster.node_pools[0].labels['foo.example.com/test2'] == 'foo' - create_cluster.node_pools[0].taints[0].key == 'foo.example.com/test2' From 9d0b0f9fc6c0dddf825866ce7fe1127a97c43376 Mon Sep 17 00:00:00 2001 From: ezilber-akamai Date: Fri, 12 Sep 2025 15:06:28 -0400 Subject: [PATCH 6/7] Fix docs --- docs/inventory/instance.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/inventory/instance.rst b/docs/inventory/instance.rst index a6ebb030..b35fe27b 100644 --- a/docs/inventory/instance.rst +++ b/docs/inventory/instance.rst @@ -76,19 +76,19 @@ Parameters **parent_group (type=str):** - \• parent group for keyed group. + \• parent group for keyed group **prefix (type=str):** - \• A keyed group name will start with this prefix. + \• A keyed group name will start with this prefix **separator (type=str, default=_):** - \• separator used to build the keyed group name. + \• separator used to build the keyed group name **key (type=str):** - \• The key from input dictionary used to generate groups. + \• The key from input dictionary used to generate groups **default_value (type=str):** @@ -98,7 +98,7 @@ Parameters **trailing_separator (type=bool, default=True):** - \• Set this option to :literal:`false` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is an empty string. + \• Set this option to :literal:`False` to omit the :literal:`keyed\_groups[].separator` after the host variable when the value is an empty string. \• This option is mutually exclusive with :literal:`keyed\_groups[].default\_value`. @@ -109,13 +109,13 @@ Parameters **leading_separator (type=boolean, default=True):** - \• Use in conjunction with :literal:`keyed\_groups`. + \• Use in conjunction with keyed\_groups. \• By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore. - \• This is because the default prefix is :literal:`""` and the default separator is :literal:`"\_"`. + \• This is because the default prefix is "" and the default separator is "\_". - \• Set this option to :literal:`false` to omit the leading underscore (or other separator) if no prefix is given. + \• Set this option to False to omit the leading underscore (or other separator) if no prefix is given. \• If the group name is derived from a mapping the separator is still used to concatenate the items. From e7ff3fe30ec1d7af167b4e0542b57a397412aeeb Mon Sep 17 00:00:00 2001 From: ezilber-akamai Date: Fri, 12 Sep 2025 15:24:42 -0400 Subject: [PATCH 7/7] Fix lint --- plugins/inventory/instance.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/inventory/instance.py b/plugins/inventory/instance.py index ba47a1b2..404c4063 100644 --- a/plugins/inventory/instance.py +++ b/plugins/inventory/instance.py @@ -97,6 +97,7 @@ HAS_LINODE = False +# pylint: disable=too-many-ancestors class InventoryModule(BaseInventoryPlugin, Constructable): """Linode instance inventory plugin"""