Skip to content

Commit

Permalink
Address CRs
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Aug 22, 2024
1 parent c3116f0 commit 500a5b3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export const AllowSkipOnTimeout = () => (
export const AllowOverwrite = () => (
<CreateDatabaseDialog
{...props}
attempt={{ status: 'failed', statusText: dbWithoutDbServerExistsErrorMsg }}
attempt={{
status: 'failed',
statusText: `A database with the name "some-name" ${dbWithoutDbServerExistsErrorMsg}. \
You can overwrite it, or use a different name and retry.`,
}}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export function CreateDatabaseDialog({
* Most likely cause of timeout is when we found a matching db_service
* but no db_server heartbeats. Most likely cause is because db_service
* has been stopped but is not removed from teleport yet (there is some
* minutes delay on expiry)
* minutes delay on expiry).
*
* We allow the user to proceed to the next step to re-deploy (replace)
* the db_service that has been stopped.
*/
if (attempt.statusText === timeoutErrorMsg) {
content = <SuccessContent dbName={dbName} onClick={onTimeout} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ export function useCreateDatabase() {

if (overwriteDb) {
try {
await ctx.databaseService.updateDatabase(clusterId, {
kind: 'overwrite-update',
dbOverwrite: db,
await ctx.databaseService.createDatabase(clusterId, {
...db,
overwrite: true,
});
setCreatedDb(db);
} catch (err) {
Expand Down Expand Up @@ -232,7 +232,6 @@ export function useCreateDatabase() {
else if (requiresDbUpdate(db)) {
try {
await ctx.databaseService.updateDatabase(clusterId, {
kind: 'partial-update',
...db,
});
setCreatedDb(db);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export function useMutualTls({ ctx, props }: Props) {
run(() =>
ctx.databaseService
.updateDatabase(clusterId, {
kind: 'partial-update',
name: meta.db.name,
caCert,
})
Expand Down
8 changes: 1 addition & 7 deletions web/packages/teleport/src/services/databases/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ class DatabaseService {
req: UpdateDatabaseRequest
): Promise<Database> {
return api
.put(
cfg.getDatabaseUrl(
clusterId,
req.kind === 'overwrite-update' ? req.dbOverwrite?.name : req.name
),
req
)
.put(cfg.getDatabaseUrl(clusterId, req.name), req)
.then(makeDatabase);
}

Expand Down
13 changes: 7 additions & 6 deletions web/packages/teleport/src/services/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export type DatabasesResponse = {
totalCount?: number;
};

export type UpdateDatabaseRequest =
| (Omit<Partial<CreateDatabaseRequest>, 'protocol'> & {
kind: 'partial-update';
caCert?: string;
})
| { kind: 'overwrite-update'; dbOverwrite: CreateDatabaseRequest };
export type UpdateDatabaseRequest = Omit<
Partial<CreateDatabaseRequest>,
'protocol'
> & {
caCert?: string;
};

export type CreateDatabaseRequest = {
name: string;
Expand All @@ -71,6 +71,7 @@ export type CreateDatabaseRequest = {
awsRds?: AwsRdsDatabase;
awsRegion?: Regions;
awsVpcId?: string;
overwrite?: boolean;
};

export type DatabaseIamPolicyResponse = {
Expand Down

0 comments on commit 500a5b3

Please sign in to comment.