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-5851] one expiration task per provider_type #5432

Merged
merged 9 commits into from
Jan 28, 2025

Conversation

maskarb
Copy link
Member

@maskarb maskarb commented Jan 2, 2025

Jira Ticket

COST-5851

Description

This change will:

  • utilize cascade_delete to remove the expired OCPUsageReportPeriod instead of the Django delete method
  • run one data expiration task per schema per provider_type, rather than 1 task per provider
  • order the deletions so OCP is triggered last (because we run multiple workers, it's still possible that OCP will delete concurrently to the Cloud providers, but tis best effort)

Testing

  1. load test data:
$ make create-test-customer; make load-test-customer-data test_source=AWS
  1. check for report data when done ingesting:
    http://localhost:8000/api/cost-management/v1/reports/aws/costs/?filter[time_scope_value]=-30
    (see data for 2 months)
  2. set RETAIN_NUM_MONTHS=1 and restart koku-worker
  3. open a python shell:
$ REDIS_HOST=localhost make shell

(set the REDIS_HOST so that the shell can reach Redis)

  1. use the Orchestrator to trigger a deletion:
>>> from masu.processor.orchestrator import Orchestrator
>>> orchestrator = Orchestrator()
>>> orchestrator.remove_expired_report_data(simulate=False)
[
    {"schema": "org1234567", "provider_type": "GCP-local", "async_id": "6f896ddc-7590-4d8e-8279-a4bd428c6651"},
    {"schema": "org1234567", "provider_type": "IBM-local", "async_id": "390a5303-91a2-4c96-94f4-0b7a8b65d99f"},
    {"schema": "org1234567", "provider_type": "AWS-local", "async_id": "efdd8a49-a13e-4592-846d-6f46ee197d1e"},
    {"schema": "org1234567", "provider_type": "Azure-local", "async_id": "0122ac56-020e-4fab-b624-77245c54a18b"},
    {"schema": "org1234567", "provider_type": "OCI-local", "async_id": "e0b624e6-7b3b-4383-8c93-f9342b084ddc"},
    {"schema": "org1234567", "provider_type": "OCP", "async_id": "b56d2cf2-6d2e-4988-a4ac-a0971c6b3c50"},
]

See that each provider-type only appears once in the result list AND OCP is called last.

  1. clear redis cache:
make delete-redis-cache
  1. Revisit the report endpoint and see data only exists for the current month:
    http://localhost:8000/api/cost-management/v1/reports/aws/costs/?filter[time_scope_value]=-30

Release Notes

  • proposed release note
* [COST-5851](https://issues.redhat.com/browse/COST-5851) ordered data expiration per provider type

@maskarb maskarb added the smoke-tests pr_check will build the image and run minimal required smokes label Jan 2, 2025
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.1%. Comparing base (7a51af4) to head (74bb1bf).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #5432     +/-   ##
=======================================
- Coverage   94.1%   94.1%   -0.0%     
=======================================
  Files        371     371             
  Lines      31631   31635      +4     
  Branches    3386    3389      +3     
=======================================
+ Hits       29770   29773      +3     
  Misses      1211    1211             
- Partials     650     651      +1     

@maskarb maskarb marked this pull request as ready for review January 27, 2025 20:32
@maskarb maskarb requested review from a team as code owners January 27, 2025 20:32
@maskarb
Copy link
Member Author

maskarb commented Jan 27, 2025

/retest

@maskarb maskarb changed the title one expiration task per provider type [COST-5851] one expiration task per provider_type Jan 27, 2025
@maskarb
Copy link
Member Author

maskarb commented Jan 28, 2025

/retest

Copy link
Contributor

@djnakabaale djnakabaale left a comment

Choose a reason for hiding this comment

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

looks good to me, one small nitpick:

koku/masu/processor/ocp/ocp_report_db_cleaner.py Outdated Show resolved Hide resolved
@maskarb maskarb merged commit 162a221 into main Jan 28, 2025
14 checks passed
@maskarb maskarb deleted the data-expiration-updates branch January 28, 2025 17:25
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.

2 participants