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

Feature/create alert form criteria #43

Closed
wants to merge 12 commits into from
Closed
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
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11321-added-1733240671518.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Added
---

Types for UDP NodeBalancer support ([#11321](https://github.com/linode/manager/pull/11321))
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11346-changed-1733145182722.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Changed
---

Type of `AlertDefinitionType` to `'system'|'user'` ([#11346](https://github.com/linode/manager/pull/11346))
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11347-fixed-1733327446988.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Fixed
---

Nullable AccountBeta ended & description properties ([#11347](https://github.com/linode/manager/pull/11347))
4 changes: 2 additions & 2 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ export interface AccountBeta {
label: string;
started: string;
id: string;
ended?: string;
description?: string;
ended: string | null;
description: string | null;
/**
* The datetime the account enrolled into the beta
* @example 2024-10-23T14:22:29
Expand Down
19 changes: 17 additions & 2 deletions packages/api-v4/src/cloudpulse/alerts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { createAlertDefinitionSchema } from '@linode/validation';
import Request, { setURL, setMethod, setData } from '../request';
import Request, {
setURL,
setMethod,
setData,
setParams,
setXFilter,
} from '../request';
import { Alert, AlertServiceType, CreateAlertDefinitionPayload } from './types';
import { BETA_API_ROOT as API_ROOT } from 'src/constants';
import { BETA_API_ROOT as API_ROOT } from '../constants';
import { Params, Filter, ResourcePage } from '../types';

export const createAlertDefinition = (
data: CreateAlertDefinitionPayload,
Expand All @@ -16,3 +23,11 @@ export const createAlertDefinition = (
setMethod('POST'),
setData(data, createAlertDefinitionSchema)
);

export const getAlertDefinitions = (params?: Params, filters?: Filter) =>
Request<ResourcePage<Alert>>(
setURL(`${API_ROOT}/monitor/alert-definitions`),
setMethod('GET'),
setParams(params),
setXFilter(filters)
);
28 changes: 24 additions & 4 deletions packages/api-v4/src/cloudpulse/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ export type MetricAggregationType = 'avg' | 'sum' | 'min' | 'max' | 'count';
export type MetricOperatorType = 'eq' | 'gt' | 'lt' | 'gte' | 'lte';
export type AlertServiceType = 'linode' | 'dbaas';
type DimensionFilterOperatorType = 'eq' | 'neq' | 'startswith' | 'endswith';
export type AlertDefinitionType = 'default' | 'custom';
export type AlertDefinitionType = 'system' | 'user';
export type AlertStatusType = 'enabled' | 'disabled';
export type CriteriaConditionType = 'ALL';
export type MetricUnitType =
| 'number'
| 'byte'
| 'second'
| 'percent'
| 'bit_per_second'
| 'millisecond'
| 'KB'
| 'MB'
| 'GB';
export interface Dashboard {
id: number;
label: string;
Expand Down Expand Up @@ -142,23 +153,30 @@ export interface ServiceTypesList {

export interface CreateAlertDefinitionPayload {
label: string;
tags?: string[];
description?: string;
entity_ids?: string[];
severity: AlertSeverityType;
rule_criteria: {
rules: MetricCriteria[];
};
trigger_condition: TriggerCondition;
trigger_conditions: TriggerCondition;
channel_ids: number[];
}
export interface MetricCriteria {
metric: string;
aggregation_type: MetricAggregationType;
operator: MetricOperatorType;
threshold: number;
dimension_filters: DimensionFilter[];
}

export interface AlertDefinitionMetricCriteria extends MetricCriteria {
unit: string;
label: string;
}
export interface DimensionFilter {
label: string;
dimension_label: string;
operator: DimensionFilterOperatorType;
value: string;
Expand All @@ -168,10 +186,12 @@ export interface TriggerCondition {
polling_interval_seconds: number;
evaluation_period_seconds: number;
trigger_occurrences: number;
criteria_condition: CriteriaConditionType;
}
export interface Alert {
id: number;
label: string;
tags: string[];
description: string;
has_more_resources: boolean;
status: AlertStatusType;
Expand All @@ -180,9 +200,9 @@ export interface Alert {
service_type: AlertServiceType;
entity_ids: string[];
rule_criteria: {
rules: MetricCriteria[];
rules: AlertDefinitionMetricCriteria[];
};
triggerCondition: TriggerCondition;
trigger_conditions: TriggerCondition;
channels: {
id: string;
label: string;
Expand Down
102 changes: 93 additions & 9 deletions packages/api-v4/src/nodebalancers/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
type TCPAlgorithm = 'roundrobin' | 'leastconn' | 'source';
type UDPAlgorithm = 'roundrobin' | 'leastconn' | 'ring_hash';

export type Algorithm = TCPAlgorithm | UDPAlgorithm;

export type Protocol = 'http' | 'https' | 'tcp' | 'udp';

type TCPStickiness = 'none' | 'table' | 'http_cookie';
type UDPStickiness = 'none' | 'session' | 'source_ip';

export type Stickiness = TCPStickiness | UDPStickiness;

export interface NodeBalancer {
id: number;
label: string;
hostname: string;
/**
* Maximum number of new TCP connections that a client (identified by a specific source IP)
* is allowed to initiate every second.
*/
client_conn_throttle: number;
/**
* Maximum number of new UDP sessions that a client (identified by a specific source IP)
* is allowed to initiate every second.
*
* @todo Remove optionality once UDP support is live
*/
client_udp_sess_throttle?: number;
region: string;
ipv4: string;
ipv6: null | string;
Expand Down Expand Up @@ -31,11 +54,15 @@ export interface BalancerTransfer {
total: number;
}

/**
* 'none' is reserved for nodes used in UDP configurations. They don't support different modes.
*/
export type NodeBalancerConfigNodeMode =
| 'accept'
| 'reject'
| 'backup'
| 'drain';
| 'drain'
| 'none';

export interface NodeBalancerConfig {
id: number;
Expand All @@ -44,22 +71,31 @@ export interface NodeBalancerConfig {
check_passive: boolean;
ssl_cert: string;
nodes_status: NodesStatus;
protocol: 'http' | 'https' | 'tcp';
protocol: Protocol;
ssl_commonname: string;
check_interval: number;
check_attempts: number;
check_timeout: number;
check_body: string;
check_path: string;
/**
* @todo Remove optionality once UDP support is live
*/
udp_check_port?: number;
/**
* @readonly This is returned by the API but *not* editable
* @todo Remove optionality once UDP support is live
* @default 16
*/
udp_session_timeout?: number;
proxy_protocol: NodeBalancerProxyProtocol;
check: 'none' | 'connection' | 'http' | 'http_body';
ssl_key: string;
stickiness: 'none' | 'table' | 'http_cookie';
algorithm: 'roundrobin' | 'leastconn' | 'source';
stickiness: Stickiness;
algorithm: Algorithm;
ssl_fingerprint: string;
cipher_suite: 'recommended' | 'legacy';
nodes: NodeBalancerConfigNode[];
modifyStatus?: 'new';
}

export type NodeBalancerProxyProtocol = 'none' | 'v1' | 'v2';
Expand All @@ -82,16 +118,48 @@ export interface NodeBalancerStats {

export interface CreateNodeBalancerConfig {
port?: number;
protocol?: 'http' | 'https' | 'tcp';
algorithm?: 'roundrobin' | 'leastconn' | 'source';
stickiness?: 'none' | 'table' | 'http_cookie';
/**
* If `udp` is chosen:
* - `check_passive` must be `false` or unset
* - `proxy_protocol` must be `none` or unset
* - The various SSL related fields like `ssl_cert`, `ssl_key`, `cipher_suite_recommended` should not be set
*/
protocol?: Protocol;
/**
* @default "none"
*/
proxy_protocol?: NodeBalancerProxyProtocol;
/**
* The algorithm for this configuration.
*
* TCP and HTTP support `roundrobin`, `leastconn`, and `source`
* UDP supports `roundrobin`, `leastconn`, and `ring_hash`
*
* @default roundrobin
*/
algorithm?: Algorithm;
/**
* Session stickiness for this configuration.
*
* TCP and HTTP support `none`, `table`, and `http_cookie`
* UDP supports `none`, `session`, and `source_ip`
*
* @default `session` for UDP
* @default `none` for TCP and HTTP
*/
stickiness?: Stickiness;
check?: 'none' | 'connection' | 'http' | 'http_body';
check_interval?: number;
check_timeout?: number;
check_attempts?: number;
check_path?: string;
check_body?: string;
check_passive?: boolean;
/**
* Must be between 1 and 65535
* @default 80
*/
udp_check_port?: number;
cipher_suite?: 'recommended' | 'legacy';
ssl_cert?: string;
ssl_key?: string;
Expand All @@ -102,6 +170,9 @@ export type UpdateNodeBalancerConfig = CreateNodeBalancerConfig;
export interface CreateNodeBalancerConfigNode {
address: string;
label: string;
/**
* Should not be specified when creating a node used on a UDP configuration
*/
mode?: NodeBalancerConfigNodeMode;
weight?: number;
}
Expand All @@ -126,8 +197,21 @@ export interface NodeBalancerConfigNodeWithPort extends NodeBalancerConfigNode {
export interface CreateNodeBalancerPayload {
region?: string;
label?: string;
/**
* The connections per second throttle for TCP and HTTP connections
*
* Must be between 0 and 20. Set to 0 to disable throttling.
* @default 0
*/
client_conn_throttle?: number;
configs: any;
/**
* The connections per second throttle for UDP sessions
*
* Must be between 0 and 20. Set to 0 to disable throttling.
* @default 0
*/
client_udp_sess_throttle?: number;
configs: CreateNodeBalancerConfig[];
firewall_id?: number;
tags?: string[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Migrate `/volumes` to Tanstack router ([#11154](https://github.com/linode/manager/pull/11154))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Clean up NodeBalancer related types ([#11321](https://github.com/linode/manager/pull/11321))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11346-added-1733145106911.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

AlertListing component and AlertTableRow component with Unit Tests ([#11346](https://github.com/linode/manager/pull/11346))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11347-tests-1733170030162.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Mock LKE creation flow + APL coverage ([#11347](https://github.com/linode/manager/pull/11347))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Add `CloudPulseAppliedFilter` and `CloudPulseAppliedFilterRenderer` components, update filter change handler function to add another parameter `label` ([#11354](https://github.com/linode/manager/pull/11354))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11379-fixed-1733476117431.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Disallow word-break in billing contact info ([#11379](https://github.com/linode/manager/pull/11379))
6 changes: 5 additions & 1 deletion packages/manager/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ module.exports = {
{
files: [
// for each new features added to the migration router, add its directory here
'src/features/Betas/*',
'src/features/Betas/**/*',
'src/features/Volumes/**/*',
],
rules: {
'no-restricted-imports': [
// This needs to remain an error however trying to link to a feature that is not yet migrated will break the router
// For those cases react-router-dom history.push is still needed
// using `eslint-disable-next-line no-restricted-imports` can help bypass those imports
'error',
{
paths: [
Expand Down
13 changes: 10 additions & 3 deletions packages/manager/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
Controls,
Stories,
} from '@storybook/blocks';
import { wrapWithTheme } from '../src/utilities/testHelpers';
import {
wrapWithTheme,
wrapWithThemeAndRouter,
} from '../src/utilities/testHelpers';
import { useDarkMode } from 'storybook-dark-mode';
import { DocsContainer as BaseContainer } from '@storybook/addon-docs';
import { themes } from '@storybook/theming';
Expand Down Expand Up @@ -42,9 +45,13 @@ export const DocsContainer = ({ children, context }) => {

const preview: Preview = {
decorators: [
(Story) => {
(Story, context) => {
const isDark = useDarkMode();
return wrapWithTheme(<Story />, { theme: isDark ? 'dark' : 'light' });
return context.parameters.tanStackRouter
? wrapWithThemeAndRouter(<Story />, {
theme: isDark ? 'dark' : 'light',
})
: wrapWithTheme(<Story />, { theme: isDark ? 'dark' : 'light' });
},
],
loaders: [
Expand Down
Loading
Loading