Skip to content

Draft: Use safe navigation in calculate_seats_in_use

What does this MR do?

This MR updates GitlabSubscription#calculate_seats_in_use so it returns a zero count when the subscription doesn't have a namespace to get the billable members from.

What's currently happening is that there are some subscriptions that ended up in a state where the namespace is nil and trying to get the billable_members_count for them results in an error. See the full explanation on how this happened in this comment.

As a result, the UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker is raising an error that prevents the update of max_seats_used for all subscriptions.

Note: The subscription object currently allows the namespace_id to be blank. The records in this state will be cleaned up and then we should probably look into ensuring these records always have a namespace associated.

Related issue

https://gitlab.com/gitlab-org/gitlab/-/issues/233444

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Amparo Luna

Merge request reports