Skip to content

Commit

Permalink
feat: [UIE-8054] - DBaaS enhancements 1 (#10786)
Browse files Browse the repository at this point in the history
* feat: [UIE-8054] - DBaaS enhancements 1

* Added changeset: Update DBaaS menu item with V1 or V2 capability, add mock data

* Review comments

* feature flag

* review comments

* review comments

* review comments

* review comments
  • Loading branch information
corya-akamai authored Aug 23, 2024
1 parent fbf256a commit b665964
Show file tree
Hide file tree
Showing 19 changed files with 197 additions and 45 deletions.
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-10786-added-1723662117687.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Added
---

Managed Databases V2` capability and types ([#10786](https://github.com/linode/manager/pull/10786))
1 change: 1 addition & 0 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export type AccountCapability =
| 'LKE HA Control Planes'
| 'Machine Images'
| 'Managed Databases'
| 'Managed Databases V2'
| 'NodeBalancers'
| 'Object Storage Access Key Regions'
| 'Object Storage Endpoint Types'
Expand Down
4 changes: 3 additions & 1 deletion packages/api-v4/src/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ export interface DatabaseInstance {
* A key/value object where the key is an IP address and the value is a member type.
*/
members: Record<string, MemberType>;
platform?: string;
}

export type ClusterSize = 1 | 3;
export type ClusterSize = 1 | 2 | 3;

type ReadonlyCount = 0 | 2;

export type MySQLReplicationType = 'none' | 'semi_synch' | 'asynch';
Expand Down
1 change: 1 addition & 0 deletions packages/api-v4/src/regions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Capabilities =
| 'Kubernetes'
| 'Linodes'
| 'Managed Databases'
| 'Managed Databases V2'
| 'Metadata'
| 'NodeBalancers'
| 'Object Storage'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Update DBaaS menu item with V1 or V2 capability, add mock data ([#10786](https://github.com/linode/manager/pull/10786))
5 changes: 5 additions & 0 deletions packages/manager/src/__data__/regionsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const regions: Region[] = [
'Vlans',
'VPCs',
'Managed Databases',
'Managed Databases V2',
'Metadata',
'Premium Plans',
'Placement Group',
Expand Down Expand Up @@ -129,6 +130,7 @@ export const regions: Region[] = [
'Vlans',
'VPCs',
'Managed Databases',
'Managed Databases V2',
'Metadata',
'Premium Plans',
],
Expand Down Expand Up @@ -484,6 +486,7 @@ export const regions: Region[] = [
'VPCs',
'Block Storage Migrations',
'Managed Databases',
'Managed Databases V2',
'Placement Group',
],
country: 'us',
Expand Down Expand Up @@ -511,6 +514,7 @@ export const regions: Region[] = [
'Cloud Firewall',
'Block Storage Migrations',
'Managed Databases',
'Managed Databases V2',
'Placement Group',
],
country: 'us',
Expand Down Expand Up @@ -542,6 +546,7 @@ export const regions: Region[] = [
'VPCs',
'Block Storage Migrations',
'Managed Databases',
'Managed Databases V2',
'Placement Group',
],
country: 'us',
Expand Down
23 changes: 23 additions & 0 deletions packages/manager/src/assets/icons/db-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/manager/src/components/PrimaryNav/PrimaryNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
hide: !isDatabasesEnabled,
href: '/databases',
icon: <Database />,
isBeta: flags.databaseBeta,
isBeta: flags.dbaasV2?.beta,
},
{
activeLinks: ['/kubernetes/create'],
Expand Down Expand Up @@ -249,7 +249,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
isDatabasesEnabled,
isManaged,
allowMarketplacePrefetch,
flags.databaseBeta,
flags.dbaasV2,
isPlacementGroupsEnabled,
flags.placementGroups,
isACLPEnabled,
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/src/dev-tools/FeatureFlagTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const options: { flag: keyof Flags; label: string }[] = [
{ flag: 'placementGroups', label: 'Placement Groups' },
{ flag: 'selfServeBetas', label: 'Self Serve Betas' },
{ flag: 'supportTicketSeverity', label: 'Support Ticket Severity' },
{ flag: 'dbaasV2', label: 'Databases V2 Beta' },
{ flag: 'databaseResize', label: 'Database Resize' },
];

export const FeatureFlagTool = withFeatureFlagProvider(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/factories/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const accountFactory = Factory.Sync.makeFactory<Account>({
'Linodes',
'LKE HA Control Planes',
'Machine Images',
'Managed Databases',
'Managed Databases V2',
'NodeBalancers',
'Object Storage Access Key Regions',
'Object Storage Endpoint Types',
Expand Down
66 changes: 50 additions & 16 deletions packages/manager/src/factories/databases.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import {
import { v4 } from 'uuid';

import Factory from 'src/factories/factoryProxy';
import { pickRandom, randomDate } from 'src/utilities/random';

import type {
ClusterSize,
Database,
DatabaseBackup,
DatabaseEngine,
DatabaseInstance,
DatabaseStatus,
DatabaseType,
Engine,
MySQLReplicationType,
PostgresReplicationType,
} from '@linode/api-v4/lib/databases/types';
import Factory from 'src/factories/factoryProxy';
import { v4 } from 'uuid';

import { pickRandom, randomDate } from 'src/utilities/random';

// These are not all of the possible statuses, but these are some common ones.
export const possibleStatuses: DatabaseStatus[] = [
Expand All @@ -35,10 +38,35 @@ export const possiblePostgresReplicationTypes: PostgresReplicationType[] = [
'asynch',
];

export const possibleTypes: string[] = [
'g6-nanode-1',
'g6-standard-2',
'g6-standard-4',
'g6-standard-6',
'g6-standard-20',
'g6-dedicated-32',
'g6-dedicated-50',
'g6-dedicated-56',
'g6-dedicated-64',
];

export const possibleRegions: string[] = [
'ap-south',
'ap-southeast',
'ap-west',
'ca-central',
'eu-central',
'fr-par',
'us-east',
'us-iad',
'us-ord',
];

export const IPv4List = ['192.0.2.1', '196.0.0.0', '198.0.0.2'];

export const databaseTypeFactory = Factory.Sync.makeFactory<DatabaseType>({
class: 'standard',
disk: Factory.each((i) => i * 20480),
engines: {
mongodb: [
{
Expand Down Expand Up @@ -134,32 +162,38 @@ export const databaseTypeFactory = Factory.Sync.makeFactory<DatabaseType>({
],
},
id: Factory.each((i) => `g6-standard-${i}`),
disk: Factory.each((i) => i * 20480),
label: Factory.each((i) => `Linode ${i} GB`),
memory: Factory.each((i) => i * 2048),
vcpus: Factory.each((i) => i * 2),
});

const adb10 = (i: number) => i % 2 === 0;

export const databaseInstanceFactory = Factory.Sync.makeFactory<DatabaseInstance>(
{
cluster_size: Factory.each(() => pickRandom([1, 3])),
cluster_size: Factory.each((i) =>
adb10(i)
? ([1, 3][i % 2] as ClusterSize)
: ([1, 2, 3][i % 3] as ClusterSize)
),
created: '2021-12-09T17:15:12',
engine: 'mysql',
engine: Factory.each((i) => ['mysql', 'postgresql'][i % 2] as Engine),
hosts: {
primary: 'db-mysql-primary-0.b.linodeb.net',
secondary: 'db-mysql-secondary-0.b.linodeb.net',
primary: 'db-primary-0.b.linodeb.net',
secondary: 'db-secondary-0.b.linodeb.net',
},
id: Factory.each((i) => i),
instance_uri: '',
label: Factory.each((i) => `database-${i}`),
label: Factory.each((i) => `example.com-database-${i}`),
members: {
'2.2.2.2': 'primary',
},
region: 'us-east',
status: Factory.each(() => pickRandom(possibleStatuses)),
type: databaseTypeFactory.build().id,
platform: Factory.each((i) => (adb10(i) ? 'adb10' : 'adb20')),
region: Factory.each((i) => possibleRegions[i % possibleRegions.length]),
status: Factory.each((i) => possibleStatuses[i % possibleStatuses.length]),
type: Factory.each((i) => possibleTypes[i % possibleTypes.length]),
updated: '2021-12-16T17:15:12',
version: '5.8.13',
version: Factory.each((i) => ['8.0.30', '15.7'][i % 2]),
}
);

Expand Down Expand Up @@ -189,7 +223,7 @@ export const databaseFactory = Factory.Sync.makeFactory<Database>({
ssl_connection: false,
status: pickRandom(possibleStatuses),
total_disk_size_gb: 15,
type: 'g6-standard-0',
type: 'g6-nanode-1',
updated: '2021-12-16T17:15:12',
updates: {
day_of_week: 1,
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export interface Flags {
databaseBeta: boolean;
databaseResize: boolean;
databases: boolean;
dbaasV2: BetaFeatureFlag;
disableLargestGbPlans: boolean;
eventMessagesV2: boolean;
gecko: boolean; // @TODO gecko: delete this after next release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
},
},
chip: {
marginLeft: 6,
marginTop: 4,
},
createBtn: {
Expand Down Expand Up @@ -452,7 +453,7 @@ const DatabaseCreate = () => {
},
],
labelOptions: {
suffixComponent: flags.databaseBeta ? (
suffixComponent: flags.dbaasV2?.beta ? (
<BetaChip className={classes.chip} component="span" />
) : null,
},
Expand Down Expand Up @@ -564,21 +565,6 @@ const DatabaseCreate = () => {
))}
</RadioGroup>
</FormControl>
<Grid md={8} xs={12}>
{flags.databaseBeta ? (
<Notice className={classes.notice} variant="info">
<strong>
Notice: There is no charge for database clusters during beta.
</strong>{' '}
Database clusters will be subject to charges when the beta
period ends on May 2nd, 2022.{' '}
<Link to="https://www.linode.com/pricing/#databases">
View pricing
</Link>
.
</Notice>
) : undefined}
</Grid>
</Grid>
<Divider spacingBottom={12} spacingTop={26} />
<Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('database resize', () => {
const standardTypes = [
databaseTypeFactory.build({
class: 'nanode',
id: 'g6-standard-0',
id: 'g6-nanode-1',
label: `Nanode 1 GB`,
memory: 1024,
}),
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('database resize', () => {
const standardTypes = [
databaseTypeFactory.build({
class: 'nanode',
id: 'g6-standard-0',
id: 'g6-nanode-1',
label: `Nanode 1 GB`,
memory: 1024,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('database current configuration section', () => {
const standardTypes = [
databaseTypeFactory.build({
class: 'nanode',
id: 'g6-standard-0',
id: 'g6-nanode-1',
label: `Nanode 1 GB`,
memory: 1024,
}),
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('database current configuration section', () => {
getByText('1 GB');

getByText('CPUs');
getByText('4');
getByText('2');

getByText('Total Disk Size');
getByText('15 GB');
Expand Down
Loading

0 comments on commit b665964

Please sign in to comment.