-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] Store credits as integer values in the usage table #11429
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
started the job as gitpod-build-af-integer-credit-values-in-usage-store.2 because the annotations in the pull request description changed |
No data to preserve so drop and recreate the table.
42c1489
to
4be8d13
Compare
|
/werft run with-preview=true with-clean-slate-deployment=true 👍 started the job as gitpod-build-af-integer-credit-values-in-usage-store.6 |
Changed to I think this is unnecessarily large though, but it's now consistent with the type used elsewhere. |
My understanding was that we have to report total usage to Stripe as an int, but we should collect usage per session in fractional units to avoid rounding errors. |
Indeed, the stored value should remain a float. This is because only the total billed value should be rounded, not each workspace instance. |
Regular workspace costs 1 credit per 6 minutes, there's no way we'd be able to express workspace that ran for 5 minutes, or other fractions in this way. |
In that case, I believe we are incorrectly rounding in the billing data sent to Stripe: gitpod/components/usage/pkg/controller/reconciler.go Lines 143 to 146 in a86efd2
Here we round each workspace instance's credits, rather than rounding the total once at the end. |
Description
Workspace credits per minute can be configured as fractional values, but we always want to bill and display usage in whole numbers of credits. This PR changes the type of the field that stores credits consumed per workspace instance to be an integer.
Related Issue(s)
Part of #9036 and this comment on #11406.
How to test
Connect to the database for the preview and describe the
d_b_workspace_instance_usage
table:Release Notes
Documentation
Werft options: