-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Upgrades functions::list command to utilize Cloud Run API #9425
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @brittanycho, 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 refactors the Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
There was a problem hiding this 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 updates the functions:list command to use the Cloud Run API, which is a significant improvement. The implementation looks solid, with good test coverage for the new listServices function. I have a couple of suggestions to improve type safety and error logging.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this 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 successfully upgrades the functions::list command to use the Cloud Run API, which is a great improvement for supporting Cloud Run-based functions. I've found a critical issue where GCFv2 functions could be duplicated in the list, and I've provided a fix. I also have a minor suggestion to improve performance in the new listServices function. Overall, the changes are well-structured and the tests for the new functionality are thorough.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…d relevant tests for backend.ts, add tests to runv2.spec.ts, call listService with label for v2 functions
|
/gemini review |
There was a problem hiding this 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 is a great step forward in upgrading the functions::list command to utilize the Cloud Run API, ensuring all function types are listed. The changes are well-organized across the command, backend, and API client layers, and the new tests are a welcome addition. I have a couple of suggestions to enhance code clarity and robustness, mainly around simplifying endpoint de-duplication and improving the label filtering logic. Overall, this is a solid contribution.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
I see the tests are failing but seem unrelated to my current changes? will hopefully pass when re-syncing tomorrow |
|
/gemini review |
There was a problem hiding this 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 upgrades the functions::list command to use the Cloud Run API, which is a great enhancement for supporting Cloud Run-based functions. The changes are well-structured, including updates to the command itself, the backend logic for fetching functions, and the necessary API client code for Cloud Run. The error handling in functions-list.ts is a good addition for robustness.
I've found a couple of issues: one is a broken test being added, and the other is a minor maintainability concern that could lead to silent errors in the future. Please see my detailed comments.
| : { | ||
| eventTrigger: { | ||
| eventType: service.annotations?.[TRIGGER_TYPE_ANNOTATION] || "unknown", | ||
| retry: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is retry always false here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iiuc, I don't think the Cloud Run Service object stores info on retry policies so I don't think we'd be able to know the actual retry setting for a trigger? I didn't see any related fields in https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services#resource:-service
src/deploy/functions/backend.ts
Outdated
| "functions", | ||
| `Failed to list Cloud Run services: ${err.message}. Ensure you have the Cloud Run Admin API enabled and the necessary permissions.`, | ||
| ); | ||
| unreachableRegions.run = ["unknown"]; // Indicate that Run services could not be listed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit surprising. does the Run API not return list of unreacheable regions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I couldn't find anything in the services.list Service object or in other Cloud Run documentation through a google search but I could definitely be missing something - I will follow-up and ask in the Cloud Run Space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update on above here: https://chat.google.com/room/AAAA8PjxsIE/mgFct9F0k9I/mgFct9F0k9I?cls=10
Discussed further offline with Daniel and decided to move forward with this PR without unreachable regions and will add it back in later when it is fully deployed by cloud run
…loud-run-fns-list
|
/gemini review |
There was a problem hiding this 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 is a solid architectural improvement, upgrading the functions::list command to use the Cloud Run API for v2 functions. The changes make the command more robust, especially with the improved error handling that prevents crashes when listing functions fails. The code is generally clean and well-tested. My review focuses on further enhancing the robustness of error handling in a couple of places to prevent potential issues with unexpected error formats, and on improving the safety of error reporting to avoid leaking sensitive information.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
src/deploy/functions/backend.ts
Outdated
| logger.debug(err.message); | ||
| unreachableRegions.run = ["unknown"]; // Indicate that Run services could not be listed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: why do we ignore errors? e.g. what if 403 is thrown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidentally removed above, added back in. I think previous case only handled 404 - is this ok to keep as is or should I add 403 error handling as well?
src/deploy/functions/backend.spec.ts
Outdated
| } | ||
| context.unreachableRegions.run = ["region"]; | ||
|
|
||
| await expect(backend.checkAvailability(context, want)).to.eventually.be.rejectedWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm why does this test pass? i thought we don't call out to v2 api endpoint anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to remove all v2 references so now above should only refer to cloud run regions (and will also add a comment that unreachableRegions needs to be updated once Cloud Run team updates their API on this)
| const CLOUD_FUNCTION_V2: gcfV2.InputCloudFunction = { | ||
| name: "projects/project/locations/region/functions/id", | ||
| buildConfig: { | ||
| entryPoint: "function", | ||
| runtime: "nodejs16", | ||
| source: { | ||
| storageSource: CLOUD_FUNCTION_V2_SOURCE, | ||
| }, | ||
| environmentVariables: {}, | ||
| }, | ||
| serviceConfig: { | ||
| service: "projects/project/locations/region/services/service", | ||
| availableCpu: "1", | ||
| maxInstanceRequestConcurrency: 80, | ||
| }, | ||
| }; | ||
| const GCF_URL = "https://region-project.cloudfunctions.net/id"; | ||
| const HAVE_CLOUD_FUNCTION_V2: gcfV2.OutputCloudFunction = { | ||
| ...CLOUD_FUNCTION_V2, | ||
| serviceConfig: { | ||
| service: "service", | ||
| uri: GCF_URL, | ||
| availableCpu: "1", | ||
| maxInstanceRequestConcurrency: 80, | ||
| }, | ||
| url: GCF_URL, | ||
| state: "ACTIVE", | ||
| updateTime: new Date(), | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we replace this with equiavalent cloud run api response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Upgrades functions::list command to utilize Cloud Run API:
Upgrades by adding new function (listServices) to runV2.ts and defining trigger within endpointFromService function. Then listServices and endpointFromService are newly utilized in functions-list.ts so that this command now uses cloud run api