Uploaded image for project: 'Cost Management'
  1. Cost Management
  2. COST-5288 Incorrect distributed cost when cloud and OCP currencies differ
  3. COST-5355

SPIKE: Figure out how many customers may be affected by COST-5288

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Done
    • Icon: Undefined Undefined
    • 2024-Aug-09
    • None
    • None
    • None
    • 1
    • False
    • None
    • False

      Approach Outline:

      1. I ran the following query to get a mapping of all of the OpenShift sources that were linked to an infrastructure source and their schema:

      SELECT array_agg(provider.uuid) as ocp_source_uuids, ac.schema_name FROM public.api_providerinfrastructuremap as provider_map INNER JOIN public.api_provider as provider ON provider_map.id = provider.infrastructure_id INNER JOIN public.api_customer as ac ON provider.customer_id = ac.id WHERE provider.active = TRUE AND provider.paused = FALSE GROUP BY ac.schema_name;

      2. I took the response and wrote a python script to convert it to a json file that had schema & ocp source uuids. 
      3. I then wrote a separate python script that looped through that mapping and populated the following sql:

      WITH cte_cost_model_currency as (
      SELECT
      cost_model_mapping.provider_uuid as ocp_source_uuid,
      currency as cost_model_currency
      FROM {{schema{}}}.cost_model_map as cost_model_mapping
      INNER JOIN schema.cost_model as cost_model
      ON cost_model.uuid = cost_model_mapping.cost_model_id
      WHERE ((cost_model.distribution_info::jsonb ->> 'worker_cost')::boolean IS TRUE
      OR (cost_model.distribution_info::jsonb ->> 'platform_cost')::boolean IS TRUE)
      AND cast(cost_model_mapping.provider_uuid as varchar) IN {{cleaned_ocp_sources{}}}
      ),
      cte_currency_match as (
      SELECT
      raw_currency as infra_currency,
      cmc.ocp_source_uuid,
      max(cmc.cost_model_currency) as cost_model_currency,
      raw_currency = MAX(cmc.cost_model_currency) AS currency_match
      FROM {{schema{}}}.reporting_ocpusagelineitem_daily_summary as lids
      INNER JOIN cte_cost_model_currency as cmc
      ON cmc.ocp_source_uuid = lids.source_uuid
      AND usage_start >= '2024-08-01'
      GROUP BY cmc.ocp_source_uuid, lids.raw_currency
      )
      SELECT * FROM cte_currency_match WHERE currency_match = False;

      The results will be in a private comment below.

            myersco Cody Myers
            myersco Cody Myers
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: