-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement optimistic resource quota utilization computation #60
base: main
Are you sure you want to change the base?
Conversation
validate :verify_resource_quota_on_create, if: -> { new_record? } | ||
validate :verify_resource_quota_on_change, if: -> { resource_quota_id_change_to_be_saved && !new_record? } |
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.
validate :verify_resource_quota_on_create, if: -> { new_record? } | |
validate :verify_resource_quota_on_change, if: -> { resource_quota_id_change_to_be_saved && !new_record? } | |
validate :verify_resource_quota_on_host_create, if: -> { new_record? } | |
validate :verify_resource_quota_on_resource_quota_change, if: -> { resource_quota_id_change_to_be_saved && !new_record? } |
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.
Even better: Merge the two methods into one.
|
||
host_resources.each do |resource_type, resource_value| | ||
new_utilization[resource_type] ||= 0 | ||
new_utilization[resource_type] = yield(new_utilization[resource_type], resource_value, resource_type) |
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.
Try to simplify the code such that it is easier to understand.
2ba48da
to
a34fedc
Compare
Use resource_quota instead of resource_quota_id for form selector and parameter filter extension
fdf8253
to
e5798e9
Compare
Instead of re-computing the Resource Quota utilization by iterating all Resource Quota hosts and determining their resources, an optimistic tracking of the utilized resources is implemented.
When a host is created/added to a Resource Quota, its resources are determined once and added to the Resource Quota utilization. When a host is destroyed/unassigned from a Resource Quota, its utilization is freed from the host's resource capacities.