Skip to content

[server] Introduce EntitlementServiceChargbee and move relevant parts of EligibilityService into it #11831

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 4, 2022

Conversation

geropl
Copy link
Member

@geropl geropl commented Aug 3, 2022

Description

This PR does two things, while not touching current behavior:

  • it introduces the EntitlementService interface, which is based on a subset of methods of EligibilityService
  • it add a Chargebee implementation, which is 100% the identical code copied over from EligibilityService

Related Issue(s)

Context: #11402

How to test

  • open a workspace on this PR
  • get the content of the EligiblityService before this commit, and put it into a file called eligibilityservice.ts
  • run diff ee/src/billing/entitlement-service-chargebee.ts eligibilityservice.ts | less
  • inspect the output carefully; notice how there is no relevant diff between the two

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@geropl geropl requested a review from a team August 3, 2022 07:54
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Aug 3, 2022
@geropl geropl marked this pull request as draft August 3, 2022 07:59
@geropl
Copy link
Member Author

geropl commented Aug 3, 2022

Noticed two small changes that I need to handle better. Will notify again once done. 👍

@geropl geropl force-pushed the gpl/entitlement-svc-2 branch from b8e1e49 to 3a34726 Compare August 3, 2022 09:56
@geropl geropl marked this pull request as ready for review August 3, 2022 11:58
@geropl
Copy link
Member Author

geropl commented Aug 3, 2022

@AlexTugarev This is ready for review now! It should really not change any behavior the slightest, and is reduced to a mere move. 👍

@geropl geropl force-pushed the gpl/entitlement-svc-2 branch from 3a34726 to bd28cba Compare August 4, 2022 11:22
}

async maySetTimeout(user: User, date: Date): Promise<boolean> {
return true;
Copy link
Member

Choose a reason for hiding this comment

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

really?

Copy link
Member

Choose a reason for hiding this comment

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

I see. Existing strategy for disabled payment is to allow everything.

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. This implementation gathers defaults that so far have been hidden in various places.

💡 But notice that this is the code for the community distribution which we do not even hand out. Self-Hosted is based on the EE code, which is driven by the "new" EntintlementServiceChargebee (the 100% old code).

In follow-up steps we want to separate that into pure Chargebee and License, but: step-by-step 👣

"user with Team Unleashed but excludeFromMoreResources set does not get 'more resources'",
).to.equal(false);
}
// TODO(gpl) These should be moved over to EntitlementService.spec.ts
Copy link
Member

Choose a reason for hiding this comment

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

🤞🏻

@@ -404,7 +406,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
* gitpod.io Extension point for implementing eligibility checks. Throws a ResponseError if not eligible.
*/
protected async maySetTimeout(user: User): Promise<boolean> {
return this.eligibilityService.maySetTimeout(user);
return this.entitlementService.maySetTimeout(user, new Date());
Copy link
Member

Choose a reason for hiding this comment

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

looking at maySetTimeout, the date param seems to be weird. it's used internally to express "until now", thus new Date(). but it doesn't seem to make any sense for maySetTimeout, does it? e.g. maySetTimeout(user, yesterday) is irrelevant. let's remove it, wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

but it doesn't seem to make any sense for maySetTimeout, does it?

ℹ️ It's mainly there for testability.

But I agree, it should have a default to not bother clients. Will change in a follow-up! 👍

Copy link
Member

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the first chunk!

/hold
just in case you want to do something about https://github.com/gitpod-io/gitpod/pull/11831/files#r937678415

@geropl
Copy link
Member Author

geropl commented Aug 4, 2022

Thank you for your review @AlexTugarev ! 🙏

/unhold
to move forward and triple-check on staging.

@roboquat roboquat merged commit 678a6a2 into main Aug 4, 2022
@roboquat roboquat deleted the gpl/entitlement-svc-2 branch August 4, 2022 11:43
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Aug 5, 2022
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/XXL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants