feat: implement collection runs tracking and error acknowledgment features
This commit is contained in:
1 parent
c39364eda4
commit
34903492f6
14 files changed
+484
-21
No files matched your search
@@ -29,6 +29,7 @@ sys.path.insert(0, str(Path(__file__).parent))
|
||||
from db import (
|
||||
get_connection, init_db, upsert_collection,
|
||||
upsert_resource_costs, set_resource_collection_status,
|
||||
start_collection_run, finish_collection_run,
|
||||
)
|
||||
from providers import (
|
||||
get_aws_cost, get_azure_cost, convert_result,
|
||||
@@ -148,15 +149,23 @@ def main():
|
||||
resource_period_end = target_day + timedelta(days=1)
|
||||
resource_period_start = resource_period_end - timedelta(days=RESOURCE_WINDOW_DAYS)
|
||||
|
||||
run_id = start_collection_run(conn, "daily")
|
||||
tenants_ok = 0
|
||||
tenants_error = 0
|
||||
|
||||
for provider, entries in (("aws", config.get("aws", [])), ("azure", config.get("azure", []))):
|
||||
for entry in entries:
|
||||
ok = collect_tenant(conn, provider, entry, period_start, period_end)
|
||||
if ok:
|
||||
tenants_ok += 1
|
||||
collect_tenant_resources(
|
||||
conn, provider, entry,
|
||||
resource_period_start.isoformat(), resource_period_end.isoformat(),
|
||||
)
|
||||
else:
|
||||
tenants_error += 1
|
||||
|
||||
finish_collection_run(conn, run_id, tenants_ok, tenants_error)
|
||||
conn.close()
|
||||
log.info("Terminé.")
|
||||
|
||||
|
||||
Reference in new issue
Block a user