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-4912] Calculate node based unattributed storage (Azure) #5066

Merged
merged 55 commits into from
Jul 16, 2024

Conversation

myersCody
Copy link
Contributor

@myersCody myersCody commented Apr 24, 2024

Jira Ticket

COST-3912

Description

This change will calculate the node based unattributed storage for Azure.

Testing

  1. Checkout Branch
  2. Create the test customer
  3. Update the unleash flag:
def is_feature_unattributed_storage_enabled(account):
    """Should unattributed storage feature be enabled."""
    unleash_flag = "cost-management.backend.unattributed_storage"
    account = convert_account(account)
    context = {"schema": account}
    # TODO: Turn on fallback when QE is ready to start testing
    # UNLEASH_CLIENT.is_enabled(unleash_flag, context, fallback_development_true)
    # return UNLEASH_CLIENT.is_enabled(unleash_flag, context)
    return True
  1. make create-test-customer
  2. make load-test-customer-data test_source=Azure
  3. Ensure that the Storage unattributed namespace was populated:
select sum(infrastructure_raw_cost), resource_id from reporting_ocpusagelineitem_daily_summary where namespace='Storage unattributed' group by resource_id;
        sum        |               resource_id
-------------------+-----------------------------------------
 4.236326764000000 | pv-123-claimless
 2.337303951000000 | azure-cloud-prefix-pvc-partial-matching
 1.554439789000000 | disk-id-1234567

The claimless will be be 100% unattributed cost; however, we can check our other resource to see that the cost was split:

select namespace, sum(infrastructure_raw_cost) from reporting_ocpusagelineitem_daily_summary where resource_id='azure-cloud-prefix-pvc-partial-matching' group by namespace;
      namespace       |        sum
----------------------+-------------------
 news-site            | 0.001427496000000
 Storage unattributed | 2.337303951000000
  1. Undo the changes to the unleash flag:
git checkout -- koku/masu/processor/__init__.py

This will set it back to being False.
8. Resummarize the Azure source
9. Recheck the database to see if unattributed storage was added:

select count(*) from reporting_ocpusagelineitem_daily_summary where namespace='Storage unattributed';
 count
-------
    0
(1 row)

Release Notes

@myersCody myersCody added the azure-smoke-tests pr_check will build the image and run azure + ocp on azure smoke tests label Apr 24, 2024
@myersCody
Copy link
Contributor Author

/retest

Copy link

codecov bot commented Apr 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.1%. Comparing base (c08f7c6) to head (a7ad4b6).

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #5066     +/-   ##
=======================================
- Coverage   94.1%   94.1%   -0.0%     
=======================================
  Files        371     371             
  Lines      30929   30938      +9     
  Branches    4542    4543      +1     
=======================================
+ Hits       29107   29113      +6     
- Misses      1163    1165      +2     
- Partials     659     660      +1     

@myersCody myersCody marked this pull request as ready for review April 25, 2024 18:11
@myersCody myersCody requested review from a team as code owners April 25, 2024 18:11
@myersCody myersCody marked this pull request as draft April 25, 2024 18:15
@myersCody myersCody marked this pull request as ready for review April 26, 2024 19:27
@myersCody myersCody marked this pull request as draft April 29, 2024 17:05
@myersCody myersCody marked this pull request as ready for review April 29, 2024 19:49
@myersCody myersCody marked this pull request as draft April 30, 2024 14:45
@myersCody
Copy link
Contributor Author

Successful Azure Smoke Run

Copy link
Member

@maskarb maskarb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions and comments:

Comment on lines +394 to +399
CASE
WHEN max(persistentvolumeclaim) = ''
THEN 'Storage unattributed'
ELSE max(namespace)
END as namespace,
max(ocp.node) as node,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(question) What is the result of max(ocp.node) here for claimless PVs? Below (in lines 461-564), when inserting for Storage unattributed, the node is null, but here it seems like the node would be not null. Is that accurate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The node column is null in the ocp daily summary table for the claimless persistent volume. So, it would be null here too:

|       node        | persistentvolumeclaim |  persistentvolume   | storageclass |       resource_id        |
| NULL              |                       | pv-volume_claimless | sc_disk_one  | abc_pv-volume_claimless  |

@lcouzens lcouzens merged commit 13e2500 into main Jul 16, 2024
11 checks passed
@lcouzens lcouzens deleted the cost-4912-unattributed-storage branch July 16, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-smoke-tests pr_check will build the image and run azure + ocp on azure smoke tests smokes-required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants