codecov / engineering-team

This is a general repo to use with GH Projects
1 stars 1 forks source link

[Accounts] Support multiple linked org setups in GH #1533

Closed aj-codecov closed 2 weeks ago

aj-codecov commented 5 months ago

Problem to Solve: In GH we don't do anything to support a GH enterprise org that has child orgs under it when billing in Codecov. This create potential for double billing and under billing if we aren't very careful with how we allocate seats.

Proposed Solution: Enable a new concept (an Enterprise) that can have child orgs that are managed from a billing and user management perspective under one plan and total list of members shared across the connected orgs.

View related designs >

### Tasks
- [x] Build the concept of an "enterprise" that has orgs as children
- [x] Map users to those orgs
### Platform
- [ ] https://github.com/codecov/engineering-team/issues/1711
- [ ] https://github.com/codecov/engineering-team/issues/1740
- [ ] https://github.com/codecov/engineering-team/issues/1993
- [ ] https://github.com/codecov/engineering-team/issues/1806
- [ ] https://github.com/codecov/engineering-team/issues/1808
- [ ] https://github.com/codecov/engineering-team/issues/1807
### Design tasks
- [x] Design exploration for Q3 planning
- [x] Discuss an alternative way to treat the 5 self-service customers without introducing a lot of work
- [x] Confirmed which plan to have the Account Model experience. Enterprise Cloud for Q3 7/11
- [ ] https://github.com/codecov/engineering-team/issues/2064
- [ ] https://github.com/codecov/engineering-team/issues/2063
katia-sentry commented 5 months ago

We are dropping Gitlab as a requirement for the first iteration of this work for Q2'24

trent-codecov commented 5 months ago

Proposed structure

erDiagram
    ACCOUNT }|..|{ USERS : "has and belongs to many"
    ACCOUNT ||..o{ ACCOUNT_SETTINGS: "has zero or many"
    ACCOUNT ||..|{ OWNERS_ORGS : "has one or many"
    USERS ||..|{ OWNERS : "has one or many"
    OWNERS }|..|{ OWNERS_ORGS : "has and belongs to many"
    USERS ||..o| SENTRY_USER : "has zero or one"
    USERS ||..o| OKTA_USER : "has zero or one"

Note that I added account_settings here. That is not a requirement for this KR but will be needed for OKTA. We can either add that here or on that KR.

Also note that owners and owners_orgs are the same table. I broke them out for clarity here .... just like they should be in the db but alas.

Everything but account and account_settings already exists in the above diagram.

Account - meta object representing a collection of users and gh/bb/gl organizations Owner - gh/bb/gl user User - meta object representing a user of the system Owner_org - gh/bb/gl organization Sentry_user - Sentry user information for a given Codecov user Okta_user - Okta user information for a given Codecov user

Adal3n3 commented 4 months ago

Enterprise plan has unlimited public and private repo so as a customer, I probably only care about the numbers of my seats because I have a limited seats.

@trent-codecov @aj-codecov @ajay-sentry @katia-sentry Do you need design for this issue? If yes, in which area?

Adal3n3 commented 4 months ago

@ajay-sentry @aj-codecov Can we have a status update on this issue?

katia-sentry commented 4 months ago

I think we can get a status update on this work from @thomasrockhu-codecov or @michelletran-codecov on the platform side?

katia-sentry commented 4 months ago

It's not clear if/where changes are needed in the UI to support the enterprise concept in our billing - @aj-codecov @ajay-sentry any idea?

aj-codecov commented 4 months ago

@katia-sentry @Adal3n3 Will update around UI work by EOD today

michelletran-codecov commented 4 months ago

@katia-sentry We're still deciding on the data models. It's not firm, but the draft for the models can be found in this: https://www.notion.so/sentry/Account-Modelling-27888fb38b06483c963e4b15c1889625?pvs=4

Adal3n3 commented 3 months ago

Making a note here from my learning section with @michelletran-codecov

Background Codecov charges users based on the number of seats. If a user has 2 orgs, we sometimes charge the user twice because we are not able to detect that this user is from the same (enterprise) plan. The billing system is attached to the OWNERS(org) table, where an OWNER can be an ORG as well. Therefore, we can’t detect if an ORG/USER belongs to a plan.

Two problems:

  1. Codecov could charge the same user multiple times if this user is duplicated across multiple ORGs within the same paid plan.
  2. Contact the Codecov account team for a package deal. We charge them based on the number of seats they provide; this is usually contract-based pricing. We can’t detect if the users are from the same plan, resulting in overcharging or undercharging.

Proposed Solution:

  1. Create an Account Model. This Account Model allows Codecov to bill accurately across multiple ORGs.
  2. The Stripe billing system will need to migrate from the OWNERS(ORGS) table to the new ACCOUNTS table

@aj-codecov There is no Parent/Child org concept in this issue, can you update this issue name and the description to help us align? Thank you 🙏

katia-sentry commented 3 months ago

@Adal3n3 Do we need a UI for this?

aj-codecov commented 3 months ago

Linking recording of recent convo here: https://sentry.rewatch.com/video/jwd8sjej7fg24ny8-new-accounts-model-admin-discussion-june-12-2024

The tl:dw; is that we're looking to make some small UI tweaks to inform an end user of a pro or enterprise cloud plan that their plan is tied to multiple orgs and shares seats across multiple orgs.

nora-codecov commented 3 months ago

Planned Structure Screenshot 2024-06-13 at 2 48 48 PM

Further details about Okta https://www.notion.so/sentry/Account-Modelling-27888fb38b06483c963e4b15c1889625?pvs=4 Further details about billing https://www.notion.so/sentry/Codecov-Billing-67bc332086cb45babdc0da513bdfb566?pvs=4

Adal3n3 commented 3 months ago

AJ and I had a sync last Friday, and here are the discussion note from 6/18

Adal3n3 commented 3 months ago

Here's the Q3 design exploration on Figma: link

Here's the discussion note from @aj-codecov and me on 6/21:

Screenshot 2024-07-11 at 9 36 47 AM

Screenshot 2024-06-21 at 3 17 36 PM

Adal3n3 commented 3 months ago

Notion doc for Q3 planning: https://www.notion.so/sentry/Support-multiple-linked-orgs-WIP-bb12636b63654fe99a45017d66cddcff?pvs=4

thomasrockhu-codecov commented 3 months ago

@aj-codecov @Adal3n3 how do we feel about splitting off the Q3 tasks into a new issue? I worry that this one is going to be in too many different states (eng - merged but only the Q2 tasks, design - in progress for Q3 tasks)

Adal3n3 commented 3 months ago

@thomasrockhu-codecov @aj-codecov I mentioned this before during the Application sprint meeting so I believe this project will have it's own issue(s) and row(s) in Q3.

katia-sentry commented 2 months ago

Removing applications team as there is no UI work for this in Q2