Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upcoming: [M3-9084] - Handle edge cases with UDP NodeBalancer #11515

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Changed
---

Allow `cipher_suite` to be `none` in `NodeBalancerConfig` and `CreateNodeBalancerConfig` ([#11515](https://github.com/linode/manager/pull/11515))
7 changes: 5 additions & 2 deletions packages/api-v4/src/nodebalancers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export interface NodeBalancerConfig {
stickiness: Stickiness;
algorithm: Algorithm;
ssl_fingerprint: string;
cipher_suite: 'recommended' | 'legacy';
/**
* Is `none` when protocol is UDP
*/
cipher_suite: 'recommended' | 'legacy' | 'none';
nodes: NodeBalancerConfigNode[];
}

Expand Down Expand Up @@ -160,7 +163,7 @@ export interface CreateNodeBalancerConfig {
* @default 80
*/
udp_check_port?: number;
cipher_suite?: 'recommended' | 'legacy';
cipher_suite?: 'recommended' | 'legacy' | 'none';
ssl_cert?: string;
ssl_key?: string;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Improve UDP NodeBalancer support ([#11515](https://github.com/linode/manager/pull/11515))
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ export const NodeBalancerConfigNode = React.memo(
{!hideModeSelect && (
<Grid lg={2} sm={3} xs={6}>
<Autocomplete
value={modeOptions.find(
(option) => option.value === node.mode
)}
value={
modeOptions.find((option) => option.value === node.mode) ??
modeOptions.find((option) => option.value === 'accept')
}
disableClearable
disabled={disabled}
errorText={nodesErrorMap.mode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { lensFrom } from '../NodeBalancerCreate';
import {
createNewNodeBalancerConfig,
createNewNodeBalancerConfigNode,
nodeForRequest,
getNodeForRequest,
parseAddress,
parseAddresses,
transformConfigsForRequest,
Expand Down Expand Up @@ -281,7 +281,7 @@ class NodeBalancerConfigurations extends React.Component<
const config = this.state.configs[configIdx];
const node = this.state.configs[configIdx].nodes[nodeIdx];

const nodeData = nodeForRequest(node);
const nodeData = getNodeForRequest(node, config);

if (!nodeBalancerId) {
return;
Expand Down Expand Up @@ -1031,7 +1031,7 @@ class NodeBalancerConfigurations extends React.Component<
const config = this.state.configs[configIdx];
const node = this.state.configs[configIdx].nodes[nodeIdx];

const nodeData = nodeForRequest(node);
const nodeData = getNodeForRequest(node, config);

if (!nodeBalancerId) {
return;
Expand Down
22 changes: 17 additions & 5 deletions packages/manager/src/features/NodeBalancers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ export const createNewNodeBalancerConfig = (
stickiness: SESSION_STICKINESS_DEFAULTS['http'],
});

export const nodeForRequest = (node: NodeBalancerConfigNodeFields) => ({
export const getNodeForRequest = (
node: NodeBalancerConfigNodeFields,
config: NodeBalancerConfigFields
) => ({
address: node.address,
label: node.label,
/* Force Node creation and updates to set mode to 'accept' */
mode: node.mode,
/**
* `mode` should not be specified for UDP because UDP does not
* support the various different modes.
*/
mode: config.protocol !== 'udp' ? node.mode : undefined,
port: node.port,
weight: +node.weight!,
});
Expand Down Expand Up @@ -108,10 +114,12 @@ export const transformConfigsForRequest = (
check_timeout: !isNil(config.check_timeout)
? +config.check_timeout
: undefined,
cipher_suite: config.cipher_suite || undefined,
cipher_suite: shouldIncludeCipherSuite(config)
? config.cipher_suite
: undefined,
id: undefined,
nodebalancer_id: undefined,
nodes: config.nodes.map(nodeForRequest),
nodes: config.nodes.map((node) => getNodeForRequest(node, config)),
nodes_status: undefined,
port: config.port ? +config.port : undefined,
protocol:
Expand Down Expand Up @@ -143,6 +151,10 @@ export const transformConfigsForRequest = (
});
};

const shouldIncludeCipherSuite = (config: NodeBalancerConfigFields) => {
return config.protocol !== 'udp';
};

export const shouldIncludeCheckPath = (config: NodeBalancerConfigFields) => {
return (
(config.check === 'http' || config.check === 'http_body') &&
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/validation": Changed
---

Allow `cipher_suite` to be `none` in NodeBalancer schemas ([#11515](https://github.com/linode/manager/pull/11515))
4 changes: 2 additions & 2 deletions packages/validation/src/nodebalancers.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const createNodeBalancerConfigSchema = object({
.typeError('Timeout must be a number.')
.integer(),
check: mixed().oneOf(['none', 'connection', 'http', 'http_body']),
cipher_suite: mixed().oneOf(['recommended', 'legacy']),
cipher_suite: string().oneOf(['recommended', 'legacy', 'none']),
port: number()
.integer()
.required('Port is required')
Expand Down Expand Up @@ -206,7 +206,7 @@ export const UpdateNodeBalancerConfigSchema = object({
.typeError('Timeout must be a number.')
.integer(),
check: mixed().oneOf(['none', 'connection', 'http', 'http_body']),
cipher_suite: mixed().oneOf(['recommended', 'legacy']),
cipher_suite: string().oneOf(['recommended', 'legacy', 'none']),
port: number()
.typeError('Port must be a number.')
.integer()
Expand Down
Loading