Skip to content

Preview free user cap only for specific namespaces

Nicolas Dular requested to merge nd/free-user-preview-inclusion into master

What does this MR do and why?

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/365673

This adds the field include_for_free_user_cap_preview to namespace_settings to only show the preview of free user cap when

  1. The Feature flag is enabled (preview_free_user_cap)
  2. The namespace has include_for_free_user_cap_preview set to true

This enables us to rollout the preview per namespace, which would not be possible (performant enough) if we would use Feature Flag subjects.

Migration

Migrate
bin/rails db:migrate:main
main: == 20220712094945 AddIncludeForFreeUserCapPreviewToNamespaceSettings: migrating
main: -- add_column(:namespace_settings, :include_for_free_user_cap_preview, :boolean, {:null=>false, :default=>false})
main:    -> 0.0044s
main: == 20220712094945 AddIncludeForFreeUserCapPreviewToNamespaceSettings: migrated (0.0055s)
Rollback
bin/rails db:rollback:main
main: == 20220712094945 AddIncludeForFreeUserCapPreviewToNamespaceSettings: reverting
main: -- remove_column(:namespace_settings, :include_for_free_user_cap_preview)
main:    -> 0.0010s
main: == 20220712094945 AddIncludeForFreeUserCapPreviewToNamespaceSettings: reverted (0.0015s)

Screenshots or screen recordings

These screenshots are just here to know where the preview_free_user_cap has an impact on:

No cap, no Preview Preview active Cap enabled
Screenshot_2022-07-12_at_15.18.33 Screenshot_2022-07-12_at_15.17.26 Screenshot_2022-07-12_at_15.18.47

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. export GITLAB_SIMULATE_SAAS=1
  2. gdk start
  3. Enable preview_free_user_cap as feature flag globally + use namespace-plans, and pick a group to test it on
    bin/rails c
    Feature.enable(:preview_free_user_cap)
    ApplicationSetting.first.update(check_namespace_plan: true)
    
    # find a group ID
    group = Group.find(GROUP_ID)
    group.namespace_settings.update_columns(include_for_free_user_cap_preview: true)
  4. Go to the Usage Quota Page (Group > Settings > Usage Quota) http://localhost:3000/groups/GROUP_NAME/-/usage_quotas#seats-quota-tab and be able to see the toggles and the banner
  5. If you want to check the free_user_cap
    bin/rails c
    Feature.disable(:preview_free_user_cap)
    Feature.enable(:free_user_cap)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Nicolas Dular

Merge request reports

Loading