Skip to content

Separate EE from SaaS data properly on pipeline_usage_app_data

Sheldon Led requested to merge led/405173-fix-undefined-ci-usage into master

What does this MR do and why?

This fixes #405173 (closed). The method that provided the data to the frontend was treating all EE data as SaaS data, breaking the UI on Usage Quotas page for Self Managed users.

There's also a small UI improvement on the top title padding for Self Managed, as highlighted in the screenshots below

Screenshots or screen recordings

Before After Simulating SaaS
usage_quotas_overview_before usage_quotas_overview_after usage_quotas_overview_saas

How to set up and validate locally

  1. If you have configured your GDK to simulate a SaaS instance make sure to undo it so that your GDK behave as Self-Managed
  2. Create a project within a group on a SM instance.
  3. Run a pipeline in the project for at least 60 seconds. A single job with sleep 60 should to the trick.
    1. If you don't have runners configured on your local GDK, you can mock the data in the DB:
    # If you already have ci minutes record, update it with any number
    Ci::Minutes::NamespaceMonthlyUsage.where(namespace_id: 188, date: Time.current.utc.beginning_of_month).update(amount_used: 70)
    
    # If you don't have the DB record, create it
    Ci::Minutes::NamespaceMonthlyUsage.new(namespace_id: 188, date: Time.current.utc.beginning_of_month, amount_used: 70).save
    
    # If you want a nice line in the graph, add data for the previous month
    # Create
    Ci::Minutes::NamespaceMonthlyUsage.new(namespace_id: 188, date: Time.current.utc.beginning_of_month - 1.month, amount_used: 50).save
    
    # Update 
    Ci::Minutes::NamespaceMonthlyUsage.where(namespace_id: 188, date: Time.current.utc.beginning_of_month - 1.month).update(amount_used: 50)
  4. Go to the top-level group and navigate to: Settins -> Usage Quotas and select the Pipelines tab.
  5. Notice how the CI/CD minutes usage quota shows up.

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 Marius Bobin

Merge request reports

Loading