Skip to content

Commit

Permalink
make create db error not notfatal
Browse files Browse the repository at this point in the history
  • Loading branch information
fredzqm committed May 10, 2024
1 parent f2a8fee commit 0ebdf26
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/dataconnect/provisionCloudSql.ts
Expand Up @@ -77,11 +77,18 @@ export async function provisionCloudSql(args: {
try {
await cloudSqlAdminClient.getDatabase(projectId, instanceId, databaseId);
silent || utils.logLabeledBullet("dataconnect", `Found existing database ${databaseId}.`);
} catch (err) {
silent ||
utils.logLabeledBullet("dataconnect", `Database ${databaseId} not found, creating it now...`);
await cloudSqlAdminClient.createDatabase(projectId, instanceId, databaseId);
silent || utils.logLabeledBullet("dataconnect", `Database ${databaseId} created.`);
} catch (err: any) {

Check warning on line 80 in src/dataconnect/provisionCloudSql.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err.status === 404) {

Check warning on line 81 in src/dataconnect/provisionCloudSql.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
// Create the database if not found.
silent ||
utils.logLabeledBullet("dataconnect", `Database ${databaseId} not found, creating it now...`);

Check failure on line 84 in src/dataconnect/provisionCloudSql.ts

View workflow job for this annotation

GitHub Actions / unit (18)

Replace `"dataconnect",·`Database·${databaseId}·not·found,·creating·it·now...`` with `⏎··········"dataconnect",⏎··········`Database·${databaseId}·not·found,·creating·it·now...`,⏎········`

Check failure on line 84 in src/dataconnect/provisionCloudSql.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Replace `"dataconnect",·`Database·${databaseId}·not·found,·creating·it·now...`` with `⏎··········"dataconnect",⏎··········`Database·${databaseId}·not·found,·creating·it·now...`,⏎········`

Check failure on line 84 in src/dataconnect/provisionCloudSql.ts

View workflow job for this annotation

GitHub Actions / unit (18)

Replace `"dataconnect",·`Database·${databaseId}·not·found,·creating·it·now...`` with `⏎··········"dataconnect",⏎··········`Database·${databaseId}·not·found,·creating·it·now...`,⏎········`
await cloudSqlAdminClient.createDatabase(projectId, instanceId, databaseId);
silent || utils.logLabeledBullet("dataconnect", `Database ${databaseId} created.`);
} else {
// Skip it if the database is not accessible.
// Possible that the CSQL instance is in the middle of something.
silent || utils.logLabeledWarning("dataconnect", `Database ${databaseId} is not accessible.`);
}
}
if (enableGoogleMlIntegration) {
await grantRolesToCloudSqlServiceAccount(projectId, instanceId, [GOOGLE_ML_INTEGRATION_ROLE]);
Expand Down

0 comments on commit 0ebdf26

Please sign in to comment.