-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RecurringLogic to update HostResources
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.
- Loading branch information
1 parent
0ca279a
commit 4885f93
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
lib/foreman_resource_quota/async/refresh_resource_quota_utilization.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module ForemanResourceQuota | ||
module Async | ||
class RefreshResourceQuotaUtilization < ::Actions::EntryAction | ||
include ::Actions::RecurringAction | ||
|
||
def run | ||
ResourceQuota.all.each do |quota| | ||
quota.determine_utilization | ||
rescue e | ||
logger.error N_(format("An error occured determining the utilization of '%s'-quota: %s", quota.name, e)) | ||
end | ||
end | ||
|
||
def logger | ||
action_logger | ||
end | ||
|
||
def rescue_strategy_for_self | ||
Dynflow::Action::Rescue::Fail | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters