Skip to content

Conversation

@jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Jun 24, 2022

Description

When payment is enabled, attribute all workspace instance usage to an explicitly selected "billing account".

TODO:

  • In the user's Billing settings, show all the teams that have usage-based billing enabled in a dropdown
  • Persist a user's selected "billing account"
  • When computing the usageAttributionId of a workspace instance, attribute based on the workspace owner's selected "billing account"

Follow-ups:

  • Auto-select "billing account" when there is no ambiguity (e.g. when a team upgrades to usage-based billing, also update all its users' usageAttributionId where it makes sense)
  • Auto-revert to user account when the team subscription is cancelled, or when the user leaves the team

Related Issue(s)

Fixes #10901

How to test

  1. Open a workspace with no project
  2. Create a project under your user (this automatically triggers a prebuild, so no need to also start a workspace)
  3. Create a Team A, with a Project A under it
  4. Create a Team B, with a Project B under it
  5. Verify attribution*:
    a. Workspace with no project --> your user
    b. Workspace with user project --> your user
    c. Workspace with Team A project --> your user
    d. Workspace with Team B project --> your user
  6. Now, enable usage-based billing for Team A, by adding a credit card for it (e.g 4242 4242 4242 4242, 4/24, 424)
  7. Next, in your user's Settings, go to the "Billing" page, and select "Team A" as a billing account (note: "Team B" should not be available, since it doesn't have usage-based billing enabled)
  8. Open a new workspace with no project
  9. Open a new workspace for your user project
  10. Open a new workspace for Project A
  11. Open a new workspace for Project B
  12. Verify attribution*:
    a. Workspace with no project --> team A
    b. Workspace with user project --> team A
    c. Workspace with Team A project --> team A
    d. Workspace with Team B project --> team A

*To verify attribution, open this PR in Gitpod, then run:

kubectl port-forward mysql-0 3306 &
mysql -h 127.0.0.1 -pjBzVMe2w4Yi7GagadsyB gitpod
mysql> select workspaceId, usageAttributionId, creationTime from d_b_workspace_instance order by creationTime;

Example output:

+-----------------------------------+-------------------------------------------+--------------------------+
| workspaceId                       | usageAttributionId                        | creationTime             |
+-----------------------------------+-------------------------------------------+--------------------------+
| autofixdev-autofix-vyof8v6yj9i    | user:a7dcf253-f05e-4dcf-9a47-cf8fccc74717 | 2022-06-24T13:13:34.254Z |
| jankeromnes-metachess-g7xzjycgnqj | team:8eba990a-4f1c-4233-b80f-c45330f81dd6 | 2022-06-24T13:14:41.517Z |
| jankeromnes-metaboard-9uzkqymxtz0 | team:8eba990a-4f1c-4233-b80f-c45330f81dd6 | 2022-06-24T13:15:04.492Z |
| jankeromnes-metachess-zwbh1q0jis4 | user:a7dcf253-f05e-4dcf-9a47-cf8fccc74717 | 2022-06-24T13:15:38.521Z |
+-----------------------------------+-------------------------------------------+--------------------------+

You can also verify every user's usageAttributionId preference like so:

mysql> select name, additionalData->"$.usageAttributionId" from d_b_user;
+--------------------------+---------------------------------------------+
| name                     | additionalData->"$.usageAttributionId"      |
+--------------------------+---------------------------------------------+
| jankeromnes              | "team:8eba990a-4f1c-4233-b80f-c45330f81dd6" |
| agent-smith              | NULL                                        |
| builtin-workspace-prober | NULL                                        |
+--------------------------+---------------------------------------------+

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview
  • /werft with-payment

@jankeromnes jankeromnes force-pushed the jx/billing-attribution branch 4 times, most recently from f6b577c to fa4ad76 Compare June 24, 2022 12:48
@roboquat roboquat added size/L and removed size/M labels Jun 24, 2022
@jankeromnes jankeromnes changed the title [Usage-based] When payment is enabled, attribute workspace instance usage based on new billing model [Usage-based] When payment is enabled, attribute all workspace instance usage to an expicitly selected "billing account" Jun 24, 2022
@jankeromnes jankeromnes changed the title [Usage-based] When payment is enabled, attribute all workspace instance usage to an expicitly selected "billing account" [Usage-based] When payment is enabled, attribute all workspace instance usage to an explicitly selected "billing account" Jun 24, 2022
@jankeromnes jankeromnes marked this pull request as ready for review June 24, 2022 13:53
@jankeromnes jankeromnes requested a review from a team June 24, 2022 13:53
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Jun 24, 2022
</Link>{" "}
to set up usage-based billing.
</p>
<div className="mt-8">
Copy link
Member

Choose a reason for hiding this comment

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

❤️

…fy a 'billing account' to attribute all their usage to
@jankeromnes jankeromnes force-pushed the jx/billing-attribution branch from 1320d58 to 898d9ed Compare June 27, 2022 14:00
Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Thank you, LGTM!

@roboquat roboquat merged commit 6afe081 into main Jun 27, 2022
@roboquat roboquat deleted the jx/billing-attribution branch June 27, 2022 14:11
@roboquat roboquat added the deployed: webapp Meta team change is running in production label Jun 28, 2022
@roboquat roboquat added the deployed Change is completely running in production label Jun 28, 2022
@AlexTugarev AlexTugarev mentioned this pull request Jul 21, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/L team: webapp Issue belongs to the WebApp team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Usage-based] When payment is enabled, attribute all workspace instance usage to an explicitly selected "billing account"

4 participants