Skip to content

Commit abca77b

Browse files
Merge pull request #683 from linode/dev
Release v0.39.0
2 parents 456caf7 + d866866 commit abca77b

File tree

5 files changed

+144
-15
lines changed

5 files changed

+144
-15
lines changed

docs/modules/nodebalancer.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Manage a Linode NodeBalancer.
44

5+
NOTE: UDP NodeBalancer may not currently be available to all users.
6+
57
- [Minimum Required Fields](#minimum-required-fields)
68
- [Examples](#examples)
79
- [Parameters](#parameters)
@@ -46,6 +48,7 @@ Manage a Linode NodeBalancer.
4648
| `label` | <center>`str`</center> | <center>**Required**</center> | The unique label to give this NodeBalancer. |
4749
| `state` | <center>`str`</center> | <center>**Required**</center> | The desired state of the target. **(Choices: `present`, `absent`)** |
4850
| `client_conn_throttle` | <center>`int`</center> | <center>Optional</center> | Throttle connections per second. Set to 0 (zero) to disable throttling. **(Updatable)** |
51+
| `client_udp_sess_throttle` | <center>`int`</center> | <center>Optional</center> | Throttle UDP sessions per second (0-20). Set to 0 (zero) to disable throttling. **(Updatable)** |
4952
| `region` | <center>`str`</center> | <center>Optional</center> | The ID of the Region to create this NodeBalancer in. |
5053
| `firewall_id` | <center>`int`</center> | <center>Optional</center> | The ID of the Firewall to assign this NodeBalancer to. |
5154
| `tags` | <center>`list`</center> | <center>Optional</center> | Tags to assign to this NodeBalancer. **(Updatable)** |
@@ -55,22 +58,23 @@ Manage a Linode NodeBalancer.
5558

5659
| Field | Type | Required | Description |
5760
|-----------|------|----------|------------------------------------------------------------------------------|
58-
| `algorithm` | <center>`str`</center> | <center>Optional</center> | What algorithm this NodeBalancer should use for routing traffic to backends. **(Choices: `roundrobin`, `leastconn`, `source`; Updatable)** |
61+
| `algorithm` | <center>`str`</center> | <center>Optional</center> | What algorithm this NodeBalancer should use for routing traffic to backends. **(Choices: `roundrobin`, `leastconn`, `source`, `ring_hash`; Updatable)** |
5962
| `check` | <center>`str`</center> | <center>Optional</center> | The type of check to perform against backends to ensure they are serving requests. **(Choices: `none`, `connection`, `http`, `http_body`; Updatable)** |
6063
| `check_attempts` | <center>`int`</center> | <center>Optional</center> | How many times to attempt a check before considering a backend to be down. **(Updatable)** |
6164
| `check_body` | <center>`str`</center> | <center>Optional</center> | This value must be present in the response body of the check in order for it to pass. If this value is not present in the response body of a check request, the backend is considered to be down. **(Updatable)** |
6265
| `check_interval` | <center>`int`</center> | <center>Optional</center> | How often, in seconds, to check that backends are up and serving requests. **(Updatable)** |
6366
| `check_passive` | <center>`bool`</center> | <center>Optional</center> | If true, any response from this backend with a 5xx status code will be enough for it to be considered unhealthy and taken out of rotation. **(Updatable)** |
6467
| `check_path` | <center>`str`</center> | <center>Optional</center> | The URL path to check on each backend. If the backend does not respond to this request it is considered to be down. **(Updatable)** |
6568
| `check_timeout` | <center>`int`</center> | <center>Optional</center> | How long, in seconds, to wait for a check attempt before considering it failed. **(Updatable)** |
66-
| `cipher_suite` | <center>`str`</center> | <center>Optional</center> | What ciphers to use for SSL connections served by this NodeBalancer. **(Choices: `recommended`, `legacy`; Default: `recommended`; Updatable)** |
69+
| `udp_check_port` | <center>`int`</center> | <center>Optional</center> | Specifies the port on the backend node used for active health checks, which may differ from the port serving traffic. **(Updatable)** |
70+
| `cipher_suite` | <center>`str`</center> | <center>Optional</center> | What ciphers to use for SSL connections served by this NodeBalancer. **(Choices: `recommended`, `legacy`, `none`; Updatable)** |
6771
| `port` | <center>`int`</center> | <center>Optional</center> | The port this Config is for. **(Updatable)** |
68-
| `protocol` | <center>`str`</center> | <center>Optional</center> | The protocol this port is configured to serve. **(Choices: `http`, `https`, `tcp`; Updatable)** |
72+
| `protocol` | <center>`str`</center> | <center>Optional</center> | The protocol this port is configured to serve. **(Choices: `http`, `https`, `tcp`, `udp`; Updatable)** |
6973
| `proxy_protocol` | <center>`str`</center> | <center>Optional</center> | ProxyProtocol is a TCP extension that sends initial TCP connection information such as source/destination IPs and ports to backend devices. **(Choices: `none`, `v1`, `v2`; Updatable)** |
7074
| `recreate` | <center>`bool`</center> | <center>Optional</center> | If true, the config will be forcibly recreated on every run. This is useful for updates to redacted fields (`ssl_cert`, `ssl_key`) **(Default: `False`)** |
7175
| `ssl_cert` | <center>`str`</center> | <center>Optional</center> | The PEM-formatted public SSL certificate (or the combined PEM-formatted SSL certificate and Certificate Authority chain) that should be served on this NodeBalancerConfig’s port. **(Updatable)** |
7276
| `ssl_key` | <center>`str`</center> | <center>Optional</center> | The PEM-formatted private key for the SSL certificate set in the ssl_cert field. **(Updatable)** |
73-
| `stickiness` | <center>`str`</center> | <center>Optional</center> | Controls how session stickiness is handled on this port. **(Choices: `none`, `table`, `http_cookie`; Updatable)** |
77+
| `stickiness` | <center>`str`</center> | <center>Optional</center> | Controls how session stickiness is handled on this port. **(Choices: `none`, `table`, `http_cookie`, `session`, `source_ip`; Updatable)** |
7478
| [`nodes` (sub-options)](#nodes) | <center>`list`</center> | <center>Optional</center> | A list of nodes to apply to this config. These can alternatively be configured through the nodebalancer_node module. **(Updatable)** |
7579

7680
### nodes

plugins/module_utils/linode_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def handle_updates(
114114
obj: linode_api4.Base,
115115
params: dict,
116116
mutable_fields: set,
117-
register_func: Any,
117+
register_func: Callable,
118118
ignore_keys: Set[str] = None,
119119
) -> Set[str]:
120120
"""Handles updates for a linode_api4 object"""
@@ -181,7 +181,7 @@ def handle_updates(
181181
return result
182182

183183

184-
def parse_linode_types(value: any) -> any:
184+
def parse_linode_types(value: Any) -> Any:
185185
"""Helper function for handle_updates.
186186
Parses Linode Object types into collections of strings."""
187187

plugins/modules/nodebalancer.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"What algorithm this NodeBalancer should use "
7777
"for routing traffic to backends."
7878
],
79-
choices=["roundrobin", "leastconn", "source"],
79+
choices=["roundrobin", "leastconn", "source", "ring_hash"],
8080
),
8181
"check": SpecField(
8282
type=FieldType.string,
@@ -143,15 +143,23 @@
143143
"failed."
144144
],
145145
),
146+
"udp_check_port": SpecField(
147+
type=FieldType.integer,
148+
required=False,
149+
editable=True,
150+
description=[
151+
"Specifies the port on the backend node used for active health checks, which "
152+
"may differ from the port serving traffic."
153+
],
154+
),
146155
"cipher_suite": SpecField(
147156
type=FieldType.string,
148157
required=False,
149-
default="recommended",
150158
editable=True,
151159
description=[
152160
"What ciphers to use for SSL connections served by this NodeBalancer."
153161
],
154-
choices=["recommended", "legacy"],
162+
choices=["recommended", "legacy", "none"],
155163
),
156164
"port": SpecField(
157165
type=FieldType.integer,
@@ -164,7 +172,7 @@
164172
required=False,
165173
editable=True,
166174
description=["The protocol this port is configured to serve."],
167-
choices=["http", "https", "tcp"],
175+
choices=["http", "https", "tcp", "udp"],
168176
),
169177
"proxy_protocol": SpecField(
170178
type=FieldType.string,
@@ -211,7 +219,7 @@
211219
description=[
212220
"Controls how session stickiness is handled on this port."
213221
],
214-
choices=["none", "table", "http_cookie"],
222+
choices=["none", "table", "http_cookie", "session", "source_ip"],
215223
),
216224
"nodes": SpecField(
217225
type=FieldType.list,
@@ -240,6 +248,14 @@
240248
"Set to 0 (zero) to disable throttling.",
241249
],
242250
),
251+
"client_udp_sess_throttle": SpecField(
252+
type=FieldType.integer,
253+
editable=True,
254+
description=[
255+
"Throttle UDP sessions per second (0-20).",
256+
"Set to 0 (zero) to disable throttling.",
257+
],
258+
),
243259
"region": SpecField(
244260
type=FieldType.string,
245261
description=["The ID of the Region to create this NodeBalancer in."],
@@ -271,7 +287,10 @@
271287

272288

273289
SPECDOC_META = SpecDocMeta(
274-
description=["Manage a Linode NodeBalancer."],
290+
description=[
291+
"Manage a Linode NodeBalancer.",
292+
"NOTE: UDP NodeBalancer may not currently be available to all users.",
293+
],
275294
requirements=global_requirements,
276295
author=global_authors,
277296
options=linode_nodebalancer_spec,
@@ -305,7 +324,11 @@
305324
},
306325
)
307326

308-
MUTABLE_FIELDS: Set[str] = {"client_conn_throttle", "tags"}
327+
MUTABLE_FIELDS: Set[str] = {
328+
"client_conn_throttle",
329+
"tags",
330+
"client_udp_sess_throttle",
331+
}
309332

310333
DOCUMENTATION = r"""
311334
"""
@@ -372,7 +395,14 @@ def _create_nodebalancer(self) -> Optional[NodeBalancer]:
372395
params = {
373396
k: v
374397
for k, v in self.module.params.items()
375-
if k in {"client_conn_throttle", "label", "firewall_id", "tags"}
398+
if k
399+
in {
400+
"client_udp_sess_throttle",
401+
"client_conn_throttle",
402+
"label",
403+
"firewall_id",
404+
"tags",
405+
}
376406
}
377407

378408
try:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
linode-api4>=5.31.0
1+
linode-api4>=5.32.0
22
polling==0.3.2
33
ansible-specdoc>=0.0.19
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
- name: nodebalancer_udp
2+
block:
3+
- set_fact:
4+
r: "{{ 1000000000 | random }}"
5+
6+
- name: create nodebalancer
7+
linode.cloud.nodebalancer:
8+
label: 'ansible-test-{{ r }}'
9+
region: ap-northeast
10+
client_udp_sess_throttle: 3
11+
state: present
12+
firewall_id: '{{ firewall_id }}'
13+
register: create_nodebalancer
14+
15+
- name: Assert NodeBalancer is created
16+
assert:
17+
that:
18+
- create_nodebalancer.changed
19+
- create_nodebalancer.configs|length == 0
20+
- create_nodebalancer.node_balancer.client_udp_sess_throttle == 3
21+
22+
- name: Add NodeBalancer config
23+
linode.cloud.nodebalancer:
24+
label: '{{ create_nodebalancer.node_balancer.label }}'
25+
region: ap-northeast
26+
client_udp_sess_throttle: 3
27+
state: present
28+
configs:
29+
- port: 80
30+
protocol: udp
31+
algorithm: roundrobin
32+
udp_check_port: 12345
33+
register: create_config
34+
35+
- name: Assert nb config is added
36+
assert:
37+
that:
38+
- create_config.configs|length == 1
39+
- create_config.configs[0].port == 80
40+
- create_config.configs[0].udp_check_port == 12345
41+
42+
- name: Update NodeBalancer config
43+
linode.cloud.nodebalancer:
44+
label: '{{ create_nodebalancer.node_balancer.label }}'
45+
region: ap-northeast
46+
client_udp_sess_throttle: 3
47+
state: present
48+
configs:
49+
- port: 80
50+
protocol: udp
51+
algorithm: roundrobin
52+
udp_check_port: 1234
53+
register: update_config
54+
55+
- name: Assert nb config is updated
56+
assert:
57+
that:
58+
- update_config.configs|length == 1
59+
- update_config.configs[0].udp_check_port == 1234
60+
- update_config.changed
61+
62+
- name: Get nodebalancer_info
63+
linode.cloud.nodebalancer_info:
64+
label: '{{ create_nodebalancer.node_balancer.label }}'
65+
register: nb_info
66+
67+
- name: Assert nb info
68+
assert:
69+
that:
70+
- nb_info.node_balancer.id == create_nodebalancer.node_balancer.id
71+
- nb_info.configs[0].udp_check_port == 1234
72+
- nb_info.configs[0].udp_session_timeout == 16
73+
- nb_info.node_balancer.client_udp_sess_throttle == 3
74+
75+
always:
76+
- ignore_errors: yes
77+
block:
78+
- name: Delete the NodeBalancer
79+
linode.cloud.nodebalancer:
80+
label: '{{ create_nodebalancer.node_balancer.label }}'
81+
state: absent
82+
register: delete
83+
84+
- name: Assert NodeBalancer delete
85+
assert:
86+
that:
87+
- delete.changed
88+
- delete.node_balancer.id == create_nodebalancer.node_balancer.id
89+
90+
environment:
91+
LINODE_UA_PREFIX: '{{ ua_prefix }}'
92+
LINODE_API_TOKEN: '{{ api_token }}'
93+
LINODE_API_URL: '{{ api_url }}'
94+
LINODE_API_VERSION: '{{ api_version }}'
95+
LINODE_CA: '{{ ca_file or "" }}'

0 commit comments

Comments
 (0)