Skip to content

[server] Cleanup around EntitlementService and BillingMode #18429

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

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

geropl
Copy link
Member

@geropl geropl commented Aug 3, 2023

Description

Blocked by: #18412

This PR refactors the EntitlementService interface, which we did not follow up on after our move to Stripe, but is in the way of some refactorings around GitpodServerImpl and WorkspaceStarter.

This does container a "breaking change", though: We take away some features in non-paid orgs (details)

Summary generated by Copilot

🤖 Generated by Copilot at bd7191c

This pull request refactors and simplifies some of the code related to billing and entitlement logic in the server component. It removes unused or redundant parameters, imports, and code, and uses more consistent and concise method calls. It affects the files billing-mode.ts, entitlement-service-ubp.ts, entitlement-service.ts, gitpod-server-impl.ts, workspace-starter.ts, and prebuild-manager.ts.

Related Issue(s)

Fixes #

How to test

Documentation

Preview status

gitpod:summary

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@@ -33,7 +32,7 @@ export class BillingModes {
return { mode: "usage-based", paid };
}

async getBillingModeForUser(user: User, now: Date): Promise<BillingMode> {
async getBillingModeForUser(): Promise<BillingMode> {
Copy link
Member

Choose a reason for hiding this comment

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

getBillingModeForUser without any user context looks pretty odd from the outside. Do we need this method at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a comment, and explicitly marked it as deprecated now. All we really need to do is add orgnaizationId to api.maySetTimeout and api.updateWorkspaceTimeoutSetting, then we can remove it entirely.

// gpl: Because with the current payment handling (pay-after-use) having a "paid" plan is not a good enough classifier for trushworthyness atm.
// We're looking into improving this, but for the meantime we limit network connections for everybody to reduce the impact of abuse.
return true;
}

private async hasPaidSubscription(user: User, date: Date): Promise<boolean> {
private async hasPaidSubscription(userId: string, organizationId?: string): Promise<boolean> {
if (organizationId) {
Copy link
Member

Choose a reason for hiding this comment

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

This is good and we should even aim for making the organization mandatory, but it is a breaking change. For instance, users who were able to change timeouts on workspaces running on their free org (but have another paid org) can now no longer do this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly. But sharpening that behavior is sth we should have done all along, right after the migration to Stripe.

Copy link
Member

@svenefftinge svenefftinge left a comment

Choose a reason for hiding this comment

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

I like this change and believe we can just roll it out. I would even consider it a bug that I would have all these paid features on a non-paid org before. So thanks for fixing! :-)

@geropl geropl force-pushed the gpl/fga-workspace-3 branch from 2be105e to 5777c75 Compare August 4, 2023 14:15
@roboquat roboquat added size/XXL and removed size/L labels Aug 4, 2023
@geropl geropl force-pushed the gpl/fga-workspace-4 branch from bd7191c to 8d05a11 Compare August 4, 2023 14:41
@roboquat roboquat added size/L and removed size/XXL labels Aug 4, 2023
@geropl geropl force-pushed the gpl/fga-workspace-4 branch from 8d05a11 to 415e2f7 Compare August 4, 2023 14:49
@geropl geropl marked this pull request as ready for review August 4, 2023 14:52
@geropl geropl requested a review from a team as a code owner August 4, 2023 14:52
@JennPlothow JennPlothow mentioned this pull request Aug 5, 2023
@svenefftinge svenefftinge merged commit ff88306 into gpl/fga-workspace-3 Aug 7, 2023
@svenefftinge svenefftinge deleted the gpl/fga-workspace-4 branch August 7, 2023 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants