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

CLOUDP-167207: Validate GCP Service Account Key #1008

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

josvazg
Copy link
Collaborator

@josvazg josvazg commented Jun 26, 2023

All Submissions:

  • Have you signed our CLA?
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if there is one).
  • Update docs/release-notes/release-notes.md if your changes should be included in the release notes for the next release.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 26, 2023

@josvazg josvazg force-pushed the CLOUDP-167207/validate-gcp-sa-key branch 7 times, most recently from fd210c4 to 0d9851b Compare June 27, 2023 08:07
Copy link
Collaborator

@helderjs helderjs left a comment

Choose a reason for hiding this comment

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

Overall looks good, just have a few comments and 2 extra thoughts:

  1. Does it make sense to have an e2e test to see how an escaped string from an applied yaml would go through the validation?

  2. Talking to @igor-karpukhin, we were wondering if makes sense to validate the entire service account object, once Atlas API will check it is really valid and can be used to connect to GCPP.

pkg/controller/validate/validate.go Outdated Show resolved Hide resolved
pkg/controller/validate/validate.go Show resolved Hide resolved
pkg/controller/validate/validate.go Outdated Show resolved Hide resolved
@josvazg
Copy link
Collaborator Author

josvazg commented Jun 28, 2023

Overall looks good, just have a few comments and 2 extra thoughts:

  1. Does it make sense to have an e2e test to see how an escaped string from an applied yaml would go through the validation?
  2. Talking to @igor-karpukhin, we were wondering if makes sense to validate the entire service account object, once Atlas API will check it is really valid and can be used to connect to GCPP.

I am doing some manual testing at the moment before I decide how to proceed there. I am hesitant to add up more to our slow and flaky e2e tests, unless for a very good reason that has no better alternative.

I think the validation against the API was not the initial idea. We could do that, even before we deploy anything in the cloud. And that could be a fast e2e test as it is a single check and does not require a cloud resource deployment to take place beforehand.

@josvazg josvazg force-pushed the CLOUDP-167207/validate-gcp-sa-key branch 4 times, most recently from 8f1e6a6 to a97952c Compare June 30, 2023 11:30
@josvazg
Copy link
Collaborator Author

josvazg commented Jun 30, 2023

Overall looks good, just have a few comments and 2 extra thoughts:

  1. Does it make sense to have an e2e test to see how an escaped string from an applied yaml would go through the validation?
  2. Talking to @igor-karpukhin, we were wondering if makes sense to validate the entire service account object, once Atlas API will check it is really valid and can be used to connect to GCPP.

In the end I added the same tests as e2e test as well, but the happy path case is using the format that we can recommend to end users when setting up the keys, just take the service account JSON file from Google and put it, as is, in the CRD YAML as a multiline attribute:

apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
  name: my-project
spec:
  name: Test Atlas Operator Project
  encryptionAtRest:
    googleCloudKms:
      enabled: true
      keyVersionResourceID: projects/...
      serviceAccountKey: |
        {
          "type": "service_account",
          "project_id": "...",
          ...
        }

The only caveat is to respect the indentation, as seen in the example, so that the YAML format knows this file is a document for serviceAccountKey

.github/workflows/test-e2e.yml Outdated Show resolved Hide resolved
pkg/controller/validate/validate.go Outdated Show resolved Hide resolved
pkg/controller/validate/validate.go Outdated Show resolved Hide resolved
test/e2e/encryption_at_rest_test.go Show resolved Hide resolved
test/e2e/encryption_at_rest_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@igor-karpukhin igor-karpukhin left a comment

Choose a reason for hiding this comment

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

Looks good in general 👍 , but let's not separate this test from other "encryption-at-rest" tests

.github/workflows/test-e2e.yml Outdated Show resolved Hide resolved
pkg/controller/validate/validate.go Outdated Show resolved Hide resolved
pkg/controller/validate/validate.go Show resolved Hide resolved
test/e2e/encryption_at_rest_test.go Outdated Show resolved Hide resolved
test/e2e/encryption_at_rest_test.go Outdated Show resolved Hide resolved
@josvazg josvazg force-pushed the CLOUDP-167207/validate-gcp-sa-key branch from a97952c to de01e8d Compare July 3, 2023 08:37
test/e2e/encryption_at_rest_test.go Outdated Show resolved Hide resolved
@josvazg josvazg force-pushed the CLOUDP-167207/validate-gcp-sa-key branch from de01e8d to 80ac13c Compare July 3, 2023 14:21
@josvazg josvazg requested a review from helderjs July 3, 2023 14:22
Copy link
Collaborator

@helderjs helderjs left a comment

Choose a reason for hiding this comment

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

Good work!

Copy link
Collaborator

@igor-karpukhin igor-karpukhin left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@josvazg josvazg merged commit c18f5cf into main Jul 4, 2023
38 checks passed
@josvazg josvazg deleted the CLOUDP-167207/validate-gcp-sa-key branch July 4, 2023 06:16
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.

3 participants