Skip to content
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

Switch to async foreman-tasks-based utilization trigger #75

Merged
merged 4 commits into from
Nov 27, 2024

Conversation

bastian-src
Copy link
Contributor

Instead of re-calculating the resource quota utilization on every host-deployment, use the last utilization and re-calculate it every day with a foreman-tasks Recurring Logic

Is part of #11

@bastian-src bastian-src force-pushed the feature/add_utilization_job branch 19 times, most recently from f4b0dd9 to a20dac2 Compare November 27, 2024 10:49
* foreman-tasks >= 10.0, < 11
* theforeman-rubocop ~> 0.1.0
Add task RefreshResourceQuotaUtilization which calls determine_utilization
on every ResourceQuota. The command iterates all hosts of a ResourceQuota
and sets the host.host_resources which is used for the ResourceQuota.utilization.

This guarantees that Foreman does not miss changes to HostResources,
when they are not performed via the Foreman UI. Moreover, it increases
performance since Foreman Resource Quota does not re-compute a
ResourceQuota's utilization on host deployment and, instead, takes
the last-computed sum of HostResources.

However, this comes with the downside that HostResources might be missed
when edited out-of Foreman UI and new hosts are deployed before the
task is executed.
A Hosts's HostResources are determined during the validation step but not saved,
because the Host must exist before its HostResources can be stored (not-null database constraint).
We add a routine which saves the HostResources immediately after a Host is saved in case its Host.host_resources changed
@bastian-src bastian-src force-pushed the feature/add_utilization_job branch from a20dac2 to 3d09d93 Compare November 27, 2024 12:45
@bastian-src bastian-src self-assigned this Nov 27, 2024
@bastian-src
Copy link
Contributor Author

The failing packit job is caused by a missing foreman-tasks dependency on the foreman-packaging:rubygem-foreman_resource_quota.spec file. Adding this with a new release.

@bastian-src bastian-src merged commit a456cc8 into main Nov 27, 2024
20 of 21 checks passed
@bastian-src bastian-src deleted the feature/add_utilization_job branch November 27, 2024 14:18
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.

2 participants