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-6576] - Dbaas total disk size and used disk size #9638

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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": Upcoming Features
---

DbaaS disk size and used size ([#9638](https://github.com/linode/manager/pull/9638))
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 @@ -239,6 +239,7 @@ export type EventAction =
| 'community_mention'
| 'community_question_reply'
| 'credit_card_updated'
| 'database_low_disk_space_remaining'
| 'disk_create'
| 'disk_update'
| 'disk_delete'
Expand Down
2 changes: 2 additions & 0 deletions packages/api-v4/src/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export interface BaseDatabase {
hosts: DatabaseHosts;
port: number;
updates: UpdatesSchedule;
total_disk_size_gb?: number;
used_disk_size_gb?: number;
bnussman-akamai marked this conversation as resolved.
Show resolved Hide resolved
}

export interface MySQLDatabase extends BaseDatabase {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

DbaaS disk size and used size ([#9638](https://github.com/linode/manager/pull/9638))
1 change: 1 addition & 0 deletions packages/manager/src/dev-tools/FeatureFlagTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const MOCK_FEATURE_FLAGS_STORAGE_KEY = 'devTools/mock-feature-flags';
const options: { flag: keyof Flags; label: string }[] = [
{ flag: 'metadata', label: 'Metadata' },
{ flag: 'databaseBeta', label: 'Database Beta' },
{ flag: 'databases', label: 'Databases' },
bnussman-akamai marked this conversation as resolved.
Show resolved Hide resolved
{ flag: 'vpc', label: 'VPC' },
{ flag: 'aglb', label: 'AGLB' },
];
Expand Down
6 changes: 6 additions & 0 deletions packages/manager/src/eventMessageGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ export const eventMessageCreators: { [index: string]: CreatorsForStatus } = {
database_delete: {
notification: (e) => `Database ${e.entity!.label} has been deleted.`,
},
database_low_disk_space_remaining: {
finished: (e) =>
`Low disk space alert for database ${e.entity!.label} has cleared.`,
notification: (e) =>
`Database ${e.entity!.label} has low disk space remaining.`,
},
database_update: {
finished: (e) => `Database ${e.entity!.label} has been updated.`,
},
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/src/factories/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const databaseFactory = Factory.Sync.makeFactory<Database>({
region: 'us-east',
ssl_connection: false,
status: pickRandom(possibleStatuses),
total_disk_size_gb: 15,
type: 'g6-standard-0',
updated: '2021-12-16T17:15:12',
updates: {
Expand All @@ -189,6 +190,7 @@ export const databaseFactory = Factory.Sync.makeFactory<Database>({
hour_of_day: 20,
week_of_month: null,
},
used_disk_size_gb: 5,
version: '5.8.13',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { makeStyles } from 'tss-react/mui';

import { Box } from 'src/components/Box';
import { StatusIcon } from 'src/components/StatusIcon/StatusIcon';
import { TooltipIcon } from 'src/components/TooltipIcon';
import { Typography } from 'src/components/Typography';
import { useDatabaseTypesQuery } from 'src/queries/databases';
import { useRegionsQuery } from 'src/queries/regions';
Expand All @@ -27,7 +28,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
label: {
fontFamily: theme.font.bold,
lineHeight: '22px',
width: theme.spacing(7),
width: theme.spacing(13),
},
status: {
alignItems: 'center',
Expand Down Expand Up @@ -65,6 +66,14 @@ export const DatabaseSummaryClusterConfiguration = (props: Props) => {
? 'Primary'
: `Primary +${database.cluster_size - 1} replicas`;

const sxTooltipIcon = {
padding: '0px',
marginLeft: '4px',
};

const storageCopy =
bnussman-akamai marked this conversation as resolved.
Show resolved Hide resolved
'The total disk size is smaller than the selected plan capacity due to the OS overhead.';

return (
<>
<Typography className={classes.header} variant="h3">
Expand Down Expand Up @@ -102,10 +111,28 @@ export const DatabaseSummaryClusterConfiguration = (props: Props) => {
<Typography className={classes.label}>CPUs</Typography>
{type.vcpus}
</Box>
<Box display="flex">
<Typography className={classes.label}>Storage</Typography>
{convertMegabytesTo(type.disk, true)}
</Box>
{database.total_disk_size_gb ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to make a new feature flag and use it as an additional conditional here? This works but wondering if the scope may expand?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend has a feature gate for the rollout. I asked about a UI flag, but they said the backend API response should suffice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, thx for the explanation

<>
<Box display="flex">
<Typography className={classes.label}>Total Disk Size</Typography>
{database.total_disk_size_gb} GB
<TooltipIcon
status="help"
sxTooltipIcon={sxTooltipIcon}
text={storageCopy}
/>
</Box>
<Box display="flex">
<Typography className={classes.label}>Used</Typography>
{database.used_disk_size_gb} GB
</Box>
</>
) : (
<Box display="flex">
<Typography className={classes.label}>Storage</Typography>
{convertMegabytesTo(type.disk, true)}
</Box>
)}
</div>
</>
);
Expand Down
12 changes: 11 additions & 1 deletion packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,11 @@ export const handlers = [
'Rebooting this thing and showing an extremely long event message for no discernible reason other than the fairly obvious reason that we want to do some testing of whether or not these messages wrap.',
percent_complete: 15,
});
const dbEvents = eventFactory.buildList(1, {
action: 'database_low_disk_space_remaining',
entity: { id: 999, label: 'database-1', type: 'database' },
message: 'Low disk space.',
});
const oldEvents = eventFactory.buildList(20, {
action: 'account_update',
percent_complete: 100,
Expand All @@ -1018,7 +1023,12 @@ export const handlers = [
});
return res.once(
ctx.json(
makeResourcePage([...events, ...oldEvents, eventWithSpecialCharacters])
makeResourcePage([
...events,
...dbEvents,
...oldEvents,
eventWithSpecialCharacters,
])
)
);
}),
Expand Down