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

Incorrect distributed cost after change of cost model currency

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • Data Pipeline
    • None
    • 5
    • False
    • None
    • False

      After we update cost model currency for OCP source correlated with cloud source, the project distributed cost seems to be incorrect. We can see the same when we delete cost model and then attach a new cost model with different currency.

      I noticed this with distribution of worker unallocated cost - we should probably look to Platform cost as well.

      Another thing I was not sure about is what we are supposed to do with OCP infra cost which is part of Worker unallocated cost. We don't seem to distribute it - is that expected or not?

      Also note that this doesn't seem to be an issue for OCP on prem (at least I was not able to reproduce it when ingesting only OCP source).

       

      Distribution of Worker unallocated cost with original cost model with SEK currency (values shown in SEK for better clarity): whole usage cost (SEK -343.2) is distributed as expected to user projects

      http://localhost:8000/api/cost-management/v1/reports/openshift/costs/?group_by[project]=*&currency=SEK
      
      
      "project": "Worker unallocated",
                          "values": [
                              {
                                  ....
                                  "infrastructure": {
                                      ....
                                      "total": {
                                          "value": 1018.2663559568134,
                                          "units": "SEK"
                                      }
                                  },
                                  "supplementary": {
                                      ....
                                      "total": {
                                          "value": 343.2,
                                          "units": "SEK"
                                      }
                                  },
                                  "cost": {
                                      "raw": {
                                          "value": 1018.2663559568134,
                                          "units": "SEK"
                                      },
                                      "markup": {
                                          "value": 0.0,
                                          "units": "SEK"
                                      },
                                      "usage": {
                                          "value": 343.2,
                                          "units": "SEK"
                                      },
                                      "platform_distributed": {
                                          "value": 0.0,
                                          "units": "SEK"
                                      },
                                      "worker_unallocated_distributed": {
                                          "value": -343.2,
                                          "units": "SEK"
                                      },
                                      "distributed": {
                                          "value": 1018.2663559568134,
                                          "units": "SEK"
                                      },
                                      "total": {
                                          "value": 1361.4663559568135,
                                          "units": "SEK"
                                      }
                                  }
                              }
                          ]

       

      Distribution of Worker unallocated cost with updated cost model with CHF currency (values shown in CHF for better clarity): the usage cost still has the same value (CHF 343.2) as expected, but this time we distribute higher value - CHF 487.2 - than the worker unallocated project even has

       "project": "Worker unallocated",
                          "values": [
                              {
                                  ...
                                  "infrastructure": {
                                      ....
                                      "total": {
                                          "value": 85.51514060876869,
                                          "units": "CHF"
                                      }
                                  },
                                  "supplementary": {
                                      ...
                                      },
                                      "total": {
                                          "value": 343.2,
                                          "units": "CHF"
                                      }
                                  },
                                  "cost": {
                                      "raw": {
                                          "value": 85.51514060876869,
                                          "units": "CHF"
                                      },
                                      "markup": {
                                          "value": 0.0,
                                          "units": "CHF"
                                      },
                                      "usage": {
                                          "value": 343.2,
                                          "units": "CHF"
                                      },
                                      "platform_distributed": {
                                          "value": 0.0,
                                          "units": "CHF"
                                      },
                                      "worker_unallocated_distributed": {
                                          "value": -487.2,
                                          "units": "CHF"
                                      },
                                      "distributed": {
                                          "value": -58.4848593912313,
                                          "units": "CHF"
                                      },
                                      "total": {
                                          "value": 428.7151406087687,
                                          "units": "CHF"
                                      }
                                  }
                              }
                          ]

       

      Note that we will get the same incorrect distribution when we delete the cost-model and attach a new cost model with CHF currency.

      On the other hand, when we delete the source and create a new source with cost-model using CHF currency, the values will be distributed as expected: whole usage cost (CHF 343.2) is distributed as expected to user projects

                           "project": "Worker unallocated",
                          "values": [
                              {
                                 ...
                                  "infrastructure": {
                                      ...
                                      "total": {
                                          "value": 85.51514060876869,
                                          "units": "CHF"
                                      }
                                  },
                                  "supplementary": {
                                     ...
                                      "total": {
                                          "value": 343.2,
                                          "units": "CHF"
                                      }
                                  },
                                  "cost": {
                                      "raw": {
                                          "value": 85.51514060876869,
                                          "units": "CHF"
                                      },
                                      "markup": {
                                          "value": 0.0,
                                          "units": "CHF"
                                      },
                                      "usage": {
                                          "value": 343.2,
                                          "units": "CHF"
                                      },
                                      "platform_distributed": {
                                          "value": 0.0,
                                          "units": "CHF"
                                      },
                                      "worker_unallocated_distributed": {
                                          "value": -343.2,
                                          "units": "CHF"
                                      },
                                      "distributed": {
                                          "value": 85.51514060876869,
                                          "units": "CHF"
                                      },
                                      "total": {
                                          "value": 428.7151406087687,
                                          "units": "CHF"
                                      }
                                  }
                              }
                          ]
                      },

       

       

      Steps to reproduce:

      You can use iqe branch esebesto/reproduce_cost4979 branch

      1. execute test_api_ocp_on_azure_reproduce_distribution_bug test

      ENV_FOR_DYNACONF=local iqe tests plugin cost_management -k test_api_ocp_on_azure_reproduce_distribution_bug -vv --pdb 

      2. the test will stop after ocp and correlate azure source is ingested, check

      http://localhost:8000/api/cost-management/v1/reports/openshift/costs/?group_by[project]=*&currency=SEK
      
      

      You will see that the whole usage cost (SEK -343.2) is distributed as expected to user projects

      3. type "c" in pdb console to continue with the test. Test will update cost model currency to CHF and run OCP and also Azure resummary.  The test will stop once re-summary is finished.. Then check the cost report again, this time using CHF currency

      http://localhost:8000/api/cost-management/v1/reports/openshift/costs/?group_by[project]=*&currency=CHF

      You will see that the usage cost still has the same value (CHF 343.2) as expected, but this time we distribute higher value - CHF 487.2 - than the worker unallocated project even has

      4. type "c" in pdb console to finish the remove the sources from db

      5. update cost model currency in setup_cost_ocp_on_azure_source_static fixture from "SEK" to "CHF" and execute the test again. This time the OCP source will be created with CHF cost-model

      ENV_FOR_DYNACONF=local iqe tests plugin cost_management -k test_api_ocp_on_azure_reproduce_distribution_bug -vv --pdb  

      6. check

      http://localhost:8000/api/cost-management/v1/reports/openshift/costs/?group_by[project]=*&currency=CHF 

      You will see that whole usage cost (CHF 343.2) is distributed as expected to user projects

       

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

              Created:
              Updated: