Uploaded image for project: 'Cost Management'
  1. Cost Management
  2. COST-5731

Incorrect markup cost inserted into OCP on ALL tables with savings plan items

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Normal Normal
    • 2024-Dec-06, 2024Q4
    • None
    • None
    • None
    • 5
    • False
    • None
    • False

      While investigating/fixing COST-5728, we noticed that in case of savings plan items we insert an incorrect markup cost into OCP on ALL tables.

      OCP on ALL view is supposed to use calculated_amortized_cost as an AWS infra cost and thus we should also apply corresponding markup cost, which is markup_cost_amortized. However, in OCP On All SQL queries  we insert sum of markup_cost and sum of project_markup_cost respectively:

      https://github.com/project-koku/koku/blob/ad93105b64dd05bc2d8413463cbf07d4c9064dad/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_daily_summary_aws.sql#L59

      https://github.com/project-koku/koku/blob/ad93105b64dd05bc2d8413463cbf07d4c9064dad/koku/masu/database/sql/openshift/all/reporting_ocpallcostlineitem_project_daily_summary_aws.sql#L61

       

      Here's an example of savings plan item from reporting_ocpawscostlineitem_project_daily_summary_p (this table is used as a source in OCP on all SQL queries)

      product_code                      | AmazonEC2
      product_family                    | Compute Instance
      ... shortened ...
      unblended_cost                    | 0.000000000000000
      markup_cost                       | 0.000000000000000
      project_markup_cost               | 0.000000000000000
      pod_cost                          | 0.000000000000000
      blended_cost                      | 0.000000000000000
      markup_cost_blended               | 0.000000000000000
      markup_cost_savingsplan           | 0.300000000000000
      markup_cost_amortized             | 0.300000000
      savingsplan_effective_cost        | 3.000000000000000
      calculated_amortized_cost         | 3.000000000
       

      We can see that both markup_cost and project_markup_cost, which are inserted into OCP on ALL tables, are  $0 (they are calculated from unblended_cost) -> in fact we do not apply markup to these items. I believe the OCP on ALL queries should use markup_cost_amortized, which is derived from calculated_amortized_cost  ($0.3 in the example above).

       

      Additionally, we should also double check if pod_cost is calculated correctly here:

      https://github.com/project-koku/koku/blob/main/koku/masu/database/trino_sql/reporting_ocpawscostlineitem_daily_summary.sql

       

      Steps to reproduce:

      iqe branch: https://gitlab.cee.redhat.com/insights-qe/iqe-cost-management-plugin/-/merge_requests/2158/diffs

      1. run

      ENV_FOR_DYNACONF=local iqe tests plugin cost_management -k "ocp_on_aws_markup_calculation" -vv --pdb
       

      2. wait for the test to fail

              rhn-support-lcouzens Luke Couzens
              rhn-support-esebesto Eva Šebestová
              Eva Šebestová Eva Šebestová
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: