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-4742] OCP Network API #5088

Merged
merged 21 commits into from
May 31, 2024
Merged

[COST-4742] OCP Network API #5088

merged 21 commits into from
May 31, 2024

Conversation

cgoodfred
Copy link
Contributor

@cgoodfred cgoodfred commented May 4, 2024

Jira Ticket

COST-4742

Description

This change will add the network API to the provider map for OpenShift.

Testing

  1. Checkout Branch
  2. Restart Koku
  3. Load OCP on Cloud data that has unattributed network: make load-test-customer-data test_source=azure
  4. Query the API to get network usage and cost data
    http://localhost:8000/api/cost-management/v1/reports/openshift/network/
"total": {
            "usage": 134.666945631,
            "data_transfer_in": 55.341763949,
            "data_transfer_out": 79.325181682,
            "infrastructure": {
                "raw": {
                    "value": 4.306397139,
                    "units": "USD"
                },

Look at the data in the database

postgres=# SELECT 
sum(infrastructure_data_in_gigabytes + infrastructure_data_out_gigabytes) AS total,
sum(infrastructure_data_in_gigabytes) as inbound,
sum(infrastructure_data_out_gigabytes) as outbound,
sum(infrastructure_raw_cost) AS cost
FROM org1234567.reporting_ocp_network_summary_p
WHERE usage_start >= '2024-05-19';

-[ RECORD 1 ]-----------------
total    | 134.666945631000000
inbound  | 55.341763949000000
outbound | 79.325181682000000
cost     | 4.306397139000000
  1. Check group by cluster: http://localhost:8000/api/cost-management/v1/reports/openshift/network/?group_by[cluster]=*
    If you only have one cluster, this data will be the same as above, if you have more than one the totals will match but the per day records will differ.
postgres=# SELECT
sum(infrastructure_data_in_gigabytes + infrastructure_data_out_gigabytes) AS total,
sum(infrastructure_data_in_gigabytes) as inbound, sum(infrastructure_data_out_gigabytes) AS outbound,
sum(infrastructure_raw_cost) AS cost,
cluster_alias
FROM org1234567.reporting_ocp_network_summary_p
WHERE usage_start >= '2024-05-19'
GROUP BY cluster_alias;

-[ RECORD 1 ]-+--------------------
total         | 134.666945631000000
inbound       | 55.341763949000000
outbound      | 79.325181682000000
cost          | 4.306397139000000
cluster_alias | TestCluster
  1. Check group my node
    http://localhost:8000/api/cost-management/v1/reports/openshift/network/?group_by[node]=*
    If you only have one cluster, this data will be the same as above, if you have more than one the totals will match but the per day records will differ.
"date": "2024-04-25",
            "nodes": [
                {
                    "node": "azure_compute1",
                    "values": [
                        {
                            "node": "azure_compute1",
                            "date": "2024-04-25",
                            "usage": {
                                "value": 12.5,
                                "units": "GB"
                            },
                            "data_transfer_in": 5.0,
                            "data_transfer_out": 7.5,
                            "clusters": [
                                "TestCluster"
                            ],
                    ...
                    "node": "azure_compute2",
                    "values": [
                        {
                            "node": "azure_compute2",
                            "date": "2024-04-25",
                            "usage": {
                                "value": 0.679625062,
                                "units": "GB"
                            },
                            "data_transfer_in": 0.071095255,
                            "data_transfer_out": 0.608529807,
                            "clusters": [
                                "TestCluster"
                            ],
...

Look at the data

postgres=# SELECT
sum(infrastructure_data_in_gigabytes + infrastructure_data_out_gigabytes) AS total,
sum(infrastructure_data_in_gigabytes) AS inbound,
sum(infrastructure_data_out_gigabytes) AS outbound,
sum(infrastructure_raw_cost) AS cost,
node
FROM org1234567.reporting_ocp_network_summary_by_node_p
WHERE usage_start = '2024-05-19'
GROUP BY node;

-[ RECORD 1 ]----------------
total    | 12.500000000000000
inbound  | 5.000000000000000
outbound | 7.500000000000000
cost     | 0.125000000000000
node     | azure_compute1
-[ RECORD 2 ]----------------
total    | 0.679625062000000
inbound  | 0.071095255000000
outbound | 0.608529807000000
cost     | 0.123826018000000
node     | azure_compute2

Release Notes

  • proposed release note
* [COST-4742](https://issues.redhat.com/browse/COST-4742) Add API for OCP on cloud network costs

@cgoodfred cgoodfred self-assigned this May 4, 2024
Copy link

codecov bot commented May 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.1%. Comparing base (883132d) to head (540ad65).

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #5088     +/-   ##
=======================================
- Coverage   94.1%   94.1%   -0.0%     
=======================================
  Files        376     375      -1     
  Lines      31317   31170    -147     
  Branches    3759    3730     -29     
=======================================
- Hits       29474   29323    -151     
- Misses      1174    1179      +5     
+ Partials     669     668      -1     

@samdoran samdoran added the ocp-smoke-tests pr_check will build the image and run ocp + ocp on [clouds] smoke tests label May 28, 2024
@samdoran samdoran marked this pull request as ready for review May 29, 2024 15:46
@samdoran samdoran requested review from a team as code owners May 29, 2024 15:46
@samdoran samdoran enabled auto-merge (squash) May 30, 2024 17:35
@samdoran samdoran merged commit 541f699 into main May 31, 2024
10 of 11 checks passed
@samdoran samdoran deleted the COST-4742-node-network-api branch May 31, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ocp-smoke-tests pr_check will build the image and run ocp + ocp on [clouds] smoke tests smokes-required
Projects
None yet
3 participants