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

fix: [UIE-8146] - DBaaS V2 bug fix #10980

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Changed
---

Make `replication_type` and `replication_commit_type` optional in MySQL and Postgres interfaces ([#10980](https://github.com/linode/manager/pull/10980))
6 changes: 3 additions & 3 deletions packages/api-v4/src/databases/types.ts
mjac0bs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export interface BaseDatabase {
}

export interface MySQLDatabase extends BaseDatabase {
replication_type: MySQLReplicationType;
replication_type?: MySQLReplicationType;
}

export type PostgresReplicationType = 'none' | 'synch' | 'asynch';
Expand All @@ -169,8 +169,8 @@ type ReplicationCommitTypes =
| 'off';

export interface PostgresDatabase extends BaseDatabase {
replication_type: PostgresReplicationType;
replication_commit_type: ReplicationCommitTypes;
replication_type?: PostgresReplicationType;
replication_commit_type?: ReplicationCommitTypes;
}

type MongoStorageEngine = 'wiredtiger' | 'mmapv1';
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10980-fixed-1726845381695.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Incorrect timezone in Database Maintenance Window tooltip, inaccurate Resize status of Database, and unneeded `replication_type` in v2 `createPayload` ([#10980](https://github.com/linode/manager/pull/10980))
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ const DatabaseCreate = () => {
...values,
allow_list: _allow_list,
};

if (isDatabasesV2Beta) {
delete createPayload.replication_type;
}
try {
const response = await createDatabase(createPayload);
history.push(`/databases/${response.engine}/${response.id}`);
Expand Down Expand Up @@ -459,17 +461,26 @@ const DatabaseCreate = () => {
'cluster_size',
values.cluster_size < 1 ? 3 : values.cluster_size
);
setFieldValue(
'replication_type',
determineReplicationType(values.cluster_size, values.engine)
);
setFieldValue(
'replication_commit_type',
determineReplicationCommitType(values.engine)
);
!isDatabasesV2Enabled &&
setFieldValue(
'replication_type',
determineReplicationType(values.cluster_size, values.engine)
);
mpolotsk-akamai marked this conversation as resolved.
Show resolved Hide resolved
!isDatabasesV2Enabled &&
setFieldValue(
'replication_commit_type',
determineReplicationCommitType(values.engine)
);
setFieldValue('storage_engine', determineStorageEngine(values.engine));
setFieldValue('compression_type', determineCompressionType(values.engine));
}, [dbtypes, setFieldValue, values.cluster_size, values.type, values.engine]);
}, [
dbtypes,
setFieldValue,
values.cluster_size,
values.type,
values.engine,
isDatabasesV2Enabled,
]);

if (regionsLoading || !regionsData || enginesLoading || typesLoading) {
return <CircleProgress />;
Expand Down Expand Up @@ -580,10 +591,11 @@ const DatabaseCreate = () => {
<FormControl
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setFieldValue('cluster_size', +e.target.value);
setFieldValue(
'replication_type',
+e.target.value === 1 ? 'none' : 'semi_synch'
);
!isDatabasesV2Enabled &&
setFieldValue(
'replication_type',
+e.target.value === 1 ? 'none' : 'semi_synch'
);
}}
data-testid="database-nodes"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ const weekSelectionMap = [
];

const utcOffsetText = (utcOffsetInHours: number) => {
return utcOffsetInHours < 0
return utcOffsetInHours <= 0
? `+${Math.abs(utcOffsetInHours)}`
: `-${utcOffsetInHours}`;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
import React from 'react';
import { DatabaseStatusDisplay } from '../DatabaseDetail/DatabaseStatusDisplay';
import { mockMatchMedia, renderWithTheme } from 'src/utilities/testHelpers';

import { databaseFactory } from 'src/factories';
import { entityFactory, eventFactory } from 'src/factories/events';
import { mockMatchMedia, renderWithTheme } from 'src/utilities/testHelpers';

import { DatabaseStatusDisplay } from '../DatabaseDetail/DatabaseStatusDisplay';
beforeAll(() => mockMatchMedia());

describe('DatabaseStatusDisplay component', () => {
it(`renders status 'resizing' with percentage when recent event status is 'started' or 'scheduled'`, () => {
it(`should render status 'resizing' with percentage when recent event status is 'started'`, () => {
const mockEvent = eventFactory.build({
action: 'database_resize',
percent_complete: 50,
entity: entityFactory.build({ id: 1, type: 'database' }),
percent_complete: 50,
status: 'started',
});
const database = databaseFactory.build({ id: 1, status: 'resizing' });

const { getByText } = renderWithTheme(
<DatabaseStatusDisplay events={[mockEvent]} database={database} />
<DatabaseStatusDisplay database={database} events={[mockEvent]} />
);
expect(getByText('Resizing (50%)')).toBeInTheDocument();
});

it(`renders status 'active' when recent event status is 'finished' `, () => {
it(`should render status 'resizing' when recent event status is 'scheduled' `, () => {
const mockEvent = eventFactory.build({
action: 'database_resize',
entity: entityFactory.build({ id: 1, type: 'database' }),
percent_complete: 50,
status: 'scheduled',
});
const database = databaseFactory.build({ id: 1, status: 'resizing' });

const { getByText } = renderWithTheme(
<DatabaseStatusDisplay database={database} events={[mockEvent]} />
);

expect(getByText('Resizing (50%)')).toBeInTheDocument();
});
it(`should render status 'active' when recent event status is 'finished' `, () => {
const mockEvent = eventFactory.build({
action: 'database_resize',
status: 'finished',
entity: entityFactory.build({ id: 1, type: 'database' }),
status: 'finished',
});
const database = databaseFactory.build({ id: 1, status: 'active' });

const { getByText } = renderWithTheme(
<DatabaseStatusDisplay events={[mockEvent]} database={database} />
<DatabaseStatusDisplay database={database} events={[mockEvent]} />
);

expect(getByText('Active')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ export const DatabaseStatusDisplay = (props: Props) => {
let progress: number | undefined;
let displayedStatus;

if (
const isResizing =
recentEvent?.action === 'database_resize' &&
(recentEvent?.status === 'started' || recentEvent?.status === 'scheduled')
) {
database.status === 'resizing' &&
mpolotsk-akamai marked this conversation as resolved.
Show resolved Hide resolved
(recentEvent?.status === 'started' || recentEvent?.status === 'scheduled');

if (isResizing) {
progress = recentEvent?.percent_complete ?? 0;
displayedStatus = (
<>
Expand Down
3 changes: 2 additions & 1 deletion packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ import { accountLoginFactory } from 'src/factories/accountLogin';
import { accountUserFactory } from 'src/factories/accountUsers';
import { grantFactory, grantsFactory } from 'src/factories/grants';
import { LinodeKernelFactory } from 'src/factories/linodeKernel';
import { pickRandom } from 'src/utilities/random';
import { getStorage } from 'src/utilities/storage';

const getRandomWholeNumber = (min: number, max: number) =>
Math.floor(Math.random() * (max - min + 1) + min);

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

import type {
AccountMaintenance,
CreateObjectStorageKeyPayload,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/validation": Changed
---

Make `replication_type` and `replication_commit_type` optional in `databases.schema.ts` ([#10980](https://github.com/linode/manager/pull/10980))
4 changes: 2 additions & 2 deletions packages/validation/src/databases.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export const createDatabaseSchema = object({
is: (engine: string) => Boolean(engine.match(/postgres/)),
then: string().oneOf(['none', 'synch', 'asynch']),
})
.required('Replication Type is required'),
.optional(),
otherwise: string().notRequired().nullable(true),
}),
replication_commit_type: string().when('engine', {
is: (engine: string) => Boolean(engine.match(/postgres/)),
then: string()
.oneOf(['off', 'on', 'local', 'remote_write', 'remote_apply'])
.required(),
.optional(),
otherwise: string().notRequired().nullable(true),
}),
storage_engine: string().when('engine', {
Expand Down
Loading