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-3571] generate daily reports #184

Merged
merged 52 commits into from
May 17, 2023
Merged

[COST-3571] generate daily reports #184

merged 52 commits into from
May 17, 2023

Conversation

maskarb
Copy link
Member

@maskarb maskarb commented Apr 25, 2023

COST-3571

  • only gather data for full days on initial CR creation
    • files are packaged after 96 hours of data are collected
  • when upgrading the operator, move and package the old files and regenerate data for the latest day
  • add a method for copying files instead of defaulting to moving files
    • report files generated before midnight are copied and packaged. the files remain in the data dir so we can append the rest of the days data to the file
    • after midnight, the files are moved out of the data dir and packaged

@codecov
Copy link

codecov bot commented Apr 25, 2023

Codecov Report

Merging #184 (ab2203d) into main (26f6aea) will increase coverage by 0.71%.
The diff coverage is 82.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   88.01%   88.72%   +0.71%     
==========================================
  Files          11       11              
  Lines        2328     2386      +58     
==========================================
+ Hits         2049     2117      +68     
+ Misses        200      189      -11     
- Partials       79       80       +1     
Flag Coverage Δ
unittests 88.72% <82.11%> (+0.71%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packaging/packaging.go 79.53% <66.17%> (-1.88%) ⬇️
controllers/kokumetricsconfig_controller.go 83.47% <93.54%> (+3.90%) ⬆️
collector/collector.go 86.56% <100.00%> (-0.21%) ⬇️
controllers/prometheus.go 96.03% <100.00%> (+6.67%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26f6aea...ab2203d. Read the comment docs.

@maskarb maskarb marked this pull request as ready for review April 25, 2023 17:09
@maskarb maskarb changed the title only collect full days of previous data [COST-3571] generate daily reports Apr 26, 2023
@maskarb maskarb self-assigned this May 15, 2023
@maskarb maskarb requested a review from a team May 15, 2023 15:23
t = t.Add(1 * time.Hour)
}

if r.initialDataCollection && t.Sub(startTime).Hours() == 96 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might still split into multiple files for the 4 day period? Also anything specific about the 96 mark or just feels right?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea here was to fit the number of reports into the default max of 30. Assuming a cluster has 90 days of data, this would generate 90*24/96 ~= 23 reports.

If the reports are too big and require splitting, then yea, this logic goes out the window. But it is a best effort to fit a full 90 days into 30 reports.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking about this some more, when we split a payload, that is still counted as a single report. Here is the logic for that:
https://github.com/project-koku/koku-metrics-operator/blob/main/packaging/packaging.go#L428-L435
We get the timestamp from the tar.gz and insert into a set, then count the length of the set.

All payloads from a split report use this basename:
https://github.com/project-koku/koku-metrics-operator/blob/main/packaging/packaging.go#L517

which is just TIMESTAMP-cost-mgmt...

@maskarb maskarb merged commit 4706e91 into main May 17, 2023
@maskarb maskarb deleted the collect-full-days-previous branch May 17, 2023 16:35
maskarb added a commit that referenced this pull request Sep 8, 2023
* only gather data for full days on initial CR creation

* files are packaged after 96 hours of data are collected

* when upgrading the operator, move and package the old files and regenerate data for the latest day

* add a method for copying files instead of defaulting to moving files

* report files generated before midnight are copied and packaged. the files remain in the data dir so we can append the rest of the days data to the file

* after midnight, the files are moved out of the data dir and packaged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants