-
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
| "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/commands/functions-list.ts
Outdated
| endpoints = backend.allEndpoints(existing); | ||
| } catch (err: any) { | ||
| logger.debug(`Failed to list functions:`, err); | ||
| logger.warn(err.message); |
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 should we warn or err?
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.
also, if we are not doing anything useful with the returned error, removing the try/cactch block and letting the CLI just throw the error is an option
src/deploy/functions/backend.spec.ts
Outdated
|
|
||
| describe("existing backend", () => { | ||
| let listAllFunctions: sinon.SinonStub; | ||
| let listAllFunctionsV2: sinon.SinonStub; |
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 remove this stub as well?
src/deploy/functions/backend.spec.ts
Outdated
| beforeEach(() => { | ||
| listAllFunctions = sinon.stub(gcf, "listAllFunctions").rejects("Unexpected call"); | ||
| listAllFunctionsV2 = sinon.stub(gcfV2, "listAllFunctions").rejects("Unexpected v2 call"); | ||
| listServices = sinon.stub(runv2, "listServices").resolves([]); |
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.
should call .reject() like other stubs
| listAllFunctionsV2.onFirstCall().resolves({ | ||
| functions: [], | ||
| unreachable: [], | ||
| }); |
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.
instead of deleting this, can we have it return empty run services (goes w/ changing runStub to reject in the before() setup
| 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?
| } | ||
| 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
| ); | ||
| const neededUnreachableV2 = context.unreachableRegions?.gcfV2.filter((region) => | ||
| const neededUnreachableV2 = context.unreachableRegions?.run.filter((region) => | ||
| gcfV2Regions.has(region), |
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.
should we rename this var or no?
| - [Added] support for new google-genai plugin during `init genkit` (#8957) | ||
| - Updated to v2.17.1 of the Data Connect emulator, which fixes an admin SDK bug for operation without argument #9449 (#9454). | ||
| - Upgraded functions::list command to use cloud run api for v2 functions (#9425) |
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.
remove and add our own changelist bullet?
Co-authored-by: Daniel Lee <[email protected]>
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