Skip to content

Add columns and file for daily billable usage#133

Merged
knikolla merged 1 commit into
CCI-MOC:mainfrom
knikolla:daily
Dec 4, 2025
Merged

Add columns and file for daily billable usage#133
knikolla merged 1 commit into
CCI-MOC:mainfrom
knikolla:daily

Conversation

@knikolla

@knikolla knikolla commented Dec 2, 2025

Copy link
Copy Markdown
Collaborator
  • Adds columns Report Start Time, Report End Time, Generated At
  • Adds uploaded daily file
  • Increases cronjob frequency to daily

Closes #131
Related nerc-project/operations#1307

@naved001 naved001 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good, just some optional suggestions

Comment thread k8s/base/cronjob.yaml Outdated
Comment thread src/openstack_billing_db/billing.py

@QuanMPhm QuanMPhm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just one question

secondary_location = (
# Upload daily copy
# End time is exclusive, subtract one second to find the inclusive end date
invoice_date = end - timedelta(seconds=1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should end be converted to UTC first, and then we can subtract a day from it? Or can we have default_start_argument and default_end_argument be in UTC?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@QuanMPhm All times processed in this script (event times for VMs coming from the database) are timezone-naive objects that are assumed to be in UTC. Comparing time-naive datetime objects with datetime objects that have a timezone associated to them leads to an error, hence the default_start_argument and default_end_argument don't have a timezone associated to them.

Though since they are fetched without providing tzinfo, they'll be in the local time of machine running the script. I could fetch them from datetime.now(timezone.utc) instead, which seems reasonable. But I'd still need to strip away the timezone to make them timezone-naive and reset them to 00:00:00.

Can you please explain your comment about subtracting 1 day instead of 1 second?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Either way, as Naved is out today and tomorrow and these changes would re-require his approval if you're okay with the current state of this PR I can make them in a future PR.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@knikolla I'm fine with the PR as it is. I'll approve it now.

Can you please explain your comment about subtracting 1 day instead of 1 second?

I had a misunderstanding about timestamps. I thought it you added timezone info to a naive timestamp, it would change the hour value for the timestamp. I didn't realize the timestamp would still numerically be the same, just no longer naive. You can disregard my comment.

@knikolla knikolla merged commit 29fc01f into CCI-MOC:main Dec 4, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add columns for report time range

3 participants