Skip to content
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

[GCP] Private Endpoint Support #417

Merged
merged 18 commits into from
Jul 23, 2024
Merged

Conversation

smcclure20
Copy link
Collaborator

@smcclure20 smcclure20 commented Jul 4, 2024

[Update] Closed #435 and merged it into this PR. Originally, this PR used the URI of the service attachment for later references of the PSC (ex, adding/removing rules on it). However, since Google services do not have a service attachment, I changed the returned URI to be the forwarding rule that implements the PSC. Users shouldn't even have to use this URI since they can refer to the connection via its name and the tag service will map that to the URI.

Completes the GCP portion of #394

Anticipated UI
For a minimal change to the existing user interface and in alignment with our discussions on the API, this does not require any front-end changes. Instead, users should send requests for private service connections (PSCs) by sending a CreateResource request with the description having one field: "url" which provides the URL of the service attachment to connect to (https://cloud.google.com/vpc/docs/configure-private-service-connect-services)

We can revisit this as needed as we implement for other clouds.

Also in this PR

  • Some cleanup of resources.go
  • Creation of a clients struct (like Azure) so that functions do not have to have arguments for each client that may be necessary (this became especially bad as each supported resource requires different -- and potentially many -- clients, but they all have to match the same interface)

@smcclure20 smcclure20 requested a review from a team as a code owner July 4, 2024 00:01
@smcclure20 smcclure20 marked this pull request as draft July 4, 2024 00:01
Copy link

github-actions bot commented Jul 4, 2024

Unit Test Results

309 tests  +4   309 ✅ +4   4s ⏱️ +2s
 49 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit afdaf96. ± Comparison against base commit 9287b6a.

This pull request removes 8 and adds 12 tests. Note that renamed tests count towards both.
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetVnetsWithMatchingPrefixAddressSpaces
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetVnetsWithMatchingPrefixAddressSpaces/GetAllVnetsAddressSpaces:_Failure_-_No_Vnet
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetVnetsWithMatchingPrefixAddressSpaces/GetAllVnetsAddressSpaces:_Failure_-_wrong_name
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetVnetsWithMatchingPrefixAddressSpaces/GetAllVnetsAddressSpaces:_Success
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestGKECreateWithNetwork
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestGKEFromResourceDecription
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestGKEGetNetworkInfo
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestGKEGetResourceInfo
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetAllVnetsAddressSpaces
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetAllVnetsAddressSpaces/GetAllVnetsAddressSpaces:_Failure_-_No_Vnet
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetAllVnetsAddressSpaces/GetAllVnetsAddressSpaces:_Failure_-_wrong_namespace
github.com/paraglider-project/paraglider/pkg/azure ‑ TestGetAllVnetsAddressSpaces/GetAllVnetsAddressSpaces:_Success
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestClusterCreateWithNetwork
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestClusterFromResourceDecription
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestClusterGetNetworkInfo
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestClusterGetResourceInfo
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestPrivateServiceCreateWithNetwork
github.com/paraglider-project/paraglider/pkg/gcp ‑ TestPrivateServiceGetNetworkInfo
…

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 4, 2024

50.9

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 50.9 %
  • main branch coverage: 0 %
  • diff coverage: 50.9 %

The coverage result does not include the functional test results.

@smcclure20 smcclure20 temporarily deployed to functional-tests July 8, 2024 23:04 — with GitHub Actions Inactive
@smcclure20 smcclure20 marked this pull request as ready for review July 8, 2024 23:04
Copy link

github-actions bot commented Jul 8, 2024

50.9

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 50.9 %
  • main branch coverage: 0 %
  • diff coverage: 50.9 %

The coverage result does not include the functional test results.

@smcclure20 smcclure20 temporarily deployed to functional-tests July 9, 2024 00:47 — with GitHub Actions Inactive
Copy link

github-actions bot commented Jul 9, 2024

51.0

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 51.0 %
  • main branch coverage: 0 %
  • diff coverage: 51.0 %

The coverage result does not include the functional test results.

@smcclure20 smcclure20 temporarily deployed to functional-tests July 9, 2024 01:45 — with GitHub Actions Inactive
Copy link

github-actions bot commented Jul 9, 2024

51.0

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 51.0 %
  • main branch coverage: 0 %
  • diff coverage: 51.0 %

The coverage result does not include the functional test results.

Signed-off-by: Sarah McClure <[email protected]>
@smcclure20 smcclure20 temporarily deployed to functional-tests July 9, 2024 20:40 — with GitHub Actions Inactive
Copy link

github-actions bot commented Jul 9, 2024

51.0

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 51.0 %
  • main branch coverage: 0 %
  • diff coverage: 51.0 %

The coverage result does not include the functional test results.

@smcclure20 smcclure20 temporarily deployed to functional-tests July 10, 2024 21:31 — with GitHub Actions Inactive
Signed-off-by: Sarah McClure <[email protected]>
@smcclure20 smcclure20 temporarily deployed to functional-tests July 10, 2024 22:01 — with GitHub Actions Inactive
Copy link

51.5

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 51.5 %
  • main branch coverage: 0 %
  • diff coverage: 51.5 %

The coverage result does not include the functional test results.

Copy link
Collaborator

@seankimkdy seankimkdy left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @smcclure20! Mostly looks good although I'm very new to services in general so it may be helpful for someone like @praveingk or @divega to look at this at a higher level. I left comments mostly about code.

Is it possible to have an integration test for this? Would definitely be helpful to see a barebones example even if it's contrived. But also understand if this is like our k8s example where it's hard to implement an integration test.

clusterNameFormat = "projects/%s/locations/%s/clusters/%s"
clusterTypeName = "cluster"
instanceTypeName = "instance"
serviceAttachmentTypeName = "serviceAttachment"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find the serviceAttachment as a resource to be confusing, since serviceAttachment is just the target URL of a service, and create function creates a forwarding rule which triggers creation of Private Service Connect endpoints which connects to an existing service attachment url.
Should this be called endpointConnectType to be more specific and common across clouds?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, that's fair. The main reason I kept it as serviceAttachment is due to how it is used in like 142. We have to look at the URL for its type (serviceAttachment) and I thought it was best to be consistent. I could see an argument for renaming the handler though as you mention below.

} else if err := json.Unmarshal(resourceDesc, createClusterRequest); err == nil && createClusterRequest.Cluster != nil {
return &gcpGKE{}, nil
return &clusterHandler{}, nil
} else if err := json.Unmarshal(resourceDesc, serviceAttachment); err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we check if the request is a proper service URL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should do type-specific checks like this in getResourceInfo. I'll add that.

return handler, nil
handler = &clusterHandler{}
} else if resourceType == serviceAttachmentTypeName {
handler = &privateServiceHandler{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. We are returning privateService handler from serviceAttachmentType.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Elaborating a bit more from the above: I think this just reflects the underlying cloud abstractions. We are creating a private service connect, but to do that, we need the URL of a service attachment.

@praveingk
Copy link
Collaborator

Thanks for adding this support. I have reviewed and posted some suggestions.

Signed-off-by: Sarah McClure <[email protected]>
Signed-off-by: Sarah McClure <[email protected]>
@smcclure20 smcclure20 temporarily deployed to functional-tests July 17, 2024 19:01 — with GitHub Actions Inactive
Copy link

51.5

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 51.5 %
  • main branch coverage: 0 %
  • diff coverage: 51.5 %

The coverage result does not include the functional test results.

Address string
}

type ServiceAttachmentDescription struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the definition of ServiceAttachmentDescription is defined in paraglider scope and not GCP, may be we need to define it somewhere, when we document private endpoint support. Just noting it here :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, we definitely should include it in the docs about this.

@smcclure20 smcclure20 temporarily deployed to functional-tests July 22, 2024 18:54 — with GitHub Actions Inactive
@smcclure20 smcclure20 requested a review from seankimkdy July 22, 2024 18:54
Copy link

51.5

For the detailed report, please go to Checks tab, click Build and Test, and then download unit_test_coverage artifact at the bottom of build page.

  • Your PR branch coverage: 51.5 %
  • main branch coverage: 0 %
  • diff coverage: 51.5 %

The coverage result does not include the functional test results.

@smcclure20 smcclure20 merged commit e61c0ba into main Jul 23, 2024
10 checks passed
@smcclure20 smcclure20 deleted the smcclure20/private-endpoint-support branch July 23, 2024 16:39
praveingk pushed a commit that referenced this pull request Jul 30, 2024
* initial outline of psc support

Signed-off-by: Sarah McClure <[email protected]>

* created clients struct for convenience and competed switch to PSC endpoint-based implementation

Signed-off-by: Sarah McClure <[email protected]>

* lint passing and tests mostly written for service support

Signed-off-by: Sarah McClure <[email protected]>

* most tests written, all passing

Signed-off-by: Sarah McClure <[email protected]>

* cleanup and add a few tests

Signed-off-by: Sarah McClure <[email protected]>

* fix target type for rules for service accounts and how URLs are read

Signed-off-by: Sarah McClure <[email protected]>

* initial setup for google service support

Signed-off-by: Sarah McClure <[email protected]>

* change workload env variable name to match new actions

Signed-off-by: Sarah McClure <[email protected]>

* fix firewall naming

Signed-off-by: Sarah McClure <[email protected]>

* initial implementation; needs testing

Signed-off-by: Sarah McClure <[email protected]>

* fix build issues

Signed-off-by: Sarah McClure <[email protected]>

* respond to review comments

Signed-off-by: Sarah McClure <[email protected]>

* fix tests

Signed-off-by: Sarah McClure <[email protected]>

* make the paraglider label a constant

Signed-off-by: Sarah McClure <[email protected]>

---------

Signed-off-by: Sarah McClure <[email protected]>
Signed-off-by: smcclure20 <[email protected]>
Signed-off-by: Pravein-Govindan-Kannan <[email protected]>
J-467 pushed a commit that referenced this pull request Aug 6, 2024
* initial outline of psc support

Signed-off-by: Sarah McClure <[email protected]>

* created clients struct for convenience and competed switch to PSC endpoint-based implementation

Signed-off-by: Sarah McClure <[email protected]>

* lint passing and tests mostly written for service support

Signed-off-by: Sarah McClure <[email protected]>

* most tests written, all passing

Signed-off-by: Sarah McClure <[email protected]>

* cleanup and add a few tests

Signed-off-by: Sarah McClure <[email protected]>

* fix target type for rules for service accounts and how URLs are read

Signed-off-by: Sarah McClure <[email protected]>

* initial setup for google service support

Signed-off-by: Sarah McClure <[email protected]>

* change workload env variable name to match new actions

Signed-off-by: Sarah McClure <[email protected]>

* fix firewall naming

Signed-off-by: Sarah McClure <[email protected]>

* initial implementation; needs testing

Signed-off-by: Sarah McClure <[email protected]>

* fix build issues

Signed-off-by: Sarah McClure <[email protected]>

* respond to review comments

Signed-off-by: Sarah McClure <[email protected]>

* fix tests

Signed-off-by: Sarah McClure <[email protected]>

* make the paraglider label a constant

Signed-off-by: Sarah McClure <[email protected]>

---------

Signed-off-by: Sarah McClure <[email protected]>
Signed-off-by: smcclure20 <[email protected]>
Signed-off-by: Julian Tweneboa Kodua <[email protected]>

Signed-off-by: Julian Tweneboa Kodua <[email protected]>
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.

4 participants