Uploaded image for project: 'Cost Management'
  1. Cost Management
  2. COST-2783

DataError: division by zero

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Normal Normal
    • None
    • None
    • None
    • False
    • None
    • False

      It would seem that we can divide by zero in this function:
      https://github.com/project-koku/koku/blob/main/koku/masu/database/ocp_report_db_accessor.py#L1497-L1514

      This aggregation is likely returning zero:

      cluster_hours = (
        OCPUsageLineItemDailySummary.objects.filter(
          usage_start__gte=start_date, usage_start__lt=end_date, cluster_id=cluster_id
        ).aggregate(cluster_hours=Sum(usage_column))
      ).get("cluster_hours")
      

      which is passed into this expression:

      Sum(usage_column) / cluster_hours * cluster_cost
      

      It feels like this is a first of the month issue, but we should handle the case where the cluster_hours is zero.

              Unassigned Unassigned
              mskarbek Michael Skarbek
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: