Skip to content
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

Polish handling of BillingMode #12130

Merged
merged 7 commits into from
Aug 17, 2022
Merged

Polish handling of BillingMode #12130

merged 7 commits into from
Aug 17, 2022

Conversation

geropl
Copy link
Member

@geropl geropl commented Aug 15, 2022

Description

This PR includes a couple of alignments around BillingMode. It's reviewable by commit. As all changes share the same context I think it does not make sense to further split this up. 🧘

  1. Improved tests + additional tests (no change in behavior)
  2. Make "workspace classes" usable if either of these are true:
    1. You have the "workspace_classes" FF enabled
    2. The method BillingMode.canSetWorkspaceClass returns true for your BillingMode
  3. Small fix to BillingModes: Only have paid UBP team memberships override existing Chargebee memberships
  4. Handle bad "CostCenter" error, in case you have not yet set a team spending limit for whatever reason
  5. Make moment time offset work on Usage List View removed
  6. Fix wrong usage of findCustomerByUserId and replace with findCustomerByTeamId

Related Issue(s)

Fixes #12098
Fixes #12090
Fixes #12149

How to test

  • signup
  • create a Team called Gitpod-heroes or so
  • check:
    • user preferences: no workspace classes selector, yet ✔️
    • user billing: no Usage-based stuff, yet ✔️
    • user settings menu: still has entries for Plans/Team Subscriptions ✔️
  • try to start a workspace: shows the "set spending limit" UI ✔️
  • signup for a Usage-Based team plan
    • user preferences: see workspace classes selector, yet ✔️
    • user billing: see the UBP attribution selector ✔️
    • user settings menu: no entries for Plans/Team Subscriptions ✔️

Release Notes

NONE

Documentation

Werft options:

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

@geropl
Copy link
Member Author

geropl commented Aug 15, 2022

/werft run

👍 started the job as gitpod-build-gpl-ubp.2
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-gpl-ubp.3 because the annotations in the pull request description changed
(with .werft/ from main)

@roboquat roboquat added size/XL and removed size/XS labels Aug 16, 2022
@geropl geropl marked this pull request as ready for review August 16, 2022 12:30
@geropl geropl requested a review from a team August 16, 2022 12:30
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Aug 16, 2022
@geropl geropl changed the title UBP - dev Polish handling of BillingMode Aug 16, 2022
@jankeromnes jankeromnes self-assigned this Aug 16, 2022
@jankeromnes
Copy link
Contributor

jankeromnes commented Aug 16, 2022

Thanks! Code looks good, now moving on to (manual) tests.

@jankeromnes
Copy link
Contributor

jankeromnes commented Aug 16, 2022

Question:

  1. I have no paid plans, but am by default in Chargebee mode
  2. I create a team called "Gitpod Something", which enables Usage-Based for both myself and my team
  3. In my team, I now see the Usage-Based Billing UI, which is great 👍
  4. However, in my user, I still only see the Chargebee UI
  • Is this expected?
  • How will I be able to upgrade my user to individual Usage-Based Billing (once that's supported)?

@geropl
Copy link
Member Author

geropl commented Aug 16, 2022

/hold Have to remove the usage timestamp fix commit as it clashes with a parallel fix.

@geropl
Copy link
Member Author

geropl commented Aug 16, 2022

We discussed @jankeromnes comment above: It's very well possible to not have UBP on your user. In this case, because the Team had not paid plan, yet.

@geropl
Copy link
Member Author

geropl commented Aug 16, 2022

/unhold

Commit removed.

@jankeromnes PR should be good to review - sorry for the UI glitch 🙇

@jankeromnes
Copy link
Contributor

jankeromnes commented Aug 17, 2022

Many thanks for finishing up this PR @geropl! I went through the entire "How to test" process, but found a few possible small problems.

How to test

Right after signup, and a second time later after randomly refreshing once (but it's hard to reproduce), I got this strange error:

Screenshot 2022-08-17 at 09 30 00

I believe this is when a backend service returns an error, but it's missing an HTTP error code (it's supposed to say something like Error 500, but instead it's just Error with a space but no error code).

But maybe it's just a preview problem and not related to this PR?

  • create a Team called Gitpod-heroes or so

Additionally, this wasn't part of the test flow, but I notice that the Team Billing UI has some unfortunate flickering:

https://youtu.be/v-x4zhj25pA

Instead of briefly showing the Chargebee UI before the Usage-Based UI shows up, I think this initial state should be a loading indicator. Can be done in a follow-up though.

  • check:
    • user preferences: no workspace classes selector, yet ✔️

❌ Actually, there is this:

Screenshot 2022-08-17 at 09 37 07

Is this not expected?

  • user billing: no Usage-based stuff, yet ✔️

✅ (although I think this should change in the future when we implement usage-based billing for individual users)

  • user settings menu: still has entries for Plans/Team Subscriptions ✔️

  • try to start a workspace: shows the "set spending limit" UI ✔️

❌ It didn't show the "set spending limit" UI, but started a workspace successfully instead:

Screenshot 2022-08-17 at 09 40 34 Screenshot 2022-08-17 at 09 48 27
  • signup for a Usage-Based team plan
    • user preferences: see workspace classes selector, yet ✔️

✅ (selector is still visible)

  • user billing: see the UBP attribution selector ✔️

❔ basically worked, although I needed to hard-refresh once in order to see the "Billing" menu entry (instead of the "Plans" and "Team Plans" entries which were still there for some reason).

Screenshot 2022-08-17 at 09 43 29

After that single refresh, everything is there, although the "Billing" menu entry now takes a long time before it shows up.

  • user settings menu: no entries for Plans/Team Subscriptions ✔️

✅ (same as above -- menu is eventually correct, but it takes a long time before the "Billing" menu entry shows up)

@geropl
Copy link
Member Author

geropl commented Aug 17, 2022

Thank you for your thorough review, @jankeromnes ! 🚀

Is this not expected?

The value of the workspace_classes FF changed in the meantime: 🙈
image
So this is expected, yes - but makes it hard to test. 🙄 We could add an exlusion case there... or try again with a non-@gitpod.io user.

Instead of briefly showing the Chargebee UI before the Usage-Based UI shows up, I think this initial state should be a loading indicator. Can be done in a follow-up though.

grey_question basically worked, although I needed to hard-refresh once in order to see the "Billing" menu entry (instead of the "Plans" and "Team Plans" entries which were still there for some reason).

Would you have time after 10:30 to help me fix these? 🙏 Feels like it could be simple, but I'm too unfamiliar with the Dashboard to be confident.

I believe this is when a backend service returns an error, but it's missing an HTTP error code (it's supposed to say something like Error 500, but instead it's just Error with a space but no error code).

Are there any logs on the server pod? 🤔

@jankeromnes
Copy link
Contributor

jankeromnes commented Aug 17, 2022

So this is expected, yes - but makes it hard to test. 🙄 We could add an exlusion case there... or try again with a non-@gitpod.io user.

I tried with a non-@gitpod.io user -- same problem:

  1. Initially, preferences has no workspace class selector
  2. After creating a "Gitpod (Something)" team, preferences has a workspace class selector (contrary to test plan)
  3. After upgrading team to usage-based subscription, workspace class selector remains in preferences

Would you have time after 10:30 to help me fix these? 🙏 Feels like it could be simple, but I'm too unfamiliar with the Dashboard to be confident.

Would be more than happy to! 👍 🎨

Are there any logs on the server pod? 🤔

I didn't check for server errors, but I'm pretty sure the /sorry/ redirect happens here:

handle_errors {
redir https://{$GITPOD_DOMAIN}/sorry/#Error%20{http.reverse_proxy.status_text} 302
}

@geropl
Copy link
Member Author

geropl commented Aug 17, 2022

@jankeromnes and I synced, and created this commit with resulting fixes. 👍

@jankeromnes
Copy link
Contributor

jankeromnes commented Aug 17, 2022

Thanks @geropl!

Unfortunately, while doing one last check, I found another problem 🙈 it looks like the Chargebee team billing UI is now gone entirely:

https://youtu.be/oFNoS11vmuM

Notice that I have one team with UB flag enabled, and another team with UB flag disabled.

EDIT: However, when I delete the team with with UB enabled, it fixes the Charbebee UI of the team with UB disabled.

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.

Alright! I think we're there now. 🎉 Thanks for iterating until it works!

Approving to unblock merging, but holding because there is still one problem that I raised in this comment:

❌ It didn't show the "set spending limit" UI, but started a workspace successfully instead:

The testing plan says that, when you create a "Gitpod (Something)" team, and try to start a workspace, you get blocked by a "Spending Limit" modal.

This is not the case.

Instead, it continues to start workspaces with no issues, and I have to upgrade a team to Usage-Based, and then set a Spending Limit to very low (e.g. 0), in order to actually see the "Spending Limit" modal on workspace start.

However, this is likely a bug in the test scenario, and not a bug in the code, right? 😇

/hold

@geropl
Copy link
Member Author

geropl commented Aug 17, 2022

The testing plan says that, when you create a "Gitpod (Something)" team, and try to start a workspace, you get blocked by a "Spending Limit" modal.

This is not the case.

However, this is likely a bug in the test scenario, and not a bug in the code, right? innocent

I tested this before the rebase. As it's not critical, and more important that we don't show an arkward error message as before, I'd say let's merge this one (as it's big enough), and I will re-test and take care in a follow up.

Mentioned earlier, but here again: thank you for the through review @jankeromnes ! 🙏

@geropl
Copy link
Member Author

geropl commented Aug 17, 2022

/unhold

@roboquat roboquat merged commit 4d7695b into main Aug 17, 2022
@roboquat roboquat deleted the gpl/ubp branch August 17, 2022 12:56
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Aug 18, 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/XL team: webapp Issue belongs to the WebApp team
Projects
None yet
3 participants