EE::Namespace#actual_plan writes a gitlab_subscriptions row during a read
EE::Namespace#actual_plan calls a private generate_subscription, which runs
create_gitlab_subscription(plan_code: Plan::FREE, seats: 0). So reading a
namespace's plan can INSERT a row.
generate_subscription has exactly one caller, actual_plan, so the surface is
small.
Observable consequences:
- Adding a member to a group creates a subscription row as a side effect. The
member hook triggers a licensed-feature check, which reaches
actual_plan. - Tests work around it by deleting the row afterwards. See the comment in
ee/spec/features/billings/billing_plans_spec.rb: "post_create_member_hook creates a subscription due to a license check". - Behaviour depends on whether something happened to read the plan earlier in the
request or the test. That is what made
ee/spec/features/groups/usage_quotas/seats_tab_spec.rbflaky.
Ask: make the read path stop writing. Leave subscription creation to the explicit paths that are meant to create one.
This needs care. Some code may rely on the row appearing after a plan read, so the
callers of actual_plan should be checked before the write is removed.