Add Google Cloud Compute services
What does this MR do and why?
Add Google Cloud Compute services
Adds 3 services for to interact with Google Cloud Compute. These services are gated behind a SaaS-only feature.
Basically, they will build and use the client class but also provide data conversions and additional validations. Among others, check a feature flag.
We have 3 functions that the client exposes, so naturally, we split that into 3 services:
- list regions
- list zones
- list machine types
All 3 services will have a similar validation and error handling, thus we have a base class that will centralize the common logic.
The main user of these services will be GraphQL endpoints (implemented in different MRs).
NOTE: This MR is inspired from David's !143359 (merged) (which does the same for Artifact Registry).
Closes #439569 (closed)

What does this MR do and why?

- Add 3 services:
-
GoogleCloudPlatform::Compute::ListRegionsService
. -
GoogleCloudPlatform::Compute::ListZonesService
. -
GoogleCloudPlatform::Compute::ListMachineTypesService
.
-
- Add a base (common parent) service class:
GoogleCloudPlatform::Compute::BaseService
. - Add the related specs.
The feature is hidden behind the gcp_runner
FF: #437901 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

These are services so, hu... no impact on the existing UI

How to set up and validate locally


Setup

Local testing is a bit involved as we need to have an Artifact Registry set up and some other things for the authentication part. Follow !143099 (merged), points
Now, we need to set up the Artifact registry integration. Follow the instructions from !141127 (merged).
Enable the gcp_artifact_registry
and gcp_runner
feature flags:
$ echo "Feature.enable(:gcp_artifact_registry); Feature.enable(:gcp_runner, type: :wip)" | gdk rails console
All the examples below are to be executed in the rails console and you will need the project_id
on which you set up the integration and a user with read_runner_cloud_provisioning_options
permission (maintainer
+).

Get machine types

GoogleCloudPlatform::Compute::ListRegionsService.new(project: Project.find(<project_id>), current_user: User.first, max_results: 2).execute
=> #<ServiceResponse:0x0000000299017bd8
@http_status=:ok,
@message=nil,
@payload={:items=>[{:name=>"africa-south1", :description=>"africa-south1"}, {:name=>"asia-east1", :description=>"asia-east1"}], :next_page_token=>"Cgphc2lhLWVhc3Qx"},
@reason=nil,
@status=:success>

List zones

GoogleCloudPlatform::Compute::ListZonesService.new(project: Project.find(<project_id>), current_user: User.first).execute
=> #<ServiceResponse:0x0000000299014b18
@http_status=:ok,
@message=nil,
@payload={:items=>[{:name=>"africa-south1-b", :description=>"africa-south1-b"}, {:name=>"africa-south1-c", :description=>"africa-south1-c"}], :next_page_token=>"Cg9hZnJpY2Etc291dGgxLWI="},
@reason=nil,
@status=:success>

List machine types

> GoogleCloudPlatform::Compute::ListMachineTypesService.new(project: Project.find(43), current_user: User.first, zone: "us-west1-a", max_results: 2).execute
=> #<ServiceResponse:0x00000002a0130568
@http_status=:ok,
@message=nil,
@payload=
{:items=>
[{:name=>"c2-standard-16", :description=>"Compute Optimized: 16 vCPUs, 64 GB RAM", :zone=>"us-west1-a"},
{:name=>"c2-standard-30", :description=>"Compute Optimized: 30 vCPUs, 120 GB RAM", :zone=>"us-west1-a"}],
:next_page_token=>"Cg5jMi1zdGFuZGFyZC0zMA=="},
@reason=nil,
@status=:success>
> GoogleCloudPlatform::Compute::ListMachineTypesService.new(project: Project.find(43), current_user: User.first, zone: "us-west1-a", max_results: 2, page_token: "Cg5jMi1zdGFuZGFyZC0zMA==").execute
=> #<ServiceResponse:0x000000029fabf238
@http_status=:ok,
@message=nil,
@payload=
{:items=>
[{:name=>"c2-standard-4", :description=>"Compute Optimized: 4 vCPUs, 16 GB RAM", :zone=>"us-west1-a"},
{:name=>"c2-standard-60", :description=>"Compute Optimized: 60 vCPUs, 240 GB RAM", :zone=>"us-west1-a"}],
:next_page_token=>"Cg5jMi1zdGFuZGFyZC02MA=="},
@reason=nil,
@status=:success>

Handling errors

Let's play around with erroneous calls:
GoogleCloudPlatform::Compute::ListRegionsService.new(project: Project.find(<project id>), current_user: User.first, order_by: 'id desc').execute
=> #<ServiceResponse:0x00000002a00157f0 @http_status=nil, @message="Invalid order_by value", @payload={}, @reason=nil, @status=:error>
GoogleCloudPlatform::Compute::ListMachineTypesService.new(project: Project.find(43), current_user: User.first, zone: "us-west1")
=> #<ServiceResponse:0x0000000322a5dde8
@http_status=nil,
@message="Unsuccessful Google Cloud API request: An error has occurred when making a REST request: Invalid value for field 'zone': 'us-west1'. Unknown zone.",
@payload={},
@reason=nil,
@status=:error>
Let's list regions on a project that doesn't have the integration configured:
GoogleCloudPlatform::Compute::ListRegionsService.new(project: Project.find(44), current_user: User.first, order_by: 'id desc').execute
=> #<ServiceResponse:0x0000000319e9c188 @http_status=nil, @message="Project Artifact Registry integration not set", @payload={}, @reason=nil, @status=:error>
Merge request reports
Activity
added devopsverify grouprunner sectionci + 1 deleted label
assigned to @pedropombeiro
changed milestone to %16.9
7 Warnings This merge request is quite big (561 lines changed), please consider splitting it into multiple merge requests. c66698a5: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines. 57ebe877: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines. fa6b2dca: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines. 18f68a8f: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines. e0255fdd: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines. featureaddition and featureenhancement merge requests normally have a documentation change. Consider adding a documentation update or confirming the documentation plan with the Technical Writer counterpart.
For more information, see:
- The Handbook page on merge request types.
- The definition of done documentation.
1 Message CHANGELOG missing: If this merge request needs a changelog entry, add the
Changelog
trailer to the commit message you want to add to the changelog.If this merge request doesn't need a CHANGELOG entry, feel free to ignore this message.
Reviewer roulette
Category Reviewer Maintainer backend @radbatnag
(UTC+8, 7 hours ahead of author)
@aakriti.gupta
(UTC+5.5, 4.5 hours ahead of author)
~"Authorization" Reviewer review is optional for ~"Authorization" @mokhax
(UTC-7, 8 hours behind author)
Please check reviewer's status!
Please refer to documentation page for guidance on how you can benefit from the Reviewer Roulette, or use the GitLab Review Workload Dashboard to find other available reviewers.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
DangerE2E Test Result Summary
allure-report-publisher
generated test report!e2e-test-on-gdk:
test report for 3c961e3bexpand test summary
+------------------------------------------------------------------+ | suites summary | +-------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +-------------+--------+--------+---------+-------+-------+--------+ | Verify | 31 | 0 | 0 | 0 | 31 | ✅ | | Create | 8 | 0 | 3 | 0 | 11 | ✅ | | Govern | 3 | 0 | 0 | 0 | 3 | ✅ | | Package | 0 | 0 | 1 | 0 | 1 | ➖ | | Monitor | 4 | 0 | 0 | 0 | 4 | ✅ | | Plan | 4 | 0 | 0 | 0 | 4 | ✅ | | Data Stores | 0 | 0 | 2 | 0 | 2 | ➖ | +-------------+--------+--------+---------+-------+-------+--------+ | Total | 50 | 0 | 6 | 0 | 56 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+
e2e-package-and-test:
test report for 3c961e3bexpand test summary
+------------------------------------------------------------------+ | suites summary | +-------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +-------------+--------+--------+---------+-------+-------+--------+ | Verify | 138 | 0 | 27 | 0 | 165 | ✅ | | Create | 148 | 0 | 24 | 4 | 172 | ✅ | | Package | 0 | 0 | 2 | 0 | 2 | ➖ | | Monitor | 8 | 0 | 0 | 0 | 8 | ✅ | | Data Stores | 0 | 0 | 4 | 0 | 4 | ➖ | | Govern | 6 | 0 | 0 | 0 | 6 | ✅ | | Plan | 8 | 0 | 0 | 0 | 8 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+ | Total | 308 | 0 | 57 | 4 | 365 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+
added feature flagexists label
- Resolved by Dzmitry (Dima) Meshcharakou
Hey @dmeshcharakou
, mind doing the backend initial review?
requested review from @dmeshcharakou
added 55 commits
-
b1e3f584...9c02f034 - 54 commits from branch
master
- 6ea2f839 - Add Google Cloud Compute services
-
b1e3f584...9c02f034 - 54 commits from branch
requested review from @10io and removed review request for @dmeshcharakou
added 57 commits
-
6ea2f839...eafb8d88 - 56 commits from branch
master
- a7701725 - Add Google Cloud Compute services
-
6ea2f839...eafb8d88 - 56 commits from branch
added 92 commits
-
41b90ae6...72f669eb - 91 commits from branch
master
- 5f837dc1 - Add Google Cloud Compute services
-
41b90ae6...72f669eb - 91 commits from branch
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro
- Resolved by David Fernandez
- Resolved by Pedro Pombeiro
removed review request for @10io
requested review from @10io
added 70 commits
-
8982f3e0...70a65dde - 68 commits from branch
master
- 007a16ef - Add Google Cloud Compute services
- 1f8eb8a7 - Address MR review comments
-
8982f3e0...70a65dde - 68 commits from branch
added 109 commits
-
a201716e...2d92f25b - 105 commits from branch
master
- 45e52801 - Add Google Cloud Compute services
- fcbefa7a - Address MR review comments
- 61e9ebf5 - Use nil default for max_results
- 9986539e - Pass arguments in constructor
Toggle commit list-
a201716e...2d92f25b - 105 commits from branch
mentioned in merge request !143214 (merged)
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro
- Resolved by Pedro Pombeiro