Skip to content

Commit

Permalink
4.0 upgrade (#260)
Browse files Browse the repository at this point in the history
Update to 4.0

* update ondemand's initializers for 4.0 to use Rails.application.config.after_initialize blocks.
* remove NavConfig class.
* Unrelated to 4.0 - this also removes a few patches that are no longer needed.
  • Loading branch information
johrstrom authored Dec 19, 2024
1 parent 49c9ef3 commit e901a8e
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 145 deletions.
18 changes: 10 additions & 8 deletions apps.awesim.org/apps/activejobs/initializers/filter.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Add a filter by group option and insert it after the first option.
Filter.list.insert(1, Filter.new.tap { |f|
group = OodSupport::User.new.group.name
f.title = "Your Group's Jobs (#{group})"
f.filter_id = "group"
# N.B. Need to use :egroup here for now. My Oodsupport group name is 'appl' but job 'Account_Name' is 'PZS0002'
f.filter_block = Proc.new { |job| job.native[:egroup] == group || job.native[:group_name] == group || job.accounting_id.to_s.downcase == group.downcase }
})
Rails.application.config.after_initialize do
# Add a filter by group option and insert it after the first option.
Filter.list.insert(1, Filter.new.tap { |f|
group = OodSupport::User.new.group.name
f.title = "Your Group's Jobs (#{group})"
f.filter_id = "group"
# N.B. Need to use :egroup here for now. My Oodsupport group name is 'appl' but job 'Account_Name' is 'PZS0002'
f.filter_block = Proc.new { |job| job.native[:egroup] == group || job.native[:group_name] == group || job.accounting_id.to_s.downcase == group.downcase }
})
end
14 changes: 8 additions & 6 deletions apps.awesim.org/apps/activejobs/initializers/ood_clusters_fix.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
OodAppkit.clusters = OodCore::Clusters.new(
OodAppkit.clusters.reject { |cluster| [:quick_pitzer].include?(cluster.id) }
)
Rails.application.config.after_initialize do
OodAppkit.clusters = OodCore::Clusters.new(
OodAppkit.clusters.reject { |cluster| [:quick_pitzer].include?(cluster.id) }
)

if defined?(OODClusters)
OODClusters = OodCore::Clusters.new(OodAppkit.clusters.select(&:job_allow?))
end
if defined?(OODClusters)
OODClusters = OodCore::Clusters.new(OodAppkit.clusters.select(&:job_allow?))
end
end
46 changes: 26 additions & 20 deletions apps.awesim.org/apps/dashboard/initializers/ood.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# AweSim OOD config

def add_paths
OodFilesApp.candidate_favorite_paths.tap do |paths|
# add project space directories
projects = User.new.groups.map(&:name).grep(/^P./)
paths.concat projects.map { |p| Pathname.new("/fs/project/#{p}") }
Rails.application.config.after_initialize do
def add_paths
OodFilesApp.candidate_favorite_paths.tap do |paths|
# add project space directories
projects = User.new.groups.map(&:name).grep(/^P./)

# add scratch space directories
paths << Pathname.new("/fs/scratch/#{User.new.name}")
paths.concat projects.map { |p| Pathname.new("/fs/scratch/#{p}") }

# add scratch space directories
paths << Pathname.new("/fs/scratch/#{User.new.name}")
paths.concat projects.map { |p| Pathname.new("/fs/scratch/#{p}") }

# add ess scratch and project directories
paths.concat projects.map { |p| Pathname.new("/fs/ess/scratch/#{p}") }
paths.concat projects.map { |p| Pathname.new("/fs/ess/#{p}") }
paths.concat projects.map { |p| Pathname.new("/fs/ess/#{p}") }
end
end
end

fs_outage = `grep node_file_test_failure /var/lib/node_exporter/textfile_collector/autofs-file-test.prom | grep -q ' 1'; echo $?`
add_paths if fs_outage.chomp == "1" && !File.exist?('/etc/ood/config/gpfs_outage')
fs_outage = `grep node_file_test_failure /var/lib/node_exporter/textfile_collector/autofs-file-test.prom | grep -q ' 1'; echo $?`
add_paths if fs_outage.chomp == "1" && !File.exist?('/etc/ood/config/gpfs_outage')

# don't show develop dropdown unless you are setup for app sharing
Configuration.app_development_enabled = UsrRouter.base_path.directory?
Configuration.app_sharing_facls_enabled = true
require 'socket'
hostname = Socket.gethostname
case hostname
when /dev/
idp = 'https://idp-dev.osc.edu'
when /test/
idp = 'https://idp-test.osc.edu'
else
idp = 'https://idp.osc.edu'
end

ENV['OOD_DASHBOARD_HELP_CUSTOM_URL'] = "#{idp}/realms/osc/account/#/security/linked-accounts"
end

NavConfig.categories_whitelist=true
17 changes: 0 additions & 17 deletions apps.awesim.org/apps/dashboard/initializers/usr_router_patch.rb

This file was deleted.

11 changes: 5 additions & 6 deletions apps.totalsim.us/apps/dashboard/initializers/ood.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# hide all menu options
NavConfig.categories = ['Files']
NavConfig.categories_whitelist=true
Rails.application.config.after_initialize do

# enable dev mode for all configured app developers
Configuration.app_development_enabled = UsrRouter.base_path.directory?
Configuration.app_sharing_facls_enabled = true
# enable dev mode for all configured app developers
Configuration.app_development_enabled = UsrRouter.base_path.directory?
Configuration.app_sharing_facls_enabled = true
end
16 changes: 0 additions & 16 deletions class.osc.edu/apps/dashboard/initializers/k8s_core.rb

This file was deleted.

30 changes: 16 additions & 14 deletions class.osc.edu/apps/dashboard/initializers/stats2480.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
def add_paths
OodFilesApp.candidate_favorite_paths.tap do |paths|
# add project space directories
projects = User.new.groups.map(&:name).grep(/^P./)
paths.concat projects.map { |p| Pathname.new("/fs/project/#{p}") }
Rails.application.config.after_initialize do
def add_paths
OodFilesApp.candidate_favorite_paths.tap do |paths|
# add project space directories
projects = User.new.groups.map(&:name).grep(/^P./)
paths.concat projects.map { |p| Pathname.new("/fs/project/#{p}") }

# add scratch space directories
paths << Pathname.new("/fs/scratch/#{User.new.name}")
paths.concat projects.map { |p| Pathname.new("/fs/scratch/#{p}") }
# add scratch space directories
paths << Pathname.new("/fs/scratch/#{User.new.name}")
paths.concat projects.map { |p| Pathname.new("/fs/scratch/#{p}") }

# add ess scratch and project directories
paths.concat projects.map { |p| Pathname.new("/fs/ess/scratch/#{p}") }
paths.concat projects.map { |p| Pathname.new("/fs/ess/#{p}") }
# add ess scratch and project directories
paths.concat projects.map { |p| Pathname.new("/fs/ess/scratch/#{p}") }
paths.concat projects.map { |p| Pathname.new("/fs/ess/#{p}") }
end
end
end

fs_outage = `grep node_file_test_failure /var/lib/node_exporter/textfile_collector/autofs-file-test.prom | grep -q ' 1'; echo $?`
add_paths if fs_outage.chomp == "1" && !File.exist?('/etc/ood/config/gpfs_outage')
fs_outage = `grep node_file_test_failure /var/lib/node_exporter/textfile_collector/autofs-file-test.prom | grep -q ' 1'; echo $?`
add_paths if fs_outage.chomp == "1" && !File.exist?('/etc/ood/config/gpfs_outage')
end
18 changes: 10 additions & 8 deletions ondemand.osc.edu/apps/activejobs/initializers/filter.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Add a filter by group option and insert it after the first option.
Filter.list.insert(1, Filter.new.tap { |f|
group = OodSupport::User.new.group.name
f.title = "Your Group's Jobs (#{group})"
f.filter_id = "group"
# N.B. Need to use :egroup here for now. My Oodsupport group name is 'appl' but job 'Account_Name' is 'PZS0002'
f.filter_block = Proc.new { |job| job.native[:egroup] == group || job.native[:group_name] == group || job.accounting_id.to_s.downcase == group.downcase }
})
Rails.application.config.after_initialize do
# Add a filter by group option and insert it after the first option.
Filter.list.insert(1, Filter.new.tap { |f|
group = OodSupport::User.new.group.name
f.title = "Your Group's Jobs (#{group})"
f.filter_id = "group"
# N.B. Need to use :egroup here for now. My Oodsupport group name is 'appl' but job 'Account_Name' is 'PZS0002'
f.filter_block = Proc.new { |job| job.native[:egroup] == group || job.native[:group_name] == group || job.accounting_id.to_s.downcase == group.downcase }
})
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
OodAppkit.clusters = OodCore::Clusters.new(
OodAppkit.clusters.reject { |cluster| [:quick_pitzer].include?(cluster.id) }
)
Rails.application.config.after_initialize do
OodAppkit.clusters = OodCore::Clusters.new(
OodAppkit.clusters.reject { |cluster| [:quick_pitzer].include?(cluster.id) }
)

if defined?(OODClusters)
OODClusters = OodCore::Clusters.new(OodAppkit.clusters.select(&:job_allow?))
end
if defined?(OODClusters)
OODClusters = OodCore::Clusters.new(OodAppkit.clusters.select(&:job_allow?))
end
end
48 changes: 25 additions & 23 deletions ondemand.osc.edu/apps/dashboard/initializers/ood.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@

def add_paths
OodFilesApp.candidate_favorite_paths.tap do |paths|
# add project space directories
projects = User.new.groups.map(&:name).grep(/^P./)

# add scratch space directories
paths << Pathname.new("/fs/scratch/#{User.new.name}")
paths.concat projects.map { |p| Pathname.new("/fs/scratch/#{p}") }
Rails.application.config.after_initialize do
def add_paths
OodFilesApp.candidate_favorite_paths.tap do |paths|
# add project space directories
projects = User.new.groups.map(&:name).grep(/^P./)

# add scratch space directories
paths << Pathname.new("/fs/scratch/#{User.new.name}")
paths.concat projects.map { |p| Pathname.new("/fs/scratch/#{p}") }

paths.concat projects.map { |p| Pathname.new("/fs/ess/#{p}") }
paths.concat projects.map { |p| Pathname.new("/fs/ess/#{p}") }
end
end
end

fs_outage = `grep node_file_test_failure /var/lib/node_exporter/textfile_collector/autofs-file-test.prom | grep -q ' 1'; echo $?`
add_paths if fs_outage.chomp == "1" && !File.exist?('/etc/ood/config/gpfs_outage')
fs_outage = `grep node_file_test_failure /var/lib/node_exporter/textfile_collector/autofs-file-test.prom | grep -q ' 1'; echo $?`
add_paths if fs_outage.chomp == "1" && !File.exist?('/etc/ood/config/gpfs_outage')

NavConfig.categories_whitelist=true
require 'socket'
hostname = Socket.gethostname
case hostname
when /dev/
idp = 'https://idp-dev.osc.edu'
when /test/
idp = 'https://idp-test.osc.edu'
else
idp = 'https://idp.osc.edu'
end

require 'socket'
hostname = Socket.gethostname
case hostname
when /dev/
idp = 'https://idp-dev.osc.edu'
when /test/
idp = 'https://idp-test.osc.edu'
else
idp = 'https://idp.osc.edu'
ENV['OOD_DASHBOARD_HELP_CUSTOM_URL'] = "#{idp}/realms/osc/account/#/security/linked-accounts"
end
ENV['OOD_DASHBOARD_HELP_CUSTOM_URL'] = "#{idp}/realms/osc/account/#/security/linked-accounts"

5 changes: 3 additions & 2 deletions ondemand.osc.edu/apps/dashboard/initializers/usr_sharing.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Configuration.app_sharing_facls_enabled = true

Rails.application.config.after_initialize do
Configuration.app_sharing_facls_enabled = true
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Rails.application.configure do |config|
ActiveSupport.on_load(:active_record) do
Workflow.where(batch_host: 'pitzer-exp').update_all(batch_host: 'pitzer')
Workflow.where(batch_host: 'owens-slurm').update_all(batch_host: 'owens')
end if Configuration.production_database_path.file?
Rails.application.config.after_initialize do
Rails.application.configure do |config|
ActiveSupport.on_load(:active_record) do
Workflow.where(batch_host: 'pitzer-exp').update_all(batch_host: 'pitzer')
Workflow.where(batch_host: 'owens-slurm').update_all(batch_host: 'owens')
end if Configuration.production_database_path.file?
end
end

Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# array_ids is not currently exported automatically from ood_core
require 'ood_core/job/array_ids'
require 'workflow'
Rails.application.config.after_initialize do
# array_ids is not currently exported automatically from ood_core
require 'ood_core/job/array_ids'
require 'workflow'

class Workflow
validate :task_count_may_not_exceed_max_job_array_tasks
MAX_JOB_ARRAY_TASKS = 1000
class Workflow
validate :task_count_may_not_exceed_max_job_array_tasks
MAX_JOB_ARRAY_TASKS = 1000

def task_count_may_not_exceed_max_job_array_tasks
if ! task_count_ok?
errors.add(:job_array_request, "must result in less than #{Workflow::MAX_JOB_ARRAY_TASKS} tasks.")
def task_count_may_not_exceed_max_job_array_tasks
if ! task_count_ok?
errors.add(:job_array_request, "must result in less than #{Workflow::MAX_JOB_ARRAY_TASKS} tasks.")
end
end
end

def task_count_ok?
return true if (job_array_request.nil? || job_array_request.empty?)
def task_count_ok?
return true if (job_array_request.nil? || job_array_request.empty?)

OodCore::Job::ArrayIds.new(job_array_request).ids.size <= Workflow::MAX_JOB_ARRAY_TASKS
OodCore::Job::ArrayIds.new(job_array_request).ids.size <= Workflow::MAX_JOB_ARRAY_TASKS
end
end
end

0 comments on commit e901a8e

Please sign in to comment.