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

feat: [UIE-8054] - DBaaS enhancements 1 #10786

Merged
merged 8 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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-10786-added-1723662117687.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Added
---

Add DBaaS V2 capabilites ([#10786](https://github.com/linode/manager/pull/10786))
corya-akamai marked this conversation as resolved.
Show resolved Hide resolved
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
6 changes: 4 additions & 2 deletions packages/api-v4/src/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type MemberType = 'primary' | 'failover';

// DatabaseInstance is the interface for the shape of data returned by the /databases/instances endpoint.
export interface DatabaseInstance {
id: number;
id: string;
corya-akamai marked this conversation as resolved.
Show resolved Hide resolved
label: string;
engine: Engine;
type: string;
Expand All @@ -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
59 changes: 46 additions & 13 deletions packages/manager/src/factories/databases.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
import type {
ClusterSize,
Database,
DatabaseBackup,
DatabaseEngine,
DatabaseInstance,
DatabaseStatus,
DatabaseType,
Engine,
MySQLReplicationType,
PostgresReplicationType,
} from '@linode/api-v4/lib/databases/types';
Expand Down Expand Up @@ -35,10 +37,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 +161,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),
id: Factory.each((i) => (i % 2 ? i.toString() : `a${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 +222,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 @@ -452,7 +452,7 @@ const DatabaseCreate = () => {
},
],
labelOptions: {
suffixComponent: flags.databaseBeta ? (
suffixComponent: flags.dbaasV2?.beta ? (
corya-akamai marked this conversation as resolved.
Show resolved Hide resolved
<BetaChip className={classes.chip} component="span" />
) : null,
},
Expand Down Expand Up @@ -564,21 +564,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 @@ -28,7 +28,7 @@ describe('database current configuration section', () => {
const standardTypes = [
databaseTypeFactory.build({
class: 'nanode',
id: 'g6-standard-0',
id: 'g6-nanode-1',
corya-akamai marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as React from 'react';
import { makeStyles } from 'tss-react/mui';

import Logo from 'src/assets/icons/db-logo.svg';
import { BetaChip } from 'src/components/BetaChip/BetaChip';
import { Box } from 'src/components/Box';
import { Typography } from 'src/components/Typography';

import type { Theme } from '@mui/material/styles';

interface Props {
style?: React.CSSProperties;
}

const useStyles = makeStyles()((theme: Theme) => ({
betaChip: {
backgroundColor: '#727272',
color: theme.color.white,
},
logo: {
color: '#32363C',
display: 'flex',
marginTop: '8px',
},
}));

export const DatabaseLogo = ({ style }: Props) => {
const { classes } = useStyles();
return (
<Box
display="flex"
justifyContent="center"
sx={style ? style : { margin: '20px' }}
>
<Typography sx={{ display: 'inline-block', textAlign: 'center' }}>
<BetaChip className={classes.betaChip} component="span" />
<span className={classes.logo}>
Powered by <Logo />
</span>
</Typography>
</Box>
);
};

export default DatabaseLogo;
corya-akamai marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading