CCI-MOC / openstack-billing-from-db

Simple billing from the database
Apache License 2.0
1 stars 3 forks source link

Issue with TypeError on `pci_requests` #59

Closed knikolla closed 5 months ago

knikolla commented 5 months ago

Seems like something weird happened with the database resulting in pci_requests being a NoneType and resulting in a TypeError. Which broke the cronjob.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/openstack_billing_db/main.py", line 205, in <module>
    main()
  File "/app/openstack_billing_db/main.py", line 192, in main
    billing.generate_billing(
  File "/app/openstack_billing_db/billing.py", line 221, in generate_billing
    invoices = collect_invoice_data_from_openstack(database, start, end, rates)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openstack_billing_db/billing.py", line 83, in collect_invoice_data_from_openstack
    for project in database.projects:
                   ^^^^^^^^^^^^^^^^^
  File "/app/openstack_billing_db/model.py", line 191, in projects
    self._projects = self.get_projects()
                     ^^^^^^^^^^^^^^^^^^^
  File "/app/openstack_billing_db/model.py", line 284, in get_projects
    instances=self.get_instances(project[0])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openstack_billing_db/model.py", line 231, in get_instances
    pci_info = json.loads(instance["pci_requests"])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

More weirdly, after adding a try/catch with a warning printed the instance UUID causing this is reported as all zeroes. /shrug

WARNING:openstack_billing_db.model:Could not parse pci requests from 00000000-0000-0000-0000-000000000000.