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

Clusters set auto_cores max #3778

Merged
merged 8 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion apps/dashboard/app/javascript/script_show.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeChangeHandlers } from './dynamic_forms';

jQuery(function() {
makeChangeHandlers('script');
makeChangeHandlers('launcher');
});
43 changes: 43 additions & 0 deletions apps/dashboard/app/lib/cluster_cache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#frozen_string_literal: true

module ClusterCache
def cluster_options
Rails.cache.fetch('script_cluster_options', expires_in: 4.hours) do
cluster_max_cores.map do |cluster_id, max|
[cluster_id.to_s, cluster_id.to_s, {'data-max-auto-cores': max}]
end.sort_by { |option| option[0] }
end
end

def cluster_nodes
Rails.cache.fetch('script_cluster_nodes', expires_in: 4.hours) do
{}.tap do |hash|
batch_clusters.map do |cluster|
hash[cluster.id] = cluster.job_adapter.nodes
end
end
end
end

def cluster_max_cores
Rails.cache.fetch('script_cluster_max_values', exipres_in: 4.hours) do
{}.tap do |hash|
cluster_nodes.each do |cluster_id, nodes|
hash[cluster_id] = nodes.max { |a, b| a.procs <=> b.procs }.procs
end
end
end
end

def batch_clusters
johrstrom marked this conversation as resolved.
Show resolved Hide resolved
Rails.cache.fetch('script_batch_clusters', expires_in: 4.hours) do
Configuration.job_clusters.reject do |c|
reject_cluster?(c)
end
end
end

def reject_cluster?(cluster)
cluster.kubernetes? || cluster.linux_host? || cluster.systemd?
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,20 @@

module SmartAttributes
class AttributeFactory

extend ClusterCache
# Build this attribute object. Must specify a valid directory in opts
#
# @param opts [Hash] attribute's options
# @return [Attributes::AutoBatchClusters] the attribute object
def self.build_auto_batch_clusters(opts = {})
options = batch_clusters
options = cluster_options

static_opts = {
options: options
}.merge(opts.without(:options).to_h)

Attributes::AutoBatchClusters.new('auto_batch_clusters', static_opts)
end

def self.batch_clusters
Rails.cache.fetch('script_batch_clusters', expires_in: 4.hours) do
Configuration.job_clusters.reject do |c|
reject_cluster?(c)
end.map(&:id).map(&:to_s).sort
end
end

def self.reject_cluster?(cluster)
cluster.kubernetes? || cluster.linux_host? || cluster.systemd?
end
end

module Attributes
Expand Down
Loading