From 8a0fc2b37278e4a6e484a7f240526820068478b5 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Thu, 15 Feb 2024 20:56:18 -0500 Subject: [PATCH 01/10] Update Linode and PG types --- packages/api-v4/src/linodes/types.ts | 8 ++---- packages/api-v4/src/placement-groups/types.ts | 17 +++++++---- packages/manager/src/__data__/linodes.ts | 28 ++++++++++++++++--- packages/manager/src/factories/linodes.ts | 15 ++++------ .../manager/src/factories/placementGroups.ts | 1 + .../LinodesCreate/AddonsPanel.test.tsx | 21 ++++++++++++-- .../LinodeRow/LinodeRow.test.tsx | 2 +- .../Linodes/LinodesLanding/ListView.tsx | 2 +- 8 files changed, 64 insertions(+), 30 deletions(-) diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index f8c1abe5ee2..b6c0ea4dd06 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -1,7 +1,7 @@ import type { Region } from '../regions'; import type { IPAddress, IPRange } from '../networking/types'; import type { SSHKey } from '../profile/types'; -import type { PlacementGroup } from '../placement-groups/types'; +import type { LinodePlacementGroup } from '../placement-groups/types'; export type Hypervisor = 'kvm' | 'zen'; @@ -24,11 +24,7 @@ export interface Linode { ipv4: string[]; ipv6: string | null; label: string; - // While the API returns an array of PlacementGroup objects for future proofing, - // we only support one PlacementGroup per Linode at this time, hence the tuple. - placement_groups: - | [Pick] - | []; + placement_group: LinodePlacementGroup; type: string | null; status: LinodeStatus; updated: string; diff --git a/packages/api-v4/src/placement-groups/types.ts b/packages/api-v4/src/placement-groups/types.ts index 63f64584004..2188cfae30b 100644 --- a/packages/api-v4/src/placement-groups/types.ts +++ b/packages/api-v4/src/placement-groups/types.ts @@ -14,14 +14,21 @@ export interface PlacementGroup { affinity_type: AffinityType; is_compliant: boolean; linode_ids: number[]; + strict: boolean; } -// The `strict` parameter specifies whether placement groups should be ignored when looking for a host. -// TODO VM_Placement: figure out the values for each create flow (create, clone, migrate etc) -export type CreatePlacementGroupPayload = Pick< +type PlacementGroupPayload = Pick< PlacementGroup, - 'label' | 'affinity_type' | 'region' -> & { strict: boolean }; + 'label' | 'affinity_type' | 'strict' +>; + +export type LinodePlacementGroup = PlacementGroupPayload & { + id: number; +}; + +export type CreatePlacementGroupPayload = PlacementGroupPayload & { + region: Region['id']; +}; export type RenamePlacementGroupPayload = Pick; diff --git a/packages/manager/src/__data__/linodes.ts b/packages/manager/src/__data__/linodes.ts index e0c5d2a608a..dbf3eca7223 100644 --- a/packages/manager/src/__data__/linodes.ts +++ b/packages/manager/src/__data__/linodes.ts @@ -24,7 +24,12 @@ export const linode1: Linode = { ipv4: ['97.107.143.78', '98.107.143.78', '99.107.143.78'], ipv6: '2600:3c03::f03c:91ff:fe0a:109a/64', label: 'test', - placement_groups: [], + placement_group: { + affinity_type: 'anti_affinity', + id: 1, + label: 'pg-1', + strict: true, + }, region: 'us-east', specs: { disk: 20480, @@ -64,7 +69,12 @@ export const linode2: Linode = { ipv4: ['97.107.143.49'], ipv6: '2600:3c03::f03c:91ff:fe0a:0d7a/64', label: 'another-test', - placement_groups: [], + placement_group: { + affinity_type: 'anti_affinity', + id: 1, + label: 'pg-1', + strict: true, + }, region: 'us-east', specs: { disk: 30720, @@ -104,7 +114,12 @@ export const linode3: Linode = { ipv4: ['97.107.143.49'], ipv6: '2600:3c03::f03c:91ff:fe0a:0d7a/64', label: 'another-test', - placement_groups: [], + placement_group: { + affinity_type: 'anti_affinity', + id: 1, + label: 'pg-1', + strict: true, + }, region: 'us-east', specs: { disk: 30720, @@ -144,7 +159,12 @@ export const linode4: Linode = { ipv4: ['97.107.143.49'], ipv6: '2600:3c03::f03c:91ff:fe0a:0d7a/64', label: 'another-test-eu', - placement_groups: [], + placement_group: { + affinity_type: 'anti_affinity', + id: 1, + label: 'pg-1', + strict: true, + }, region: 'eu-west', specs: { disk: 30720, diff --git a/packages/manager/src/factories/linodes.ts b/packages/manager/src/factories/linodes.ts index 64807d6cd23..62d5b55bb64 100644 --- a/packages/manager/src/factories/linodes.ts +++ b/packages/manager/src/factories/linodes.ts @@ -262,16 +262,11 @@ export const linodeFactory = Factory.Sync.makeFactory({ ipv4: ['50.116.6.212', '192.168.203.1'], ipv6: '2600:3c00::f03c:92ff:fee2:6c40/64', label: Factory.each((i) => `linode-${i}`), - placement_groups: [ - placementGroupFactory.build({ - affinity_type: 'anti_affinity', - id: 1, - is_compliant: true, - label: 'test', - linode_ids: [1], - region: 'us-east', - }), - ], + placement_group: placementGroupFactory.build({ + affinity_type: 'anti_affinity', + id: 1, + label: 'pg-1', + }), region: 'us-east', specs: linodeSpecsFactory.build(), status: 'running', diff --git a/packages/manager/src/factories/placementGroups.ts b/packages/manager/src/factories/placementGroups.ts index fb0d0a2a73c..f83e2cbc891 100644 --- a/packages/manager/src/factories/placementGroups.ts +++ b/packages/manager/src/factories/placementGroups.ts @@ -14,6 +14,7 @@ export const placementGroupFactory = Factory.Sync.makeFactory({ label: Factory.each((id) => `pg-${id}`), linode_ids: [0, 1, 2, 3, 5, 6, 7, 8, 43], region: 'us-east', + strict: true, }); export const createPlacementGroupPayloadFactory = Factory.Sync.makeFactory( diff --git a/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx b/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx index 54712f0649d..dca3f5e21c1 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx @@ -62,7 +62,12 @@ const props: AddonsPanelProps = { ipv4: ['45.56.75.98'], ipv6: '2600:3c00::f03c:93ff:fe85:576d/128', label: 'test_instance', - placement_groups: [], + placement_group: { + affinity_type: 'anti_affinity', + id: 1, + label: 'test', + strict: true, + }, region: 'us-central', specs: { disk: 51200, @@ -102,7 +107,12 @@ const props: AddonsPanelProps = { ipv4: ['192.168.139.183', '139.144.17.202'], ipv6: '2600:3c04::f03c:93ff:fe75:0612/128', label: 'debian-ca-central', - placement_groups: [], + placement_group: { + affinity_type: 'anti_affinity', + id: 1, + label: 'test', + strict: true, + }, region: 'ca-central', specs: { disk: 25600, @@ -141,7 +151,12 @@ const props: AddonsPanelProps = { ipv4: ['45.79.74.95'], ipv6: '2600:3c01::f03c:93ff:fe75:e4f9/128', label: 'almalinux-us-west', - placement_groups: [], + placement_group: { + affinity_type: 'anti_affinity', + id: 1, + label: 'test', + strict: true, + }, region: 'us-west', specs: { disk: 25600, diff --git a/packages/manager/src/features/Linodes/LinodesLanding/LinodeRow/LinodeRow.test.tsx b/packages/manager/src/features/Linodes/LinodesLanding/LinodeRow/LinodeRow.test.tsx index 234c8c01ab6..083885f2282 100644 --- a/packages/manager/src/features/Linodes/LinodesLanding/LinodeRow/LinodeRow.test.tsx +++ b/packages/manager/src/features/Linodes/LinodesLanding/LinodeRow/LinodeRow.test.tsx @@ -42,7 +42,7 @@ describe('LinodeRow', () => { ipv6={linode.ipv6 || ''} key={`linode-row-${1}`} label={linode.label} - placement_groups={linode.placement_groups} + placement_group={linode.placement_group} region={linode.region} specs={linode.specs} status={linode.status} diff --git a/packages/manager/src/features/Linodes/LinodesLanding/ListView.tsx b/packages/manager/src/features/Linodes/LinodesLanding/ListView.tsx index 50bde0d77d4..ac316735313 100644 --- a/packages/manager/src/features/Linodes/LinodesLanding/ListView.tsx +++ b/packages/manager/src/features/Linodes/LinodesLanding/ListView.tsx @@ -46,7 +46,7 @@ export const ListView = (props: RenderLinodesProps) => { ipv6={linode.ipv6 || ''} key={`linode-row-${idx}`} label={linode.label} - placement_groups={linode.placement_groups} + placement_group={linode.placement_group} region={linode.region} specs={linode.specs} status={linode.status} From 89c02d83b07e4a3219ff4679727725cdcca925a7 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Mon, 26 Feb 2024 12:57:34 -0500 Subject: [PATCH 02/10] Update get types --- packages/api-v4/src/linodes/types.ts | 4 +- packages/api-v4/src/placement-groups/types.ts | 20 ++--- packages/manager/src/__data__/linodes.ts | 8 +- .../manager/src/factories/placementGroups.ts | 43 +++++++++- .../LinodesCreate/AddonsPanel.test.tsx | 6 +- .../Linodes/LinodesCreate/LinodeCreate.tsx | 3 +- ...lacementGroupsAssignLinodesDrawer.test.tsx | 43 +++++++++- .../PlacementGroupsAssignLinodesDrawer.tsx | 1 - .../PlacementGroupsCreateDrawer.tsx | 4 +- .../PlacementGroupsDeleteModal.test.tsx | 9 ++- .../PlacementGroupsLinodes.test.tsx | 7 +- .../PlacementGroupsSummary.test.tsx | 24 +++++- .../PlacementGroupsRow.test.tsx | 7 +- .../PlacementGroupsRenameDrawer.tsx | 2 +- .../src/features/PlacementGroups/types.ts | 4 +- .../features/PlacementGroups/utils.test.ts | 40 ++++++++-- .../src/features/PlacementGroups/utils.ts | 4 +- .../src/hooks/usePlacementGroupsData.ts | 6 +- packages/manager/src/mocks/serverHandlers.ts | 80 ++++++++++++++++++- .../manager/src/queries/placementGroups.ts | 4 +- packages/validation/src/linodes.schema.ts | 1 - 21 files changed, 269 insertions(+), 51 deletions(-) diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index b6c0ea4dd06..cdf8d734187 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -24,7 +24,7 @@ export interface Linode { ipv4: string[]; ipv6: string | null; label: string; - placement_group: LinodePlacementGroup; + placement_group?: LinodePlacementGroup; // If not in a placement group, this will be undefined type: string | null; status: LinodeStatus; updated: string; @@ -340,7 +340,7 @@ export interface UserData { } export interface CreateLinodePlacementGroupPayload { - id?: number | null; + id: number; compliant_only?: boolean | null; } diff --git a/packages/api-v4/src/placement-groups/types.ts b/packages/api-v4/src/placement-groups/types.ts index 2188cfae30b..8507374487a 100644 --- a/packages/api-v4/src/placement-groups/types.ts +++ b/packages/api-v4/src/placement-groups/types.ts @@ -13,32 +13,34 @@ export interface PlacementGroup { region: Region['id']; affinity_type: AffinityType; is_compliant: boolean; - linode_ids: number[]; - strict: boolean; + linodes: { + linode: number; + is_compliant: boolean; + }[]; + is_strict: boolean; } type PlacementGroupPayload = Pick< PlacementGroup, - 'label' | 'affinity_type' | 'strict' + 'id' | 'label' | 'affinity_type' | 'is_strict' >; -export type LinodePlacementGroup = PlacementGroupPayload & { - id: number; -}; +export type LinodePlacementGroup = PlacementGroupPayload; -export type CreatePlacementGroupPayload = PlacementGroupPayload & { +export type CreatePlacementGroupPayload = Omit & { region: Region['id']; }; -export type RenamePlacementGroupPayload = Pick; +export type UpdatePlacementGroupPayload = Pick; /** * Since the API expects an array of ONE linode id, we'll use a tuple here. */ export type AssignLinodesToPlacementGroupPayload = { linodes: [number]; - strict: boolean; + compliant_only?: boolean; }; + export type UnassignLinodesFromPlacementGroupPayload = { linodes: [number]; }; diff --git a/packages/manager/src/__data__/linodes.ts b/packages/manager/src/__data__/linodes.ts index dbf3eca7223..cf97f0af27d 100644 --- a/packages/manager/src/__data__/linodes.ts +++ b/packages/manager/src/__data__/linodes.ts @@ -27,8 +27,8 @@ export const linode1: Linode = { placement_group: { affinity_type: 'anti_affinity', id: 1, + is_strict: true, label: 'pg-1', - strict: true, }, region: 'us-east', specs: { @@ -72,8 +72,8 @@ export const linode2: Linode = { placement_group: { affinity_type: 'anti_affinity', id: 1, + is_strict: true, label: 'pg-1', - strict: true, }, region: 'us-east', specs: { @@ -117,8 +117,8 @@ export const linode3: Linode = { placement_group: { affinity_type: 'anti_affinity', id: 1, + is_strict: true, label: 'pg-1', - strict: true, }, region: 'us-east', specs: { @@ -162,8 +162,8 @@ export const linode4: Linode = { placement_group: { affinity_type: 'anti_affinity', id: 1, + is_strict: true, label: 'pg-1', - strict: true, }, region: 'eu-west', specs: { diff --git a/packages/manager/src/factories/placementGroups.ts b/packages/manager/src/factories/placementGroups.ts index f83e2cbc891..1660924eb06 100644 --- a/packages/manager/src/factories/placementGroups.ts +++ b/packages/manager/src/factories/placementGroups.ts @@ -11,17 +11,54 @@ export const placementGroupFactory = Factory.Sync.makeFactory({ affinity_type: 'anti_affinity', id: Factory.each((id) => id), is_compliant: Factory.each(() => pickRandom([true, false])), + is_strict: true, label: Factory.each((id) => `pg-${id}`), - linode_ids: [0, 1, 2, 3, 5, 6, 7, 8, 43], + linodes: [ + { + is_compliant: true, + linode: 0, + }, + { + is_compliant: true, + linode: 1, + }, + { + is_compliant: true, + linode: 2, + }, + { + is_compliant: true, + linode: 3, + }, + { + is_compliant: true, + linode: 5, + }, + { + is_compliant: true, + linode: 6, + }, + { + is_compliant: true, + linode: 7, + }, + { + is_compliant: true, + linode: 8, + }, + { + is_compliant: false, + linode: 43, + }, + ], region: 'us-east', - strict: true, }); export const createPlacementGroupPayloadFactory = Factory.Sync.makeFactory( { affinity_type: 'anti_affinity', + is_strict: true, label: Factory.each((id) => `mock-pg-${id}`), region: pickRandom(['us-east', 'us-southeast', 'ca-central']), - strict: true, } ); diff --git a/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx b/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx index dca3f5e21c1..1f918e443db 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/AddonsPanel.test.tsx @@ -65,8 +65,8 @@ const props: AddonsPanelProps = { placement_group: { affinity_type: 'anti_affinity', id: 1, + is_strict: true, label: 'test', - strict: true, }, region: 'us-central', specs: { @@ -110,8 +110,8 @@ const props: AddonsPanelProps = { placement_group: { affinity_type: 'anti_affinity', id: 1, + is_strict: true, label: 'test', - strict: true, }, region: 'ca-central', specs: { @@ -154,8 +154,8 @@ const props: AddonsPanelProps = { placement_group: { affinity_type: 'anti_affinity', id: 1, + is_strict: true, label: 'test', - strict: true, }, region: 'us-west', specs: { diff --git a/packages/manager/src/features/Linodes/LinodesCreate/LinodeCreate.tsx b/packages/manager/src/features/Linodes/LinodesCreate/LinodeCreate.tsx index a98f321cadb..5b4026bfa4b 100644 --- a/packages/manager/src/features/Linodes/LinodesCreate/LinodeCreate.tsx +++ b/packages/manager/src/features/Linodes/LinodesCreate/LinodeCreate.tsx @@ -838,8 +838,7 @@ export class LinodeCreate extends React.PureComponent< ); const placement_group_payload: CreateLinodePlacementGroupPayload = { - compliant_only: true, - id: this.props.placementGroupSelection?.id, + id: this.props.placementGroupSelection?.id ?? -1, }; // eslint-disable-next-line sonarjs/no-unused-collection diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx index 657f3468b8e..709226ca320 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx @@ -87,7 +87,48 @@ describe('PlacementGroupsAssignLinodesDrawer', () => { }); queryMocks.useAssignLinodesToPlacementGroup.mockReturnValue( placementGroupFactory.build({ - linode_ids: [1, 2, 0, 1, 2, 3, 5, 6, 7, 8, 43, 11], + linodes: [ + { + is_compliant: true, + linode: 0, + }, + { + is_compliant: true, + linode: 1, + }, + { + is_compliant: true, + linode: 2, + }, + { + is_compliant: true, + linode: 3, + }, + { + is_compliant: true, + linode: 5, + }, + { + is_compliant: true, + linode: 6, + }, + { + is_compliant: true, + linode: 7, + }, + { + is_compliant: true, + linode: 8, + }, + { + is_compliant: true, + linode: 43, + }, + { + is_compliant: true, + linode: 11, + }, + ], }) ); diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx index 9022f02a4ba..d3c4e0da5f6 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.tsx @@ -142,7 +142,6 @@ export const PlacementGroupsAssignLinodesDrawer = ( const payload: AssignLinodesToPlacementGroupPayload = { linodes: [selectedLinode.id], - strict: true, }; try { diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx index b64f3a9cc69..6b2e80cbe58 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx @@ -15,8 +15,8 @@ import { handleGeneralErrors, } from 'src/utilities/formikErrorUtils'; -import { PlacementGroupsDrawerContent } from './PlacementGroupsDrawerContent'; import { MAX_NUMBER_OF_PLACEMENT_GROUPS } from './constants'; +import { PlacementGroupsDrawerContent } from './PlacementGroupsDrawerContent'; import type { PlacementGroupDrawerFormikProps, @@ -57,9 +57,9 @@ export const PlacementGroupsCreateDrawer = ( enableReinitialize: true, initialValues: { affinity_type: '' as PlacementGroupDrawerFormikProps['affinity_type'], + is_strict: true, label: '', region: selectedRegionId ?? '', - strict: true, }, onSubmit( values: PlacementGroupDrawerFormikProps, diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsDeleteModal.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsDeleteModal.test.tsx index e1362e4fa66..66fff87a554 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsDeleteModal.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsDeleteModal.test.tsx @@ -90,7 +90,12 @@ describe('PlacementGroupsDeleteModal', () => { affinity_type: 'anti_affinity', id: 1, label: 'PG-to-delete', - linode_ids: [1], + linodes: [ + { + is_compliant: true, + linode: 1, + }, + ], region: 'us-east', }), }); @@ -127,7 +132,7 @@ describe('PlacementGroupsDeleteModal', () => { affinity_type: 'anti_affinity', id: 1, label: 'PG-to-delete', - linode_ids: [], + linodes: [], }), }); diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsLinodes/PlacementGroupsLinodes.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsLinodes/PlacementGroupsLinodes.test.tsx index dd6d063c000..448ad4efb8d 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsLinodes/PlacementGroupsLinodes.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsLinodes/PlacementGroupsLinodes.test.tsx @@ -19,7 +19,12 @@ describe('PlacementGroupsLinodes', () => { it('features the linodes table, a filter field, a create button and a docs link', () => { const placementGroup = placementGroupFactory.build({ - linode_ids: [1], + linodes: [ + { + is_compliant: true, + linode: 1, + }, + ], }); const { getByPlaceholderText, getByRole } = renderWithTheme( diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsSummary/PlacementGroupsSummary.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsSummary/PlacementGroupsSummary.test.tsx index 03d6a4e6f8e..aec5ec9c314 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsSummary/PlacementGroupsSummary.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsDetail/PlacementGroupsSummary/PlacementGroupsSummary.test.tsx @@ -14,7 +14,29 @@ describe('PlacementGroups Summary', () => { id: 3, is_compliant: true, label: 'pg-3', - linode_ids: [2, 4, 6, 8, 10], + linodes: [ + { + is_compliant: true, + linode: 2, + }, + { + is_compliant: true, + linode: 4, + }, + { + is_compliant: true, + linode: 6, + }, + { + is_compliant: true, + linode: 8, + }, + { + is_compliant: true, + linode: 10, + }, + ], + region: 'us-east', })} /> diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsLanding/PlacementGroupsRow.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsLanding/PlacementGroupsRow.test.tsx index ba83d5c302d..cd0e56cd9e8 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsLanding/PlacementGroupsRow.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsLanding/PlacementGroupsRow.test.tsx @@ -72,7 +72,12 @@ describe('PlacementGroupsLanding', () => { affinity_type: 'anti_affinity', is_compliant: false, label: 'group 1', - linode_ids: [1], + linodes: [ + { + is_compliant: true, + linode: 1, + }, + ], region: 'us-east', })} handleDeletePlacementGroup={handleDeletePlacementGroupMock} diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsRenameDrawer.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsRenameDrawer.tsx index 72dd8d96668..1eb03f28b6a 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsRenameDrawer.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsRenameDrawer.tsx @@ -57,9 +57,9 @@ export const PlacementGroupsRenameDrawer = ( enableReinitialize: true, initialValues: { affinity_type: selectedPlacementGroup?.affinity_type as PlacementGroupDrawerFormikProps['affinity_type'], + is_strict: true, label: selectedPlacementGroup?.label ?? '', region: selectedPlacementGroup?.region ?? '', - strict: true, }, onSubmit(values, { setErrors, setStatus, setSubmitting }) { setHasFormBeenSubmitted(false); diff --git a/packages/manager/src/features/PlacementGroups/types.ts b/packages/manager/src/features/PlacementGroups/types.ts index c23c6be27ab..238dc86c105 100644 --- a/packages/manager/src/features/PlacementGroups/types.ts +++ b/packages/manager/src/features/PlacementGroups/types.ts @@ -1,7 +1,7 @@ import { CreatePlacementGroupPayload, PlacementGroup, - RenamePlacementGroupPayload, + UpdatePlacementGroupPayload, } from '@linode/api-v4'; export type PlacementGroupsDrawerPropsBase = { @@ -20,7 +20,7 @@ export type PlacementGroupsRenameDrawerProps = PlacementGroupsDrawerPropsBase & selectedPlacementGroup: PlacementGroup | undefined; }; -export type PlacementGroupDrawerFormikProps = RenamePlacementGroupPayload & +export type PlacementGroupDrawerFormikProps = UpdatePlacementGroupPayload & CreatePlacementGroupPayload; export type PlacementGroupsAssignLinodesDrawerProps = PlacementGroupsDrawerPropsBase & { diff --git a/packages/manager/src/features/PlacementGroups/utils.test.ts b/packages/manager/src/features/PlacementGroups/utils.test.ts index 0600821731b..2c3bac0e4b5 100644 --- a/packages/manager/src/features/PlacementGroups/utils.test.ts +++ b/packages/manager/src/features/PlacementGroups/utils.test.ts @@ -9,11 +9,26 @@ import { import type { PlacementGroup } from '@linode/api-v4'; +const initialLinodeData = [ + { + is_compliant: true, + linode: 1, + }, + { + is_compliant: true, + linode: 2, + }, + { + is_compliant: true, + linode: 3, + }, +]; + describe('getPlacementGroupLinodeCount', () => { it('returns the length of the linode_ids array', () => { expect( getPlacementGroupLinodeCount({ - linode_ids: [1, 2, 3], + linodes: initialLinodeData, } as PlacementGroup) ).toBe(3); }); @@ -37,7 +52,7 @@ describe('hasPlacementGroupReachedCapacity', () => { expect( hasPlacementGroupReachedCapacity({ placementGroup: placementGroupFactory.build({ - linode_ids: [1, 2, 3], + linodes: initialLinodeData, }), region: regionFactory.build({ maximum_vms_per_pg: 3, @@ -50,7 +65,7 @@ describe('hasPlacementGroupReachedCapacity', () => { expect( hasPlacementGroupReachedCapacity({ placementGroup: placementGroupFactory.build({ - linode_ids: [1, 2, 3], + linodes: initialLinodeData, }), region: regionFactory.build({ maximum_vms_per_pg: 4, @@ -64,8 +79,23 @@ describe('getLinodesFromAllPlacementGroups', () => { it('returns an array of unique linode ids from all placement groups', () => { expect( getLinodesFromAllPlacementGroups([ - { linode_ids: [1, 2, 3] }, - { linode_ids: [3, 4, 5] }, + { linodes: initialLinodeData }, + { + linodes: [ + { + is_compliant: true, + linode: 3, + }, + { + is_compliant: true, + linode: 4, + }, + { + is_compliant: true, + linode: 5, + }, + ], + }, ] as PlacementGroup[]) ).toEqual([1, 2, 3, 4, 5]); }); diff --git a/packages/manager/src/features/PlacementGroups/utils.ts b/packages/manager/src/features/PlacementGroups/utils.ts index b28d7a87938..b6f98a279cf 100644 --- a/packages/manager/src/features/PlacementGroups/utils.ts +++ b/packages/manager/src/features/PlacementGroups/utils.ts @@ -12,7 +12,7 @@ import type { export const getPlacementGroupLinodeCount = ( placementGroup: PlacementGroup ): number => { - return placementGroup.linode_ids.length; + return placementGroup.linodes.length; }; interface HasPlacementGroupReachedCapacityOptions { @@ -57,7 +57,7 @@ export const getLinodesFromAllPlacementGroups = ( } const linodeIds = allPlacementGroups.reduce((acc, placementGroup) => { - return [...acc, ...placementGroup.linode_ids]; + return [...acc, ...placementGroup.linodes.map((linode) => linode.linode)]; }, []); return Array.from(new Set(linodeIds)); diff --git a/packages/manager/src/hooks/usePlacementGroupsData.ts b/packages/manager/src/hooks/usePlacementGroupsData.ts index a7b43ea370f..af53deea081 100644 --- a/packages/manager/src/hooks/usePlacementGroupsData.ts +++ b/packages/manager/src/hooks/usePlacementGroupsData.ts @@ -31,8 +31,8 @@ export const usePlacementGroupData = ({ const { data: linodes, error, isLoading } = useAllLinodesQuery( {}, { - '+or': placementGroup?.linode_ids.map((id) => ({ - id, + '+or': placementGroup?.linodes.map((linode) => ({ + linode, })), } ); @@ -55,7 +55,7 @@ export const usePlacementGroupData = ({ const linodesCount = getPlacementGroupLinodeCount(placementGroup); const assignedLinodes = linodes?.filter((linode) => - placementGroup.linode_ids.includes(linode.id) + placementGroup.linodes.some((pgLinode) => pgLinode.linode === linode.id) ); const hasReachedCapacity = hasPlacementGroupReachedCapacity({ placementGroup, diff --git a/packages/manager/src/mocks/serverHandlers.ts b/packages/manager/src/mocks/serverHandlers.ts index ce213679d83..238701e4762 100644 --- a/packages/manager/src/mocks/serverHandlers.ts +++ b/packages/manager/src/mocks/serverHandlers.ts @@ -2111,8 +2111,45 @@ export const handlers = [ affinity_type: 'anti_affinity', id: Number(req.params.placementGroupId) ?? -1, label: 'pg-1', - linode_ids: [ - ...[0, 1, 2, 3, 5, 6, 7, 8, 43], + linodes: [ + ...[ + { + is_compliant: true, + linode: 0, + }, + { + is_compliant: true, + linode: 1, + }, + { + is_compliant: true, + linode: 2, + }, + { + is_compliant: true, + linode: 3, + }, + { + is_compliant: true, + linode: 5, + }, + { + is_compliant: true, + linode: 6, + }, + { + is_compliant: true, + linode: 7, + }, + { + is_compliant: true, + linode: 8, + }, + { + is_compliant: false, + linode: 43, + }, + ], (req.body as any).linodes[0], ], }); @@ -2130,7 +2167,44 @@ export const handlers = [ affinity_type: 'anti_affinity', id: Number(req.params.placementGroupId) ?? -1, label: 'pg-1', - linode_ids: [0, 1, 2, 3, 5, 6, 7, 8, 43], + linodes: [ + { + is_compliant: true, + linode: 0, + }, + { + is_compliant: true, + linode: 1, + }, + { + is_compliant: true, + linode: 2, + }, + { + is_compliant: true, + linode: 3, + }, + { + is_compliant: true, + linode: 5, + }, + { + is_compliant: true, + linode: 6, + }, + { + is_compliant: true, + linode: 7, + }, + { + is_compliant: true, + linode: 8, + }, + { + is_compliant: false, + linode: 43, + }, + ], }); return res(ctx.json(response)); diff --git a/packages/manager/src/queries/placementGroups.ts b/packages/manager/src/queries/placementGroups.ts index a1952724458..79e7dd39e2d 100644 --- a/packages/manager/src/queries/placementGroups.ts +++ b/packages/manager/src/queries/placementGroups.ts @@ -23,8 +23,8 @@ import type { AssignLinodesToPlacementGroupPayload, CreatePlacementGroupPayload, PlacementGroup, - RenamePlacementGroupPayload, UnassignLinodesFromPlacementGroupPayload, + UpdatePlacementGroupPayload, } from '@linode/api-v4'; export const queryKey = 'placement-groups'; @@ -84,7 +84,7 @@ export const useCreatePlacementGroup = () => { export const useMutatePlacementGroup = (id: number) => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: (data) => renamePlacementGroup(id, data), onSuccess: (placementGroup) => { queryClient.invalidateQueries([queryKey, 'paginated']); diff --git a/packages/validation/src/linodes.schema.ts b/packages/validation/src/linodes.schema.ts index 89666f99af4..41497079e09 100644 --- a/packages/validation/src/linodes.schema.ts +++ b/packages/validation/src/linodes.schema.ts @@ -262,7 +262,6 @@ const MetadataSchema = object({ const PlacementGroupPayloadSchema = object({ id: number().notRequired().nullable(true), - compliant_only: boolean().notRequired().nullable(true), }); export const CreateLinodeSchema = object({ From f0dc38a83815bc0eaa980753fbb824ddd3f7a9b7 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Mon, 26 Feb 2024 16:12:36 -0500 Subject: [PATCH 03/10] Update types, factories and mocks --- .../manager/src/factories/placementGroups.ts | 8 +- ...lacementGroupsAssignLinodesDrawer.test.tsx | 8 +- .../src/hooks/usePlacementGroupsData.ts | 2 +- packages/manager/src/mocks/serverHandlers.ts | 100 ++++++++---------- 4 files changed, 56 insertions(+), 62 deletions(-) diff --git a/packages/manager/src/factories/placementGroups.ts b/packages/manager/src/factories/placementGroups.ts index 1660924eb06..820c189c9c6 100644 --- a/packages/manager/src/factories/placementGroups.ts +++ b/packages/manager/src/factories/placementGroups.ts @@ -14,10 +14,6 @@ export const placementGroupFactory = Factory.Sync.makeFactory({ is_strict: true, label: Factory.each((id) => `pg-${id}`), linodes: [ - { - is_compliant: true, - linode: 0, - }, { is_compliant: true, linode: 1, @@ -46,6 +42,10 @@ export const placementGroupFactory = Factory.Sync.makeFactory({ is_compliant: true, linode: 8, }, + { + is_compliant: true, + linode: 9, + }, { is_compliant: false, linode: 43, diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx index 709226ca320..7a387dfaef2 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsAssignLinodesDrawer.test.tsx @@ -88,10 +88,6 @@ describe('PlacementGroupsAssignLinodesDrawer', () => { queryMocks.useAssignLinodesToPlacementGroup.mockReturnValue( placementGroupFactory.build({ linodes: [ - { - is_compliant: true, - linode: 0, - }, { is_compliant: true, linode: 1, @@ -120,6 +116,10 @@ describe('PlacementGroupsAssignLinodesDrawer', () => { is_compliant: true, linode: 8, }, + { + is_compliant: true, + linode: 9, + }, { is_compliant: true, linode: 43, diff --git a/packages/manager/src/hooks/usePlacementGroupsData.ts b/packages/manager/src/hooks/usePlacementGroupsData.ts index af53deea081..00ee3c3d996 100644 --- a/packages/manager/src/hooks/usePlacementGroupsData.ts +++ b/packages/manager/src/hooks/usePlacementGroupsData.ts @@ -31,7 +31,7 @@ export const usePlacementGroupData = ({ const { data: linodes, error, isLoading } = useAllLinodesQuery( {}, { - '+or': placementGroup?.linodes.map((linode) => ({ + '+or': placementGroup?.linodes.map(({ linode }) => ({ linode, })), } diff --git a/packages/manager/src/mocks/serverHandlers.ts b/packages/manager/src/mocks/serverHandlers.ts index 238701e4762..9754533710c 100644 --- a/packages/manager/src/mocks/serverHandlers.ts +++ b/packages/manager/src/mocks/serverHandlers.ts @@ -745,7 +745,7 @@ export const handlers = [ if (orFilters) { const filteredLinodes = linodes.filter((linode) => { const filteredById = orFilters.some( - (filter: { id: number }) => filter.id === linode.id + (filter: { linode: number }) => filter.linode === linode.id ); const filteredByRegion = orFilters.some( (filter: { region: string }) => filter.region === linode.region @@ -1077,7 +1077,6 @@ export const handlers = [ ) ); }), - rest.post('*object-storage/keys', (req, res, ctx) => { const { label, regions } = req.body as ObjectStorageKeyRequest; @@ -1962,14 +1961,7 @@ export const handlers = [ rest.post('*/account/payments', (req, res, ctx) => { return res(ctx.json(creditPaymentResponseFactory.build())); }), - // rest.get('*/databases/mysql/instances', (req, res, ctx) => { - // const online = databaseFactory.build({ status: 'ready' }); - // const initializing = databaseFactory.build({ status: 'initializing' }); - // const error = databaseFactory.build({ status: 'error' }); - // const unknown = databaseFactory.build({ status: 'unknown' }); - // const databases = [online, initializing, error, unknown]; - // return res(ctx.json(makeResourcePage(databases))); - // }), + rest.get('*/profile/tokens', (req, res, ctx) => { return res(ctx.json(makeResourcePage(appTokenFactory.buildList(30)))); }), @@ -2112,45 +2104,46 @@ export const handlers = [ id: Number(req.params.placementGroupId) ?? -1, label: 'pg-1', linodes: [ - ...[ - { - is_compliant: true, - linode: 0, - }, - { - is_compliant: true, - linode: 1, - }, - { - is_compliant: true, - linode: 2, - }, - { - is_compliant: true, - linode: 3, - }, - { - is_compliant: true, - linode: 5, - }, - { - is_compliant: true, - linode: 6, - }, - { - is_compliant: true, - linode: 7, - }, - { - is_compliant: true, - linode: 8, - }, - { - is_compliant: false, - linode: 43, - }, - ], - (req.body as any).linodes[0], + { + is_compliant: true, + linode: 1, + }, + { + is_compliant: true, + linode: 2, + }, + { + is_compliant: true, + linode: 3, + }, + { + is_compliant: true, + linode: 4, + }, + { + is_compliant: true, + linode: 5, + }, + { + is_compliant: true, + linode: 6, + }, + { + is_compliant: true, + linode: 7, + }, + { + is_compliant: true, + linode: 8, + }, + { + is_compliant: false, + linode: 43, + }, + { + is_compliant: true, + linode: (req.body as any).linodes[0], + }, ], }); @@ -2168,14 +2161,11 @@ export const handlers = [ id: Number(req.params.placementGroupId) ?? -1, label: 'pg-1', linodes: [ - { - is_compliant: true, - linode: 0, - }, { is_compliant: true, linode: 1, }, + { is_compliant: true, linode: 2, @@ -2184,6 +2174,10 @@ export const handlers = [ is_compliant: true, linode: 3, }, + { + is_compliant: true, + linode: 4, + }, { is_compliant: true, linode: 5, From ac168c0262634d0adbcde36cd02df8039b2dafe2 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Mon, 26 Feb 2024 16:27:14 -0500 Subject: [PATCH 04/10] fix last wrong type --- packages/api-v4/src/placement-groups/placement-groups.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api-v4/src/placement-groups/placement-groups.ts b/packages/api-v4/src/placement-groups/placement-groups.ts index 16cd63182fb..123149c8589 100644 --- a/packages/api-v4/src/placement-groups/placement-groups.ts +++ b/packages/api-v4/src/placement-groups/placement-groups.ts @@ -17,7 +17,7 @@ import type { CreatePlacementGroupPayload, PlacementGroup, UnassignLinodesFromPlacementGroupPayload, - RenamePlacementGroupPayload, + UpdatePlacementGroupPayload, } from './types'; /** @@ -72,7 +72,7 @@ export const createPlacementGroup = (data: CreatePlacementGroupPayload) => */ export const renamePlacementGroup = ( placementGroupId: number, - data: RenamePlacementGroupPayload + data: UpdatePlacementGroupPayload ) => Request( setURL( From eeb00682ec66c3dcdcb695f9ac8b159894b17341 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 27 Feb 2024 10:53:45 -0500 Subject: [PATCH 05/10] Affinity enforcement --- packages/api-v4/src/placement-groups/types.ts | 1 + .../src/features/PlacementGroups/utils.test.ts | 11 +++++++++++ .../manager/src/features/PlacementGroups/utils.ts | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/packages/api-v4/src/placement-groups/types.ts b/packages/api-v4/src/placement-groups/types.ts index 8507374487a..fc07d50222f 100644 --- a/packages/api-v4/src/placement-groups/types.ts +++ b/packages/api-v4/src/placement-groups/types.ts @@ -6,6 +6,7 @@ export const AFFINITY_TYPES = { } as const; export type AffinityType = keyof typeof AFFINITY_TYPES; +export type AffinityEnforcement = 'Strict' | 'Flexible'; export interface PlacementGroup { id: number; diff --git a/packages/manager/src/features/PlacementGroups/utils.test.ts b/packages/manager/src/features/PlacementGroups/utils.test.ts index 2c3bac0e4b5..b18bbbd8f08 100644 --- a/packages/manager/src/features/PlacementGroups/utils.test.ts +++ b/packages/manager/src/features/PlacementGroups/utils.test.ts @@ -2,6 +2,7 @@ import { placementGroupFactory, regionFactory } from 'src/factories'; import { affinityTypeOptions, + getAffinityEnforcement, getLinodesFromAllPlacementGroups, getPlacementGroupLinodeCount, hasPlacementGroupReachedCapacity, @@ -104,3 +105,13 @@ describe('getLinodesFromAllPlacementGroups', () => { expect(getLinodesFromAllPlacementGroups(undefined)).toEqual([]); }); }); + +describe('getAffinityEnforcement', () => { + it('returns "Strict" if `is_strict` is true', () => { + expect(getAffinityEnforcement(true)).toBe('Strict'); + }); + + it('returns "Flexible" if `is_strict` is false', () => { + expect(getAffinityEnforcement(false)).toBe('Flexible'); + }); +}); diff --git a/packages/manager/src/features/PlacementGroups/utils.ts b/packages/manager/src/features/PlacementGroups/utils.ts index b6f98a279cf..09c23187eca 100644 --- a/packages/manager/src/features/PlacementGroups/utils.ts +++ b/packages/manager/src/features/PlacementGroups/utils.ts @@ -1,11 +1,21 @@ import { AFFINITY_TYPES } from '@linode/api-v4/lib/placement-groups'; import type { + AffinityEnforcement, CreatePlacementGroupPayload, PlacementGroup, Region, } from '@linode/api-v4'; +/** + * Helper to get the affinity enforcement readable string. + */ +export const getAffinityEnforcement = ( + affinityType: PlacementGroup['is_strict'] +): AffinityEnforcement => { + return affinityType ? 'Strict' : 'Flexible'; +}; + /** * Helper to get the number of Linodes in a Placement Group. */ From 4cc4ab2cb6721980e88c61a4d8d923d3c708e5f7 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 27 Feb 2024 11:00:07 -0500 Subject: [PATCH 06/10] cleanup --- packages/api-v4/src/linodes/types.ts | 2 +- packages/manager/src/mocks/serverHandlers.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index cdf8d734187..a6c2a20a0a4 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -341,7 +341,7 @@ export interface UserData { export interface CreateLinodePlacementGroupPayload { id: number; - compliant_only?: boolean | null; + compliant_only?: boolean; } export interface CreateLinodeRequest { diff --git a/packages/manager/src/mocks/serverHandlers.ts b/packages/manager/src/mocks/serverHandlers.ts index 9754533710c..73f88217cf6 100644 --- a/packages/manager/src/mocks/serverHandlers.ts +++ b/packages/manager/src/mocks/serverHandlers.ts @@ -1961,7 +1961,14 @@ export const handlers = [ rest.post('*/account/payments', (req, res, ctx) => { return res(ctx.json(creditPaymentResponseFactory.build())); }), - + // rest.get('*/databases/mysql/instances', (req, res, ctx) => { + // const online = databaseFactory.build({ status: 'ready' }); + // const initializing = databaseFactory.build({ status: 'initializing' }); + // const error = databaseFactory.build({ status: 'error' }); + // const unknown = databaseFactory.build({ status: 'unknown' }); + // const databases = [online, initializing, error, unknown]; + // return res(ctx.json(makeResourcePage(databases))); + // }), rest.get('*/profile/tokens', (req, res, ctx) => { return res(ctx.json(makeResourcePage(appTokenFactory.buildList(30)))); }), From 4575882db85533da29632657808eaac4273f2591 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 27 Feb 2024 11:22:22 -0500 Subject: [PATCH 07/10] Added changeset: Update Placement Groups types, methods and factories --- .../.changeset/pr-10200-upcoming-features-1709050942048.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/manager/.changeset/pr-10200-upcoming-features-1709050942048.md diff --git a/packages/manager/.changeset/pr-10200-upcoming-features-1709050942048.md b/packages/manager/.changeset/pr-10200-upcoming-features-1709050942048.md new file mode 100644 index 00000000000..53a3d5f1c89 --- /dev/null +++ b/packages/manager/.changeset/pr-10200-upcoming-features-1709050942048.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Upcoming Features +--- + +Update Placement Groups types, methods and factories ([#10200](https://github.com/linode/manager/pull/10200)) From f0e59621216e383e2f90268f59e35f1e31a3b998 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 27 Feb 2024 11:33:01 -0500 Subject: [PATCH 08/10] Add cmments --- packages/api-v4/src/linodes/types.ts | 3 +++ packages/api-v4/src/placement-groups/types.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index a6c2a20a0a4..811de9926ee 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -341,6 +341,9 @@ export interface UserData { export interface CreateLinodePlacementGroupPayload { id: number; + /** + * This parameter is silent in Cloud Manager, but still needs to be represented in the API types. + */ compliant_only?: boolean; } diff --git a/packages/api-v4/src/placement-groups/types.ts b/packages/api-v4/src/placement-groups/types.ts index fc07d50222f..a6032417b2e 100644 --- a/packages/api-v4/src/placement-groups/types.ts +++ b/packages/api-v4/src/placement-groups/types.ts @@ -39,6 +39,9 @@ export type UpdatePlacementGroupPayload = Pick; */ export type AssignLinodesToPlacementGroupPayload = { linodes: [number]; + /** + * This parameter is silent in Cloud Manager, but still needs to be represented in the API types. + */ compliant_only?: boolean; }; From 63cf603afd4f32f098f4b21a44ed9479f43bc9ff Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 27 Feb 2024 11:44:06 -0500 Subject: [PATCH 09/10] Feedback --- packages/api-v4/src/linodes/types.ts | 4 ++-- packages/api-v4/src/placement-groups/types.ts | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index 811de9926ee..03d9db17118 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -1,7 +1,7 @@ import type { Region } from '../regions'; import type { IPAddress, IPRange } from '../networking/types'; import type { SSHKey } from '../profile/types'; -import type { LinodePlacementGroup } from '../placement-groups/types'; +import type { PlacementGroupPayload } from '../placement-groups/types'; export type Hypervisor = 'kvm' | 'zen'; @@ -24,7 +24,7 @@ export interface Linode { ipv4: string[]; ipv6: string | null; label: string; - placement_group?: LinodePlacementGroup; // If not in a placement group, this will be undefined + placement_group?: PlacementGroupPayload; // If not in a placement group, this will be undefined type: string | null; status: LinodeStatus; updated: string; diff --git a/packages/api-v4/src/placement-groups/types.ts b/packages/api-v4/src/placement-groups/types.ts index a6032417b2e..f0d5aa140eb 100644 --- a/packages/api-v4/src/placement-groups/types.ts +++ b/packages/api-v4/src/placement-groups/types.ts @@ -21,13 +21,11 @@ export interface PlacementGroup { is_strict: boolean; } -type PlacementGroupPayload = Pick< +export type PlacementGroupPayload = Pick< PlacementGroup, 'id' | 'label' | 'affinity_type' | 'is_strict' >; -export type LinodePlacementGroup = PlacementGroupPayload; - export type CreatePlacementGroupPayload = Omit & { region: Region['id']; }; From c5b3404ae105f1cbc5c22e80990e0f2ab363f6f3 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Tue, 27 Feb 2024 11:52:20 -0500 Subject: [PATCH 10/10] Feedback 2 --- packages/api-v4/src/linodes/types.ts | 4 +++- packages/api-v4/src/placement-groups/types.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index 03d9db17118..cfbd0dd089b 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -24,7 +24,7 @@ export interface Linode { ipv4: string[]; ipv6: string | null; label: string; - placement_group?: PlacementGroupPayload; // If not in a placement group, this will be undefined + placement_group?: PlacementGroupPayload; // If not in a placement group, this will be excluded from the response. type: string | null; status: LinodeStatus; updated: string; @@ -343,6 +343,8 @@ export interface CreateLinodePlacementGroupPayload { id: number; /** * This parameter is silent in Cloud Manager, but still needs to be represented in the API types. + * + * @default false */ compliant_only?: boolean; } diff --git a/packages/api-v4/src/placement-groups/types.ts b/packages/api-v4/src/placement-groups/types.ts index f0d5aa140eb..df593e53bdc 100644 --- a/packages/api-v4/src/placement-groups/types.ts +++ b/packages/api-v4/src/placement-groups/types.ts @@ -39,6 +39,8 @@ export type AssignLinodesToPlacementGroupPayload = { linodes: [number]; /** * This parameter is silent in Cloud Manager, but still needs to be represented in the API types. + * + * @default false */ compliant_only?: boolean; };