Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COST-5093] Update mapped tags in EC2 summary table #5147

Merged
merged 6 commits into from
Jul 12, 2024

Conversation

djnakabaale
Copy link
Contributor

@djnakabaale djnakabaale commented Jun 5, 2024

Jira Ticket

COST-5093

Description

This change will update mapped tags for EC2 summary table by leveraging the existing update functionality for the aws daily summary table.

Testing

  1. Checkout Branch

  2. Load test data

    make create-test-customer ; make load-test-customer-data test_source=aws
    
  3. Create tag mappings with a PUT request to this endpoint and requires knowing tag uuids.

     http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/child/add/. 
    
    Example
     curl --location --request PUT 'http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/child/add/' \
     --header 'Content-Type: application/json' \
     --data '{
         "parent":  "ab1994b9-3b0f-441d-93ee-b731fd1956cf",
         "children": [
             "9c7ce1a3-3713-4657-a838-a471c77e049d",
             "db4df347-0924-4142-9786-0f3ed929446c",
             "9944e8b8-5e36-48f8-b9d8-ab06b18d3899",
             "c39ef51b-d459-41b3-b776-302f2836361a",
             "51e62c05-ee8c-47e0-a25b-e6edb7eb79cc",
             "92016af6-00b5-4c1c-86cb-4abbcec736c0",
             "66df0282-9c21-4674-9aed-f973cd536c6e",
             "31079e66-0885-4ebb-9b91-1ce4430f0b4d",
             "6ec4cdd2-b65b-4e7b-92bd-6603af2ed825",
             "93c60f52-ce91-4b0f-a381-85b5bd536353",
             "348285ae-f7a8-4ab3-b84f-9b67aaa55e32"
         ]
     }'
    
  4. Check these endpoints to

    • see the parent mapped tags, http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/parent/?source_type=AWS

        {
            "meta": {
                "count": 1,
                "limit": 1,
                "offset": 0
            },
            "links": {
                "first": "/api/cost-management/v1/settings/tags/mappings/parent/?limit=1&offset=0&source_type=AWS",
                "next": null,
                "previous": null,
                "last": "/api/cost-management/v1/settings/tags/mappings/parent/?limit=1&offset=0&source_type=AWS"
            },
            "data": [
                {
                    "uuid": "ab1994b9-3b0f-441d-93ee-b731fd1956cf",
                    "key": "Name",
                    "source_type": "AWS",
                    "cost_model_id": null
                }
            ]
        }
      
    • see mapped child tags, http://127.0.0.1:8000/api/cost-management/v1/settings/tags/mappings/child/

        {
            "meta": {
                "count": 2,
                "limit": 2,
                "offset": 0
            },
            "links": {
                "first": "/api/cost-management/v1/settings/tags/mappings/child/?limit=6&offset=0",
                "next": null,
                "previous": null,
                "last": "/api/cost-management/v1/settings/tags/mappings/child/?limit=6&offset=0"
            },
            "data": [
                {
                    "uuid": "3a56a865-8c2f-4649-8947-4e909464989f",
                    "key": "app",
                    "source_type": "OCP",
                    "cost_model_id": null
                },
                {
                    "uuid": "bfbb6b8a-9197-4d77-ab00-9b9bc8c177aa",
                    "key": "application",
                    "source_type": "OCP",
                    "cost_model_id": null
                }
            ]
        }
      
  5. Trigger a re-summary for the AWS source

  6. Then in the postgres shell, check to see that tags are updated in the EC2 table

    postgres=# select uuid, tags from reporting_awscostentrylineitem_summary_by_ec2_compute where tags ?| ARRAY['app', 'application'];
    (0 rows)
    
    postgres=# 
    
    

@djnakabaale djnakabaale self-assigned this Jun 5, 2024
@djnakabaale djnakabaale requested review from a team as code owners June 5, 2024 15:46
Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.1%. Comparing base (31f7de6) to head (4c167f9).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #5147   +/-   ##
=====================================
  Coverage   94.1%   94.1%           
=====================================
  Files        371     371           
  Lines      30927   30929    +2     
  Branches    4542    4542           
=====================================
+ Hits       29103   29105    +2     
  Misses      1163    1163           
  Partials     661     661           

@djnakabaale djnakabaale added the smoke-tests pr_check will build the image and run minimal required smokes label Jun 5, 2024
@djnakabaale
Copy link
Contributor Author

/retest

@djnakabaale djnakabaale enabled auto-merge (squash) July 12, 2024 15:43
@djnakabaale djnakabaale merged commit c08f7c6 into main Jul 12, 2024
11 checks passed
@djnakabaale djnakabaale deleted the cost-5093-ec2-tag-mapping branch July 12, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
smoke-tests pr_check will build the image and run minimal required smokes smokes-required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants