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

refactor qos #3955

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions apps/dashboard/app/lib/account_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,33 @@ def queues

def dynamic_qos
Rails.cache.fetch('dynamic_qos', expires_in: 4.hours) do
accounts.map do |account|
qos_tuples = accounts.map do |account|
account.qos.map do |qos|
[account.name, account.cluster, qos]
end
end.flatten(1).map do |tuple|
other_accounts = account_names.reject { |acct| acct == tuple[0] }
other_clusters = Configuration.job_clusters.reject { |c| c.id.to_s == tuple[1] }
end.flatten(1).group_by { |tuple| tuple[2] }

data = {}.tap do |hash|
other_clusters.each do |cluster|
hash["data-option-for-cluster-#{cluster.id}"] = false
end
clusters = Configuration.job_clusters.map { |c| c.id.to_s }

other_accounts.each do |account|
hash["data-option-for-auto-accounts-#{account}"] = false
end
unique_qos_names.map do |qos|
data = {}
account_tuples = qos_tuples[qos]

available_clusters = account_tuples.map { |tuple| tuple[1] }.uniq
unavailable_clusters = clusters.reject { |c| available_clusters.include?(c) }

unavailable_clusters.each do |cluster|
data["data-option-for-cluster-#{cluster}"] = false
end

available_accounts = account_tuples.map { |tuple| tuple[0] }.uniq
unavailable_accounts = account_names.reject { |c| available_accounts.include?(c) }

unavailable_accounts.each do |account|
data["data-option-for-auto-accounts-#{account}"] = false
end

[
tuple[2], tuple[2], data
]
[qos, qos, data]
end
end
end
Expand Down