Skip to content

Find out Orphan GitlabSubscriptions in Gitlab database, and decide how to handle(downgrade) them

When investigate a Gitlab.com trial error, we noticed a namespace has <code data-sourcepos="1:73-1:80">ultimate</code> in GitlabSubscription but has NO ultimate order in CDot.

This shows there are some Gitlab.com namespaces GitlabSubscription is orphaned:

  • GitlabSubscription.hosted_plan is non-free plan: ultimate, or premium, or even ultimate-trial or premium-trial, gold/bronze/etc
  • The namespace does NOT have any CDot Order for the base plan(as of in GitlabSubscription).

One example is namespace 71874329

Data/screenshot from database
The namespace 71874329 is on ultimate plan in GitlabSubscription table
[ gprd ] production> g= Group.find(71874329)
=> #<Group id:71874329 @rmsrohan-ultimate>
[ gprd ] production> gs = g.gitlab_subscription
=>
#<GitlabSubscription:0x00007f41924bd5e0
...
[ gprd ] production> gs
=>
#<GitlabSubscription:0x00007f41924bd5e0
 id: 10189589,
 created_at: Thu, 24 Aug 2023 03:57:31.990327000 UTC +00:00,
 updated_at: Wed, 16 Oct 2024 18:13:23.812512000 UTC +00:00,
 start_date: Thu, 07 Sep 2023,
 end_date: nil,
 trial_ends_on: nil,
 namespace_id: 71874329,
 hosted_plan_id: 101,
 max_seats_used: 19,
 seats: 0,
 trial: false,
 trial_starts_on: nil,
 auto_renew: nil,
 seats_in_use: 2,
 seats_owed: 0,
 trial_extension_type: nil,
 max_seats_used_changed_at: Thu, 07 Mar 2024 06:11:53.741875000 UTC +00:00,
 last_seat_refresh_at: Thu, 30 Jan 2025 00:11:07.414621000 UTC +00:00>
[ gprd ] production> Plan.find(101)
=> #<Plan:0x00007f41a5fbd090 id: 101, created_at: Mon, 15 Feb 2021 15:57:35.101224000 UTC +00:00, updated_at: Mon, 15 Feb 2021 15:57:35.101224000 UTC +00:00, name: "ultimate", title: "[FILTERED]">
[ gprd ] production> g
=> #<Group id:71874329 @rmsrohan-ultimate>
[ gprd ] production> g.created_at
=> Thu, 24 Aug 2023 03:57:31.927386000 UTC +00:00
[ gprd ] production> g.updated_at
=> Mon, 20 May 2024 10:33:50.541596000 UTC +00:00
[ gprd ] production>

The namespace does not have any ultimate Order in CDot database: image

This means: such namespace will escape from the ExpireOrderCronJob, and their namespace will stay in the paid plan for ever.

Proposal

Find out such Orphan GitlabSubscriptions in Gitlab database, and decide how to handle(downgrade) them. Ideally, we should downgrade them to free plan.

Even better, if we could find a way to regularly cleanup such GitlabSubscriptions, we could process this automatically in long term.

Result

No Orphan GitlabSubscriptions in Gitlab database. Reduced Gitlab.com operation cost.

Next steps (if any)

How will we measure success?

Edited by Qingyu Zhao