Skip to content

Use new stripe secret in preview environments #10563

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

Conversation

andrew-farries
Copy link
Contributor

@andrew-farries andrew-farries commented Jun 9, 2022

Description

Following on from #10552 which added the stripe-api-keys secret to preview environment clusters, this PR makes the server component use the secret and removes the old stripe-config secret from the repo.

Related Issue(s)

Part of #9036 and https://github.com/gitpod-io/ops/issues/2554

How to test

Manually trigger a werft job for this branch (Notion doc), setting with-payment=true.

Check that server is in a running state in the preview environment cluster and that it has successfully mounted the stripe-api-keys secret:

> kubectl describe pod <server pod>

Release Notes

NONE

@andrew-farries
Copy link
Contributor Author

/hold

@andrew-farries andrew-farries marked this pull request as ready for review June 9, 2022 16:12
@jankeromnes
Copy link
Contributor

jankeromnes commented Jun 9, 2022

Cool, many thanks @andrew-farries!

I want to try something:

/werft run github -j .werft/build.yaml -a with-payment=true -a updateGitHubStatus=gitpod-io/gitpod -f

👍 started the job as gitpod-build-af-use-stripe-secret-in-preview.2
(with .werft/ from main)

@jankeromnes
Copy link
Contributor

Well that didn't work.

I also tried running werft run github -j .werft/build.yaml -a with-payment=true -f in a Gitpod workspace, but this seems to have failed:

https://werft.gitpod-dev.com/job/gitpod-custom-af-use-stripe-secret-in-preview.1/raw

[Adding preview-specific configuration] STDERR: Error from server (Conflict): error when applying patch:
[Adding preview-specific configuration] {"metadata":{"creationTimestamp":"2022-06-09T09:57:08Z","resourceVersion":"289359424","uid":"17b131a5-96ae-4b78-9e82-b97211a41c31"}}
[Adding preview-specific configuration] to:
[Adding preview-specific configuration] Resource: "/v1, Resource=secrets", GroupVersionKind: "/v1, Kind=Secret"
[Adding preview-specific configuration] Name: "stripe-api-keys", Namespace: "default"
[Adding preview-specific configuration] for: "stripe-api-keys.secret.yaml": Operation cannot be fulfilled on secrets "stripe-api-keys": the object has been modified; please apply your changes to the latest version and try again
[deploy|FAIL] Error: Error: kubectl --kubeconfig "/workspace/gitpod/kubeconfigs/k3s" apply -f stripe-api-keys.secret.yaml exit with non-zero status code.

Did I do something wrong?

@andrew-farries
Copy link
Contributor Author

Does it work from a clean slate deployment?

@andrew-farries
Copy link
Contributor Author

Maybe the kubectl apply here:

exec(`kubectl --kubeconfig "${this.options.kubeconfigPath}" apply -f stripe-api-keys.secret.yaml`, { slice });

Should be a kubectl create to match here:

kubectl create secret generic "$providerId" \
--namespace "${this.options.deploymentNamespace}" \
--kubeconfig "${this.options.kubeconfigPath}" \
--from-literal=provider="$data" \
--dry-run=client -o yaml | \
kubectl --kubeconfig "${this.options.kubeconfigPath}" replace --force -f -

@andrew-farries
Copy link
Contributor Author

Looks like the kubectl apply is the problem. See here.

@andrew-farries andrew-farries force-pushed the af/use-stripe-secret-in-preview branch from 23346d1 to 4b1b513 Compare June 10, 2022 09:26
@andrew-farries andrew-farries force-pushed the af/create-stripe-secret-in-preview-env branch from 97c6a59 to 6248fa1 Compare June 10, 2022 09:26
@andrew-farries andrew-farries force-pushed the af/use-stripe-secret-in-preview branch 2 times, most recently from ba0dfbe to 5fad09b Compare June 10, 2022 10:27
@andrew-farries
Copy link
Contributor Author

This should be working now @jankeromnes. Could you try again?

@jankeromnes
Copy link
Contributor

Many thanks! Will give this another go.

By the way, the test instructions I tried in #10563 (comment) are still current, right?

@andrew-farries
Copy link
Contributor Author

Yes, if you run those same instructions again, I think the secret will apply properly this time.

@jankeromnes
Copy link
Contributor

jankeromnes commented Jun 10, 2022

Many thanks! 🙏 Okay, I tried again, and here is how far I got this time:

Build worked ✅ https://werft.gitpod-dev.com/job/gitpod-custom-af-use-stripe-secret-in-preview.4

The preview deployment seems to work ✅ https://af-use-strfbd5d8d72f.preview.gitpod-dev.com/workspaces

However, testing the Stripe integration didn't work:

  1. Create a Team called "Gitpod" (or "Gitpod1", "Gitpod2", etc -- first one that isn't already taken)
  2. Go to Team Billing
  3. Try to upgrade to Usage-Based by adding a payment method
Credit card input never appears Console shows these errors
Screenshot 2022-06-10 at 17 08 17 Screenshot 2022-06-10 at 17 08 40

Checking on the server pod, I get these relevant errors:

Could not load Stripe settings

Error: ENOENT: no such file or directory, open '/stripe/settings'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at loadAndCompleteConfig (/app/node_modules/@gitpod/server/dist/src/config.js:57:48)

Request getStripeSetupIntentClientSecret unsuccessful: 500/"Failed to create Stripe SetupIntent"

Error: Stripe is not properly configured
    at StripeService.getStripe (/app/node_modules/@gitpod/server/dist/ee/src/user/stripe-service.js:36:23)

Maybe there is something that needs to be adjusted so that the server can access the new secret values via the config? Sorry for not knowing much further here. 🙈

@andrew-farries andrew-farries requested a review from a team June 10, 2022 17:33
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Jun 10, 2022
@roboquat roboquat added size/M and removed size/S labels Jun 13, 2022
@andrew-farries andrew-farries force-pushed the af/use-stripe-secret-in-preview branch from 9f273fe to e38b5b0 Compare June 13, 2022 09:02
@andrew-farries andrew-farries requested review from a team June 13, 2022 09:02
@roboquat roboquat removed the size/M label Jun 13, 2022
@github-actions github-actions bot added team: IDE team: workspace Issue belongs to the Workspace team labels Jun 13, 2022
@andrew-farries andrew-farries force-pushed the af/use-stripe-secret-in-preview branch from e38b5b0 to 0ecee11 Compare June 13, 2022 09:05
@andrew-farries andrew-farries requested a review from a team June 13, 2022 09:05
@github-actions github-actions bot added the team: delivery Issue belongs to the self-hosted team label Jun 13, 2022
@andrew-farries andrew-farries force-pushed the af/create-stripe-secret-in-preview-env branch from 6248fa1 to c64d341 Compare June 13, 2022 09:07
@andrew-farries andrew-farries force-pushed the af/use-stripe-secret-in-preview branch from 0ecee11 to f18d132 Compare June 13, 2022 09:11
@roboquat roboquat added size/M and removed size/XXL labels Jun 13, 2022
@andrew-farries andrew-farries removed request for a team June 13, 2022 09:21
@andrew-farries andrew-farries force-pushed the af/use-stripe-secret-in-preview branch from f18d132 to fa85053 Compare June 13, 2022 09:39
Andrew Farries added 2 commits June 13, 2022 09:44
This now comes into clusters via GCP Secret Manager and terraform.
@andrew-farries andrew-farries force-pushed the af/use-stripe-secret-in-preview branch from fa85053 to 3deb771 Compare June 13, 2022 09:44
@andrew-farries
Copy link
Contributor Author

andrew-farries commented Jun 13, 2022

/werft run

👍 started the job as gitpod-build-af-use-stripe-secret-in-preview.14
(with .werft/ from main)

@andrew-farries
Copy link
Contributor Author

andrew-farries commented Jun 13, 2022

@jankeromnes This should be resolved now. The problem was the key in the secret data had changed from config to apikeys. As we discussed last week, we should use a secret for the keys and a configmap for other non-sensitive config, so I've renamed things here so that makes sense.

I've run through the steps in your comment and I can get to the payment UI.

Copy link
Contributor

@jankeromnes jankeromnes left a comment

Choose a reason for hiding this comment

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

Awesome, many thanks @andrew-farries!

Code looks good and works as advertised. ✅

Feel free to merge when you want, but I believe one line could still be removed in this PR. 🧹

/hold

Comment on lines 35 to 36
StripeSettingsFile string `json:"stripeSettingsFile"`
StripeSecretsFile string `json:"stripeSecretsFile"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the line above be removed?

Suggested change
StripeSettingsFile string `json:"stripeSettingsFile"`
StripeSecretsFile string `json:"stripeSecretsFile"`
StripeSecretsFile string `json:"stripeSecretsFile"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think you are right. It will probably come back again in another PR but let's remove it for now.

7da5eab

@andrew-farries
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit 1ddaa16 into af/create-stripe-secret-in-preview-env Jun 13, 2022
@roboquat roboquat deleted the af/use-stripe-secret-in-preview branch June 13, 2022 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/M team: delivery Issue belongs to the self-hosted team team: IDE team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants