Skip to content

Conversation

fredzqm
Copy link
Contributor

@fredzqm fredzqm commented Aug 20, 2025

Description

firebase deploy will no longer hang due to Cloud SQL provision delay.

Similar to Firebase console, it would save the Cloud SQL metadata in FDC Schema, then starts a UpdateSchema(MIGRATE_COMPATIBLE) LRO to wait for Cloud SQL creation and setup SQL schema afterwards.

During the Cloud SQL provision window, firebase deploy would fail because there is a blocking LRO on Schema. That's expected. During that period, customers can still use the ephermeral database to prototype.

firebase init dataconnect

Screenshot 2025-08-20 at 11 46 51 AM

firebase deploy right after that

Screenshot 2025-08-20 at 11 47 23 AM

Update dataconnect.yaml and then run firebase deploy

Screenshot 2025-08-20 at 11 49 24 AM

firebase deploy Again

Screenshot 2025-08-20 at 11 49 58 AM

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @fredzqm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant improvements to the Firebase Data Connect deployment process, primarily by making Cloud SQL instance and database provisioning asynchronous. This change allows deployments to proceed more quickly, providing immediate feedback to the user while the Cloud SQL resources are being set up in the background, with data temporarily stored until the instance is ready. Beyond this core enhancement, the PR includes refactorings to simplify IAM user setup, clarifies logging messages during schema migrations, and refines deployment confirmation prompts for better user control and safety.

Highlights

  • Asynchronous Cloud SQL Provisioning: Cloud SQL instance and database creation during deployment are now asynchronous, allowing the deployment process to continue without waiting for these long-running operations to complete.
  • Simplified IAM User Setup: The setupIAMUsers function has been refactored to no longer require the databaseId parameter, streamlining its usage across the codebase.
  • Enhanced Schema Migration Logging: Logging messages related to schema generation and compatibility checks have been updated for improved clarity and user feedback.
  • Improved Cloud SQL Connection Management: The logic for ensuring service connectivity to Cloud SQL instances has been made more robust, including better handling of instance/database switching and the introduction of an ephemeral property for PostgreSQL datasources.
  • Refined Deployment Prompts: The confirmation prompt for deleting services not present in firebase.json has been adjusted, explicitly setting the force option to false and adding a default false response, preventing accidental deletions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Cloud SQL provisioning process to be asynchronous, which is a significant improvement for the user experience during deployment. The code is generally well-structured, with logic broken down into smaller, more manageable functions. I've identified a potential bug in the schema migration logic and an opportunity to refactor some duplicated code for better maintainability. My detailed feedback is in the comments below.

@fredzqm fredzqm requested a review from joehan August 20, 2025 02:37
let diffs: Diff[] = [];

// Make sure database is setup.
await setupSchemaIfNecessary(instanceId, databaseId, options);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NOTE: This should never be here.

firebase dataconnect:sql:diff must not mutate SQL state, as it's a read-only command.

setupSchemaIfNecessary may update some SQL schema.

`Only users with 'roles/cloudsql.admin' can grant SQL roles. If you do not have this role, ask your database administrator to run this command or manually grant ${fdcSqlRole} to ${user}`,
);
}
await ensureServiceIsConnectedToCloudSql(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this so that dataconnect:sql:grant would error out quick if Cloud SQL is still being created.

@@ -121,7 +120,6 @@ export async function setupSQLPermissions(
`Missing required IAM permission to setup SQL schemas. SQL schema setup requires 'roles/cloudsql.admin' or an equivalent role.`,
);
}
await setupIAMUsers(instanceId, databaseId, options);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was repetitive.

The caller is responsive to make sure IAM users are already setup.

It's used in two places, both with the same flow:

setupIAMUsers
getSchemaMetadata
setupSQLPermissions

Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

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

LGTM with some minor changelog fixes

@joehan joehan enabled auto-merge (squash) August 20, 2025 21:01
@joehan joehan merged commit 785536e into master Aug 20, 2025
48 checks passed
@joehan joehan deleted the fz/fdc-deploy branch August 20, 2025 21:45
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants