From 7baff32e82b0bfc961dc9a285da8ce187d4fe0b6 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 21 Mar 2019 12:38:09 -0400 Subject: [PATCH] 13996: More config updates Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../app/models/api_client_authorization.rb | 10 ++--- services/api/app/models/collection.rb | 24 ++++++----- services/api/app/models/commit_ancestor.rb | 2 +- services/api/app/models/container.rb | 4 +- services/api/app/models/container_request.rb | 6 +-- services/api/app/models/node.rb | 41 ++++++++++--------- .../views/admin_notifier/new_user.text.erb | 3 +- services/api/lib/audit_logs.rb | 4 +- services/api/lib/crunch_dispatch.rb | 34 +++++++-------- services/api/lib/enable_jobs_api.rb | 7 ++-- services/api/lib/josh_id.rb | 2 +- services/api/lib/load_param.rb | 2 +- services/api/lib/log_reuse_info.rb | 2 +- services/api/lib/refresh_permission_view.rb | 4 +- services/api/lib/sweep_trashed_objects.rb | 4 +- .../lib/tasks/delete_old_container_logs.rake | 2 +- .../api/lib/tasks/delete_old_job_logs.rake | 2 +- services/api/lib/trashable.rb | 6 +-- 18 files changed, 81 insertions(+), 78 deletions(-) diff --git a/services/api/app/models/api_client_authorization.rb b/services/api/app/models/api_client_authorization.rb index 38538cb4ff..fc8ae52820 100644 --- a/services/api/app/models/api_client_authorization.rb +++ b/services/api/app/models/api_client_authorization.rb @@ -94,7 +94,7 @@ class ApiClientAuthorization < ArvadosModel def self.validate(token:, remote: nil) return nil if !token - remote ||= Rails.configuration.uuid_prefix + remote ||= Rails.configuration.ClusterID case token[0..2] when 'v2/' @@ -134,7 +134,7 @@ class ApiClientAuthorization < ArvadosModel end uuid_prefix = uuid[0..4] - if uuid_prefix == Rails.configuration.uuid_prefix + if uuid_prefix == Rails.configuration.ClusterID # If the token were valid, we would have validated it above return nil elsif uuid_prefix.length != 5 @@ -153,7 +153,7 @@ class ApiClientAuthorization < ArvadosModel # [re]validate it. begin clnt = HTTPClient.new - if Rails.configuration.sso_insecure + if Rails.configuration.TLS["Insecure"] clnt.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE else # Use system CA certificates @@ -164,7 +164,7 @@ class ApiClientAuthorization < ArvadosModel end remote_user = SafeJSON.load( clnt.get_content('https://' + host + '/arvados/v1/users/current', - {'remote' => Rails.configuration.uuid_prefix}, + {'remote' => Rails.configuration.ClusterID}, {'Authorization' => 'Bearer ' + token})) rescue => e Rails.logger.warn "remote authentication with token #{token.inspect} failed: #{e}" @@ -187,7 +187,7 @@ class ApiClientAuthorization < ArvadosModel end end - if Rails.configuration.new_users_are_active || + if Rails.configuration.Users["NewUsersAreActive"] || Rails.configuration.auto_activate_users_from.include?(remote_user['uuid'][0..4]) # Update is_active to whatever it is at the remote end user.is_active = remote_user['is_active'] diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index 590228b1af..536653fa1f 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -125,7 +125,7 @@ class Collection < ArvadosModel # Signature provided, but verify_signature did not like it. logger.warn "Invalid signature on locator #{tok}" raise ArvadosModel::PermissionDeniedError - elsif Rails.configuration.permit_create_collection_with_unsigned_manifest + elsif Rails.configuration.Collections["BlobSigning"] # No signature provided, but we are running in insecure mode. logger.debug "Missing signature on locator #{tok} ignored" elsif Blob.new(tok).empty? @@ -323,9 +323,9 @@ class Collection < ArvadosModel end def should_preserve_version? - return false unless (Rails.configuration.collection_versioning && versionable_updates?(self.changes.keys)) + return false unless (Rails.configuration.Collections["CollectionVersioning"] && versionable_updates?(self.changes.keys)) - idle_threshold = Rails.configuration.preserve_version_if_idle + idle_threshold = Rails.configuration.Collections["PreserveVersionIfIdle"] if !self.preserve_version_was && (idle_threshold < 0 || (idle_threshold > 0 && self.modified_at_was > db_current_time-idle_threshold.seconds)) @@ -371,7 +371,7 @@ class Collection < ArvadosModel return manifest_text else token = Thread.current[:token] - exp = [db_current_time.to_i + Rails.configuration.blob_signature_ttl, + exp = [db_current_time.to_i + Rails.configuration.Collections["BlobSigningTTL"], trash_at].compact.map(&:to_i).min self.class.sign_manifest manifest_text, token, exp end @@ -379,7 +379,7 @@ class Collection < ArvadosModel def self.sign_manifest manifest, token, exp=nil if exp.nil? - exp = db_current_time.to_i + Rails.configuration.blob_signature_ttl + exp = db_current_time.to_i + Rails.configuration.Collections["BlobSigningTTL"] end signing_opts = { api_token: token, @@ -489,7 +489,7 @@ class Collection < ArvadosModel # # If filter_compatible_format is true (the default), only return image # collections which are support by the installation as indicated by - # Rails.configuration.docker_image_formats. Will follow + # Rails.configuration.Containers["SupportedDockerImageFormats"]. Will follow # 'docker_image_migration' links if search_term resolves to an incompatible # image, but an equivalent compatible image is available. def self.find_all_for_docker_image(search_term, search_tag=nil, readers=nil, filter_compatible_format: true) @@ -500,15 +500,17 @@ class Collection < ArvadosModel joins("JOIN collections ON links.head_uuid = collections.uuid"). order("links.created_at DESC") - if (Rails.configuration.docker_image_formats.include? 'v1' and - Rails.configuration.docker_image_formats.include? 'v2') or filter_compatible_format == false + docker_image_formats = Rails.configuration.Containers["SupportedDockerImageFormats"] + + if (docker_image_formats.include? 'v1' and + docker_image_formats.include? 'v2') or filter_compatible_format == false pattern = /^(sha256:)?[0-9A-Fa-f]{64}\.tar$/ - elsif Rails.configuration.docker_image_formats.include? 'v2' + elsif docker_image_formats.include? 'v2' pattern = /^(sha256:)[0-9A-Fa-f]{64}\.tar$/ - elsif Rails.configuration.docker_image_formats.include? 'v1' + elsif docker_image_formats.include? 'v1' pattern = /^[0-9A-Fa-f]{64}\.tar$/ else - raise "Unrecognized configuration for docker_image_formats #{Rails.configuration.docker_image_formats}" + raise "Unrecognized configuration for docker_image_formats #{docker_image_formats}" end # If the search term is a Collection locator that contains one file diff --git a/services/api/app/models/commit_ancestor.rb b/services/api/app/models/commit_ancestor.rb index 3d5152c3ff..60798f1039 100644 --- a/services/api/app/models/commit_ancestor.rb +++ b/services/api/app/models/commit_ancestor.rb @@ -17,7 +17,7 @@ class CommitAncestor < ActiveRecord::Base protected def ask_git_whether_is - @gitdirbase = Rails.configuration.git_repositories_dir + @gitdirbase = Rails.configuration.Git["Repositories"] self.is = nil Dir.foreach @gitdirbase do |repo| next if repo.match(/^\./) diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index fb900a993d..a95a166ddb 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -205,7 +205,7 @@ class Container < ArvadosModel rc = {} defaults = { 'keep_cache_ram' => - Rails.configuration.container_default_keep_cache_ram, + Rails.configuration.Containers["DefaultKeepCacheRAM"], } defaults.merge(runtime_constraints).each do |k, v| if v.is_a? Array @@ -368,7 +368,7 @@ class Container < ArvadosModel transaction do reload(lock: 'FOR UPDATE') check_unlock_fail - if self.lock_count < Rails.configuration.max_container_dispatch_attempts + if self.lock_count < Rails.configuration.Containers["MaxDispatchAttempts"] update_attributes!(state: Queued) else update_attributes!(state: Cancelled, diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb index 292decafbf..f2e3d31220 100644 --- a/services/api/app/models/container_request.rb +++ b/services/api/app/models/container_request.rb @@ -196,7 +196,7 @@ class ContainerRequest < ArvadosModel self.mounts ||= {} self.secret_mounts ||= {} self.cwd ||= "." - self.container_count_max ||= Rails.configuration.container_count_max + self.container_count_max ||= Rails.configuration.Containers["MaxComputeVMs"] self.scheduling_parameters ||= {} self.output_ttl ||= 0 self.priority ||= 0 @@ -252,7 +252,7 @@ class ContainerRequest < ArvadosModel if self.state == Committed # If preemptible instances (eg: AWS Spot Instances) are allowed, # ask them on child containers by default. - if Rails.configuration.preemptible_instances and !c.nil? and + if Rails.configuration.Containers["UsePreemptibleInstances"] and !c.nil? and self.scheduling_parameters['preemptible'].nil? self.scheduling_parameters['preemptible'] = true end @@ -322,7 +322,7 @@ class ContainerRequest < ArvadosModel scheduling_parameters['partitions'].size) errors.add :scheduling_parameters, "partitions must be an array of strings" end - if !Rails.configuration.preemptible_instances and scheduling_parameters['preemptible'] + if !Rails.configuration.Containers["UsePreemptibleInstances"] and scheduling_parameters['preemptible'] errors.add :scheduling_parameters, "preemptible instances are not allowed" end if scheduling_parameters.include? 'max_run_time' and diff --git a/services/api/app/models/node.rb b/services/api/app/models/node.rb index 148dffc230..3c4712fded 100644 --- a/services/api/app/models/node.rb +++ b/services/api/app/models/node.rb @@ -39,7 +39,7 @@ class Node < ArvadosModel api_accessible :superuser, :extend => :user do |t| t.add :first_ping_at t.add :info - t.add lambda { |x| Rails.configuration.compute_node_nameservers }, :as => :nameservers + t.add lambda { |x| Rails.configuration.Containers["SLURM"]["Managed"]["ComputeNodeNameservers"] }, :as => :nameservers end after_initialize do @@ -47,7 +47,7 @@ class Node < ArvadosModel end def domain - super || Rails.configuration.compute_node_domain + super || Rails.configuration.Containers["SLURM"]["Managed"]["ComputeNodeDomain"] end def api_job_uuid @@ -143,7 +143,7 @@ class Node < ArvadosModel protected def assign_hostname - if self.hostname.nil? and Rails.configuration.assign_node_hostname + if self.hostname.nil? and Rails.configuration.Containers["SLURM"]["Managed"]["AssignNodeHostname"] self.hostname = self.class.hostname_for_slot(self.slot_number) end end @@ -159,7 +159,7 @@ class Node < ArvadosModel # query label: 'Node.available_slot_number', # [col_id, val] for $1 vars: - [[nil, Rails.configuration.max_compute_nodes]], + [[nil, Rails.configuration.Containers["MaxComputeVMs"]]], ).rows.first.andand.first end @@ -194,24 +194,24 @@ class Node < ArvadosModel template_vars = { hostname: hostname, - uuid_prefix: Rails.configuration.uuid_prefix, + uuid_prefix: Rails.configuration.ClusterID, ip_address: ip_address, ptr_domain: ptr_domain, } - if Rails.configuration.dns_server_conf_dir and Rails.configuration.dns_server_conf_template + if Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"] and Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"] tmpfile = nil begin begin - template = IO.read(Rails.configuration.dns_server_conf_template) + template = IO.read(Rails.configuration.Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"]) rescue IOError, SystemCallError => e - logger.error "Reading #{Rails.configuration.dns_server_conf_template}: #{e.message}" + logger.error "Reading #{Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"]}: #{e.message}" raise end - hostfile = File.join Rails.configuration.dns_server_conf_dir, "#{hostname}.conf" + hostfile = File.join Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"], "#{hostname}.conf" Tempfile.open(["#{hostname}-", ".conf.tmp"], - Rails.configuration.dns_server_conf_dir) do |f| + Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"]) do |f| tmpfile = f.path f.puts template % template_vars end @@ -227,20 +227,20 @@ class Node < ArvadosModel end end - if Rails.configuration.dns_server_update_command - cmd = Rails.configuration.dns_server_update_command % template_vars + if Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerUpdateCommand"] + cmd = Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerUpdateCommand"] % template_vars if not system cmd logger.error "dns_server_update_command #{cmd.inspect} failed: #{$?}" ok = false end end - if Rails.configuration.dns_server_conf_dir and Rails.configuration.dns_server_reload_command - restartfile = File.join(Rails.configuration.dns_server_conf_dir, 'restart.txt') + if Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"] and Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerReloadCommand"] + restartfile = File.join(Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"], 'restart.txt') begin File.open(restartfile, 'w') do |f| # Typically, this is used to trigger a dns server restart - f.puts Rails.configuration.dns_server_reload_command + f.puts Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerReloadCommand"] end rescue IOError, SystemCallError => e logger.error "Unable to write #{restartfile}: #{e.message}" @@ -252,7 +252,7 @@ class Node < ArvadosModel end def self.hostname_for_slot(slot_number) - config = Rails.configuration.assign_node_hostname + config = Rails.configuration.Containers["SLURM"]["Managed"]["AssignNodeHostname"] return nil if !config @@ -261,10 +261,13 @@ class Node < ArvadosModel # At startup, make sure all DNS entries exist. Otherwise, slurmctld # will refuse to start. - if Rails.configuration.dns_server_conf_dir and Rails.configuration.dns_server_conf_template and Rails.configuration.assign_node_hostname - (0..Rails.configuration.max_compute_nodes-1).each do |slot_number| + if (Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"] and + Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"] and + Rails.configuration.Containers["SLURM"]["Managed"]["AssignNodeHostname"]) + + (0..Rails.configuration.Containers["MaxComputeVMs"]-1).each do |slot_number| hostname = hostname_for_slot(slot_number) - hostfile = File.join Rails.configuration.dns_server_conf_dir, "#{hostname}.conf" + hostfile = File.join Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"], "#{hostname}.conf" if !File.exist? hostfile n = Node.where(:slot_number => slot_number).first if n.nil? or n.ip_address.nil? diff --git a/services/api/app/views/admin_notifier/new_user.text.erb b/services/api/app/views/admin_notifier/new_user.text.erb index d21513f7f0..20a36afcbf 100644 --- a/services/api/app/views/admin_notifier/new_user.text.erb +++ b/services/api/app/views/admin_notifier/new_user.text.erb @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0 %> <% add_to_message = '' - if Rails.configuration.auto_setup_new_users + if Rails.configuration.Users["AutoSetupNewUsers"] add_to_message = @user.is_invited ? ' and setup' : ', but not setup' end %> @@ -22,4 +22,3 @@ Please see workbench for more information: <% end -%> Thanks, Your friendly Arvados robot. - diff --git a/services/api/lib/audit_logs.rb b/services/api/lib/audit_logs.rb index 56fd935f3f..4116ae0df8 100644 --- a/services/api/lib/audit_logs.rb +++ b/services/api/lib/audit_logs.rb @@ -44,8 +44,8 @@ module AuditLogs end def self.tidy_in_background - max_age = Rails.configuration.max_audit_log_age - max_batch = Rails.configuration.max_audit_log_delete_batch + max_age = Rails.configuration.AuditLogs["MaxAge"] + max_batch = Rails.configuration.AuditLogs["MaxDeleteBatch"] return if max_age <= 0 || max_batch <= 0 exp = (max_age/14).seconds diff --git a/services/api/lib/crunch_dispatch.rb b/services/api/lib/crunch_dispatch.rb index 449d7d5162..eceada5a7a 100644 --- a/services/api/lib/crunch_dispatch.rb +++ b/services/api/lib/crunch_dispatch.rb @@ -31,13 +31,13 @@ class CrunchDispatch @cgroup_root = ENV['CRUNCH_CGROUP_ROOT'] @srun_sync_timeout = ENV['CRUNCH_SRUN_SYNC_TIMEOUT'] - @arvados_internal = Rails.configuration.git_internal_dir + @arvados_internal = Rails.configuration.Containers["JobsAPI"]["GitInternalDir"] if not File.exist? @arvados_internal $stderr.puts `mkdir -p #{@arvados_internal.shellescape} && git init --bare #{@arvados_internal.shellescape}` raise "No internal git repository available" unless ($? == 0) end - @repo_root = Rails.configuration.git_repositories_dir + @repo_root = Rails.configuration.Git["Repositories"] @arvados_repo_path = Repository.where(name: "arvados").first.server_path @authorizations = {} @did_recently = {} @@ -460,7 +460,7 @@ class CrunchDispatch bytes_logged: 0, events_logged: 0, log_throttle_is_open: true, - log_throttle_reset_time: Time.now + Rails.configuration.crunch_log_throttle_period, + log_throttle_reset_time: Time.now + Rails.configuration.Containers["Logging"]["LogThrottlePeriod"], log_throttle_bytes_so_far: 0, log_throttle_lines_so_far: 0, log_throttle_bytes_skipped: 0, @@ -485,7 +485,7 @@ class CrunchDispatch matches = line.match(/^\S+ \S+ \d+ \d+ stderr (.*)/) if matches and matches[1] and matches[1].start_with?('[...]') and matches[1].end_with?('[...]') partial_line = true - if Time.now > running_job[:log_throttle_partial_line_last_at] + Rails.configuration.crunch_log_partial_line_throttle_period + if Time.now > running_job[:log_throttle_partial_line_last_at] + Rails.configuration.Containers["Logging"]["LogPartialLineThrottlePeriod"] running_job[:log_throttle_partial_line_last_at] = Time.now else skip_counts = true @@ -499,26 +499,26 @@ class CrunchDispatch end if (running_job[:bytes_logged] > - Rails.configuration.crunch_limit_log_bytes_per_job) - message = "Exceeded log limit #{Rails.configuration.crunch_limit_log_bytes_per_job} bytes (crunch_limit_log_bytes_per_job). Log will be truncated." + Rails.configuration.Containers["Logging"]["LimitLogBytesPerJob"]) + message = "Exceeded log limit #{Rails.configuration.Containers["Logging"]["LimitLogBytesPerJob"]} bytes (LimitLogBytesPerJob). Log will be truncated." running_job[:log_throttle_reset_time] = Time.now + 100.years running_job[:log_throttle_is_open] = false elsif (running_job[:log_throttle_bytes_so_far] > - Rails.configuration.crunch_log_throttle_bytes) + Rails.configuration.Containers["Logging"]["LogThrottleBytes"]) remaining_time = running_job[:log_throttle_reset_time] - Time.now - message = "Exceeded rate #{Rails.configuration.crunch_log_throttle_bytes} bytes per #{Rails.configuration.crunch_log_throttle_period} seconds (crunch_log_throttle_bytes). Logging will be silenced for the next #{remaining_time.round} seconds." + message = "Exceeded rate #{Rails.configuration.Containers["Logging"]["LogThrottleBytes"]} bytes per #{Rails.configuration.Containers["Logging"]["LogThrottlePeriod"]} seconds (LogThrottleBytes). Logging will be silenced for the next #{remaining_time.round} seconds." running_job[:log_throttle_is_open] = false elsif (running_job[:log_throttle_lines_so_far] > - Rails.configuration.crunch_log_throttle_lines) + Rails.configuration.Containers["Logging"]["LogThrottleLines"]) remaining_time = running_job[:log_throttle_reset_time] - Time.now - message = "Exceeded rate #{Rails.configuration.crunch_log_throttle_lines} lines per #{Rails.configuration.crunch_log_throttle_period} seconds (crunch_log_throttle_lines), logging will be silenced for the next #{remaining_time.round} seconds." + message = "Exceeded rate #{Rails.configuration.Containers["Logging"]["LogThrottleLines"]} lines per #{Rails.configuration.Containers["Logging"]["LogThrottlePeriod"]} seconds (LogThrottleLines), logging will be silenced for the next #{remaining_time.round} seconds." running_job[:log_throttle_is_open] = false elsif partial_line and running_job[:log_throttle_first_partial_line] running_job[:log_throttle_first_partial_line] = false - message = "Rate-limiting partial segments of long lines to one every #{Rails.configuration.crunch_log_partial_line_throttle_period} seconds." + message = "Rate-limiting partial segments of long lines to one every #{Rails.configuration.Containers["Logging"]["LogPartialLineThrottlePeriod"]} seconds." end end @@ -552,7 +552,7 @@ class CrunchDispatch j[:stderr_buf_to_flush] << "#{LogTime.now} #{message}\n" end - j[:log_throttle_reset_time] = now + Rails.configuration.crunch_log_throttle_period + j[:log_throttle_reset_time] = now + Rails.configuration.Containers["Logging"]["LogThrottlePeriod"] j[:log_throttle_bytes_so_far] = 0 j[:log_throttle_lines_so_far] = 0 j[:log_throttle_bytes_skipped] = 0 @@ -592,7 +592,7 @@ class CrunchDispatch bufend = '' streambuf.each_line do |line| if not line.end_with? $/ - if line.size > Rails.configuration.crunch_log_throttle_bytes + if line.size > Rails.configuration.Containers["Logging"]["LogThrottleBytes"] # Without a limit here, we'll use 2x an arbitrary amount # of memory, and waste a lot of time copying strings # around, all without providing any feedback to anyone @@ -775,7 +775,7 @@ class CrunchDispatch # This is how crunch-job child procs know where the "refresh" # trigger file is - ENV["CRUNCH_REFRESH_TRIGGER"] = Rails.configuration.crunch_refresh_trigger + ENV["CRUNCH_REFRESH_TRIGGER"] = Rails.configuration.Containers["JobsAPI"]["CrunchRefreshTrigger"] # If salloc can't allocate resources immediately, make it use our # temporary failure exit code. This ensures crunch-dispatch won't @@ -937,8 +937,8 @@ class CrunchDispatch # Send out to log event if buffer size exceeds the bytes per event or if # it has been at least crunch_log_seconds_between_events seconds since # the last flush. - if running_job[:stderr_buf_to_flush].size > Rails.configuration.crunch_log_bytes_per_event or - (Time.now - running_job[:stderr_flushed_at]) >= Rails.configuration.crunch_log_seconds_between_events + if running_job[:stderr_buf_to_flush].size > Rails.configuration.Containers["Logging"]["LogBytesPerEvent"] or + (Time.now - running_job[:stderr_flushed_at]) >= Rails.configuration.Containers["Logging"]["LogSecondsBetweenEvents"] begin log = Log.new(object_uuid: running_job[:job].uuid, event_type: 'stderr', @@ -957,7 +957,7 @@ class CrunchDispatch # An array of job_uuids in squeue def squeue_jobs - if Rails.configuration.crunch_job_wrapper == :slurm_immediate + if Rails.configuration.Containers["JobsAPI"]["CrunchJobWrapper"].to_sym == :slurm_immediate p = IO.popen(['squeue', '-a', '-h', '-o', '%j']) begin p.readlines.map {|line| line.strip} diff --git a/services/api/lib/enable_jobs_api.rb b/services/api/lib/enable_jobs_api.rb index 63543ab3ad..4da6188d15 100644 --- a/services/api/lib/enable_jobs_api.rb +++ b/services/api/lib/enable_jobs_api.rb @@ -30,10 +30,9 @@ Disable_jobs_api_method_list = ["jobs.create", "jobs.show", "job_tasks.show"] -def check_enable_legacy_jobs_api - if Rails.configuration.enable_legacy_jobs_api == false || - (Rails.configuration.enable_legacy_jobs_api == "auto" && + if Rails.configuration.Containers["JobsAPI"]["Enable"] == false || + (Rails.configuration.Containers["JobsAPI"]["Enable"] == "auto" && Job.count == 0) - Rails.configuration.disable_api_methods += Disable_jobs_api_method_list + Rails.configuration.API["DisabledAPIs"] += Disable_jobs_api_method_list end end diff --git a/services/api/lib/josh_id.rb b/services/api/lib/josh_id.rb index bb6c1f48a8..396d724449 100644 --- a/services/api/lib/josh_id.rb +++ b/services/api/lib/josh_id.rb @@ -40,7 +40,7 @@ module OmniAuth options.client_options[:site] = options[:custom_provider_url] options.client_options[:authorize_url] = "#{options[:custom_provider_url]}/auth/josh_id/authorize" options.client_options[:access_token_url] = "#{options[:custom_provider_url]}/auth/josh_id/access_token" - if Rails.configuration.sso_insecure + if Rails.configuration.TLS["Insecure"] options.client_options[:ssl] = {verify_mode: OpenSSL::SSL::VERIFY_NONE} end ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options)) diff --git a/services/api/lib/load_param.rb b/services/api/lib/load_param.rb index 736f270e96..0cc29ded0a 100644 --- a/services/api/lib/load_param.rb +++ b/services/api/lib/load_param.rb @@ -56,7 +56,7 @@ module LoadParam raise ArgumentError.new("Invalid value for limit parameter") end @limit = [params[:limit].to_i, - Rails.configuration.max_items_per_response].min + Rails.configuration.API["MaxItemsPerResponse"]].min else @limit = DEFAULT_LIMIT end diff --git a/services/api/lib/log_reuse_info.rb b/services/api/lib/log_reuse_info.rb index ed5cc82bfd..01cf6dd785 100644 --- a/services/api/lib/log_reuse_info.rb +++ b/services/api/lib/log_reuse_info.rb @@ -9,7 +9,7 @@ module LogReuseInfo # doing expensive things like database queries, and we want to skip # those when logging is disabled. def log_reuse_info(candidates=nil) - if Rails.configuration.log_reuse_decisions + if Rails.configuration.Containers["LogReuseDecisions"] msg = yield if !candidates.nil? msg = "have #{candidates.count} candidates " + msg diff --git a/services/api/lib/refresh_permission_view.rb b/services/api/lib/refresh_permission_view.rb index 25be3c08d4..e7fa263c7e 100644 --- a/services/api/lib/refresh_permission_view.rb +++ b/services/api/lib/refresh_permission_view.rb @@ -12,8 +12,8 @@ def do_refresh_permission_view end def refresh_permission_view(async=false) - if async and Rails.configuration.async_permissions_update_interval > 0 - exp = Rails.configuration.async_permissions_update_interval.seconds + if async and Rails.configuration.API["AsyncPermissionsUpdateInterval"] > 0 + exp = Rails.configuration.API["AsyncPermissionsUpdateInterval"].seconds need = false Rails.cache.fetch('AsyncRefreshPermissionView', expires_in: exp) do need = true diff --git a/services/api/lib/sweep_trashed_objects.rb b/services/api/lib/sweep_trashed_objects.rb index bedbd68a44..6ade1fc567 100644 --- a/services/api/lib/sweep_trashed_objects.rb +++ b/services/api/lib/sweep_trashed_objects.rb @@ -55,8 +55,8 @@ module SweepTrashedObjects end def self.sweep_if_stale - return if Rails.configuration.trash_sweep_interval <= 0 - exp = Rails.configuration.trash_sweep_interval.seconds + return if Rails.configuration.Collections["TrashSweepInterval"] <= 0 + exp = Rails.configuration.Collections["TrashSweepInterval"].seconds need = false Rails.cache.fetch('SweepTrashedObjects', expires_in: exp) do need = true diff --git a/services/api/lib/tasks/delete_old_container_logs.rake b/services/api/lib/tasks/delete_old_container_logs.rake index b45113e8a5..c926c2ae01 100644 --- a/services/api/lib/tasks/delete_old_container_logs.rake +++ b/services/api/lib/tasks/delete_old_container_logs.rake @@ -11,7 +11,7 @@ namespace :db do desc "Remove old container log entries from the logs table" task delete_old_container_logs: :environment do - delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN containers ON logs.object_uuid = containers.uuid WHERE event_type IN ('stdout', 'stderr', 'arv-mount', 'crunch-run', 'crunchstat') AND containers.log IS NOT NULL AND clock_timestamp() - containers.finished_at > interval '#{Rails.configuration.clean_container_log_rows_after} seconds')" + delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN containers ON logs.object_uuid = containers.uuid WHERE event_type IN ('stdout', 'stderr', 'arv-mount', 'crunch-run', 'crunchstat') AND containers.log IS NOT NULL AND clock_timestamp() - containers.finished_at > interval '#{Rails.configuration.Containers["Logging"]["MaxAge"]} seconds')" ActiveRecord::Base.connection.execute(delete_sql) end diff --git a/services/api/lib/tasks/delete_old_job_logs.rake b/services/api/lib/tasks/delete_old_job_logs.rake index dcd92b19bc..327f663b20 100644 --- a/services/api/lib/tasks/delete_old_job_logs.rake +++ b/services/api/lib/tasks/delete_old_job_logs.rake @@ -9,7 +9,7 @@ namespace :db do desc "Remove old job stderr entries from the logs table" task delete_old_job_logs: :environment do - delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN jobs ON logs.object_uuid = jobs.uuid WHERE event_type = 'stderr' AND jobs.log IS NOT NULL AND clock_timestamp() - jobs.finished_at > interval '#{Rails.configuration.clean_job_log_rows_after} seconds')" + delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN jobs ON logs.object_uuid = jobs.uuid WHERE event_type = 'stderr' AND jobs.log IS NOT NULL AND clock_timestamp() - jobs.finished_at > interval '#{Rails.configuration.Rails.configuration.Containers["Logging"]["MaxAge"]} seconds')" ActiveRecord::Base.connection.execute(delete_sql) end diff --git a/services/api/lib/trashable.rb b/services/api/lib/trashable.rb index 9687962964..4981b8cd3f 100644 --- a/services/api/lib/trashable.rb +++ b/services/api/lib/trashable.rb @@ -50,7 +50,7 @@ module Trashable if trash_at.nil? self.delete_at = nil else - self.delete_at = trash_at + Rails.configuration.default_trash_lifetime.seconds + self.delete_at = trash_at + Rails.configuration.Collections["DefaultTrashLifetime"].seconds end elsif !trash_at || !delete_at || trash_at > delete_at # Not trash, or bogus arguments? Just validate in @@ -65,7 +65,7 @@ module Trashable earliest_delete = [ @validation_timestamp, trash_at_was, - ].compact.min + Rails.configuration.blob_signature_ttl.seconds + ].compact.min + Rails.configuration.Collections["BlobSigningTTL"].seconds # The previous value of delete_at is also an upper bound on the # longest-lived permission token. For example, if TTL=14, @@ -96,7 +96,7 @@ module TrashableController @object.update_attributes!(trash_at: db_current_time) end earliest_delete = (@object.trash_at + - Rails.configuration.blob_signature_ttl.seconds) + Rails.configuration.Collections["BlobSigningTTL"].seconds) if @object.delete_at > earliest_delete @object.update_attributes!(delete_at: earliest_delete) end -- 2.30.2