Skip to content

Commit

Permalink
[COST-4209] remove schedule flag from orchestrator (#4694)
Browse files Browse the repository at this point in the history
* remove schedule flag from orchestrator

* remove the kwargs from the celery task

* do not send OCP providers to the Orchestrator when created (unless in dev mode)
  • Loading branch information
maskarb authored Sep 21, 2023
1 parent e30e40c commit 84d93d5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
3 changes: 3 additions & 0 deletions koku/api/provider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def save(self, *args, **kwargs):
super().save(*args, **kwargs)

if settings.AUTO_DATA_INGEST and should_ingest and self.active:
if self.type == Provider.PROVIDER_OCP and not settings.DEBUG:
# OCP Providers are not pollable, so shouldn't go thru check_report_updates
return
# Local import of task function to avoid potential import cycle.
from masu.celery.tasks import check_report_updates

Expand Down
2 changes: 1 addition & 1 deletion koku/koku/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def validate_cron_expression(expresssion):
CHECK_REPORT_UPDATES_DEF = {
"task": download_task,
"schedule": report_schedule,
"kwargs": {"scheduled": True},
"kwargs": {},
}
app.conf.beat_schedule["check-report-updates-batched"] = CHECK_REPORT_UPDATES_DEF

Expand Down
1 change: 0 additions & 1 deletion koku/masu/api/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def download_report(request):
async_download_result = check_report_updates.delay(
provider_uuid=provider_uuid,
provider_type=provider_type,
scheduled=False,
bill_date=bill_date,
summarize_reports=summarize_reports,
)
Expand Down
4 changes: 1 addition & 3 deletions koku/masu/processor/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def __init__(
self,
provider_uuid=None,
provider_type=None,
scheduled=True,
bill_date=None,
queue_name=None,
**kwargs,
Expand All @@ -63,14 +62,13 @@ def __init__(
self.bill_date = bill_date
self.provider_uuid = provider_uuid
self.provider_type = provider_type
self.scheduled = scheduled
self.queue_name = queue_name
self.ingress_reports = kwargs.get("ingress_reports")
self.ingress_report_uuid = kwargs.get("ingress_report_uuid")
self._summarize_reports = kwargs.get("summarize_reports", True)

def get_polling_batch(self):
if not self.scheduled and self.provider_uuid:
if self.provider_uuid:
providers = Provider.objects.filter(uuid=self.provider_uuid)
else:
filters = {}
Expand Down
9 changes: 3 additions & 6 deletions koku/masu/test/processor/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,13 @@ def test_get_reports(self, fake_accessor, mock_inspect):
def test_orchestrator_args_polling_batch(self, *args):
"""Test that args to Orchestrator change the polling-batch result"""
# providing a UUID overrides the polling timestamp
o = Orchestrator(
provider_uuid=self.aws_provider_uuid,
scheduled=False,
)
o = Orchestrator(provider_uuid=self.aws_provider_uuid)
p = o.get_polling_batch()
self.assertEqual(len(p), 1)

# provider provider-type does NOT override polling timestamp
# so this query will provide zero pollable providers
o = Orchestrator(scheduled=False, provider_type="AWS-local")
o = Orchestrator(provider_type="AWS-local")
p = o.get_polling_batch()
self.assertEqual(len(p), 0)

Expand All @@ -465,7 +462,7 @@ def test_orchestrator_args_polling_batch(self, *args):
p.polling_timestamp = None
p.save()

o = Orchestrator(scheduled=False, provider_type="AWS-local")
o = Orchestrator(provider_type="AWS-local")
p = o.get_polling_batch()
self.assertGreater(len(p), 0)
self.assertEqual(len(p), expected_providers.count())

0 comments on commit 84d93d5

Please sign in to comment.