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

EC2 report doesn't always show the latest values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Normal Normal
    • None
    • None
    • None
    • None

      EC2 report is supposed to display the latest values in case that some instance attributes change over time (instance name, account alias, inst. type, memory or vcpu).

      When I tested this, it seemed to work fine but I was probably just lucky - the automated test sometimes fails because the report shows the "old" value

      UPDATE:

      It looks like max value is always picked, e.g. vcpu 16 over vcpu 2, instance z.abc over m.abc etc.

      We need to pick values with corresponding to the latest timestamps not the max values of individual attributes

      Steps to reproduce:

      • use iqe branch: esebesto/reproducer_COST-5558
      • run test_api_aws_ec2_report_content test multiple times until you hit the issue
      ENV_FOR_DYNACONF=local iqe tests plugin cost_management -k "test_api_aws_ec2_report_content" -vv --pdb 

       

      Example:

      In the example below, we have two records in the db,

      • RECORD 2 for 2024-10-01: t3.small instance with 7.5 GiB memory, name  instance_name_test_10
      • RECORD 1 for 2024-10-02:  m3.large instance with 1.5 GiB memory, name  instance_name_test_101
      postgres=# select * from reporting_awscostentrylineitem_summary_by_ec2_compute_p_2024_10 where resource_id = 'i-88883333';
      -[ RECORD 1 ]--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      ------
      uuid                       | accdd598-1691-4534-88f4-cc845f9e4f6b
      usage_start                | 2024-10-02
      usage_end                  | 2024-10-02
      usage_account_id           | 0088883333999
      resource_id                | i-88883333
      instance_name              | instance_name_test_101
      instance_type              | m3.large
      operating_system           | Fedora CoreOS
      region                     | us-west-1
      vcpu                       | 
      memory                     | 1.5 GiB
      unit                       | Hrs
      usage_amount               | 5.000000000
      normalization_factor       | 0
      normalized_usage_amount    | 0
      currency_code              | USD 
      ... SHORTENED ... 
      
      -[ RECORD 2 ]--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      ------
      uuid                       | 722f033b-35ef-4dff-bf71-9d83713a254b
      usage_start                | 2024-10-01
      usage_end                  | 2024-10-01
      usage_account_id           | 0088883333999
      resource_id                | i-88883333
      instance_name              | instance_name_test_10
      instance_type              | t3.small
      operating_system           | Fedora CoreOS
      region                     | us-west-1
      vcpu                       | 
      memory                     | 7.5 GiB
      unit                       | Hrs
      usage_amount               | 12.000000000
      normalization_factor       | 0
      normalized_usage_amount    | 0
      currency_code              | USD
      ... SHORTENED ... 
      

       

      Thus we expect to see m3.large instance with 1.5 GiB memory in the EC2 report for current month. Which was not the case. interestingly enough, instance_name was  instance_name_test_101 as expected

      http://localhost:8000/api/cost-management/v1/reports/aws/resources/ec2-compute/?filter[time_scope_value]=-1

       

      "date": "2024-10",
                  "resource_ids": [
                      {
                          "resource_id": "i-88883333",
                          "values": [
                              {
                                  "resource_id": "i-88883333",
                                  "date": "2024-10",
                                  "usage": {
                                      "value": 17.0,
                                      "units": "Hrs"
                                  },
                                  "source_uuid": [
                                      "0d6fd06a-5484-47f7-8b70-4c30c11206fd"
                                  ],
                                  "account_alias": "0088883333999",
                                  "account": "0088883333999",
                                  "instance_name": "instance_name_test_101",
                                  "instance_type": "t3.small",
                                  "operating_system": "Fedora CoreOS",
                                  "region": "us-west-1",
                                  "vcpu": null,
                                  "memory": "7.5 GiB",
                                  ... SHORTENED ... 

       
       
       
       

       
       
       
       

       
       
       
       

       

              rh-ee-lbacciot Lucas Bacciotti
              rhn-support-esebesto Eva Šebestová
              Eva Šebestová Eva Šebestová
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: