-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add classes to model pod metrics and project invoices. #78
Conversation
fe56aae
to
289c4ae
Compare
openshift_metrics/invoice.py
Outdated
gpu_request: Decimal, | ||
memory_request: Decimal, | ||
gpu_type: str, | ||
gpu_resource: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I should add namespace, the kubernetes node label, and the node model as part of a pod definition. Those would come in handy when I produce reports by pods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and most importantly the name of the pod itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some comments I have so far. Mostly minor changes. Sorry if I missed anything!
openshift_metrics/invoice.py
Outdated
elif gpu_type == GPU_A100_SXM4: # for MIG GPU of type A100_SXM4 | ||
su_type = A100_SXM4_MIG.get(gpu_resource, SU_UNKNOWN_MIG_GPU) | ||
else: | ||
return SU_UNKNOWN_GPU, 0, "GPU" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these return statements use the ServiceUnit
tuple like this?:
return ServiceUnit(SU_UNKNOWN_GPU, 0, "GPU")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes they should! good catch.
openshift_metrics/invoice.py
Outdated
|
||
# pods that requested a specific GPU but weren't scheduled may report 0 GPU | ||
if gpu_resource is not None and gpu_count == 0: | ||
return SU_UNKNOWN_GPU, 0, "GPU" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
openshift_metrics/invoice.py
Outdated
|
||
return ServiceUnit(su_type, su_count, determining_resource) | ||
|
||
def get_runtime(self, ignore_hours=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of the ignore_hours
argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should remove this, I plan to add a feature to ignore certain hours from calculating runtime. I'll add this in argument when I add that feature.
289c4ae
to
34beebe
Compare
The class `Pod` represent a pod's metrics and exposes methods to get the service unit and runtime of a pod. The service unit information is returned as a namedtuples. The method to get runtime will allow us to ignore certain hours, though, that will be added in a later commit. The class `ProjectInvoice` represents invoice data for a project. It has a method that takes in a pod and aggregates it's usage data. Another method `generate_invoice_rows` will return the csv data to be exported. The caller write_metrics_by_namespace has been updated to use these new classes. Tests have been updated to work with the new changes. There's some duplicate constants that I will sort in the next few commits.
34beebe
to
d93b2d7
Compare
The class
Pod
represent a pod's metrics and exposes methods to get the service unit and runtime of a pod. The service unit information is returned as a namedtuple. The method to get runtime will allow us to ignore certain hours, though, that will be added in a later commit.The class
ProjectInvoice
represents invoice data for a project. It has a method that takes in a pod and aggregates it's usage data. Another methodgenerate_invoice_rows
will return the csv data to be exported.The caller write_metrics_by_namespace has been updated to use these new classes.
Tests have been updated to work with the new changes. There's some duplicate constants that I will sort in the next few commits.
The method write_metrics_by_pod isn't updated yet since it's not critical and I wanted to keep the size of this PR down.