13996: Tweak rake tasks
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Thu, 11 Apr 2019 15:42:58 +0000 (11:42 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Thu, 11 Apr 2019 15:42:58 +0000 (11:42 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

lib/config/config.default.yml
services/api/config/arvados_config.rb
services/api/lib/config_loader.rb
services/api/lib/tasks/config_check.rake [deleted file]
services/api/lib/tasks/config_dump.rake [deleted file]

index d46c5c0ae1b3cbfddeb7f830c460ce8c4f9335e3..bea6387532f0d5ac476b82858ac46171162a0e06 100644 (file)
@@ -109,6 +109,11 @@ Clusters:
       # update on the permission view in the future, if not already scheduled.
       AsyncPermissionsUpdateInterval: 20
 
+      # RailsSessionSecretToken is a string of alphanumeric characters
+      # used by Rails to sign session tokens. IMPORTANT: This is a
+      # site secret. It should be at least 50 characters.
+      RailsSessionSecretToken: ""
+
     Users:
       # Config parameters to automatically setup new users.  If enabled,
       # this users will be able to self-activate.  Enable this if you want
index f0eb55a8f3b91afe6723fcecb8579c60d3634fb8..8817b8b10fb20c869d6a59f4d8ec688c07db5917 100644 (file)
@@ -67,6 +67,7 @@ arvcfg.declare_config "API.MaxRequestSize", Integer, :max_request_size
 arvcfg.declare_config "API.MaxIndexDatabaseRead", Integer, :max_index_database_read
 arvcfg.declare_config "API.MaxItemsPerResponse", Integer, :max_items_per_response
 arvcfg.declare_config "API.AsyncPermissionsUpdateInterval", ActiveSupport::Duration, :async_permissions_update_interval
+arvcfg.declare_config "API.RailsSessionSecretToken", NonemptyString, :secret_token
 arvcfg.declare_config "Users.AutoSetupNewUsers", Boolean, :auto_setup_new_users
 arvcfg.declare_config "Users.AutoSetupNewUsersWithVmUUID", String, :auto_setup_new_users_with_vm_uuid
 arvcfg.declare_config "Users.AutoSetupNewUsersWithRepository", Boolean, :auto_setup_new_users_with_repository
@@ -191,9 +192,14 @@ end
 
 # Checks for wrongly typed configuration items, and essential items
 # that can't be empty
+arvcfg.coercion_and_check $base_arvados_config, check_nonempty: false
 arvcfg.coercion_and_check $arvados_config
 dbcfg.coercion_and_check $arvados_config
 
+if $arvados_config["Collections"]["DefaultTrashLifetime"] < 86400.seconds then
+  raise "default_trash_lifetime is %d, must be at least 86400" % Rails.configuration.Collections.DefaultTrashLifetime
+end
+
 #
 # Special case for test database where there's no database.yml,
 # because the Arvados config.yml doesn't have a concept of multiple
index 5cb6e28419e1ff3b35b6e86cd68d6aac49e83e91..87bfd93fcad3ac72773ba2fcb0b199a519d68c33 100644 (file)
@@ -76,7 +76,7 @@ class ConfigLoader
     remainders
   end
 
-  def coercion_and_check check_cfg
+  def coercion_and_check check_cfg, check_nonempty: true
     @config_types.each do |cfgkey, cfgtype|
       cfg = check_cfg
       k = cfgkey
@@ -114,7 +114,7 @@ class ConfigLoader
       end
 
       if cfgtype == NonemptyString
-        if (!cfg[k] || cfg[k] == "")
+        if (!cfg[k] || cfg[k] == "") && check_nonempty
           raise "#{cfgkey} cannot be empty"
         end
         if cfg[k].is_a? String
diff --git a/services/api/lib/tasks/config_check.rake b/services/api/lib/tasks/config_check.rake
deleted file mode 100644 (file)
index 12e6dd9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
-namespace :config do
-  desc 'Ensure site configuration has all required settings'
-  task check: :environment do
-    $stderr.puts "%-32s %s" % ["AppVersion (discovered)", AppVersion.hash]
-    $application_config.sort.each do |k, v|
-      if ENV.has_key?('QUIET') then
-        # Make sure we still check for the variable to exist
-        eval("Rails.configuration.#{k}")
-      else
-        if /(password|secret|signing_key)/.match(k) then
-          # Make sure we still check for the variable to exist, but don't print the value
-          eval("Rails.configuration.#{k}")
-          $stderr.puts "%-32s %s" % [k, '*********']
-        else
-          $stderr.puts "%-32s %s" % [k, eval("Rails.configuration.#{k}")]
-        end
-      end
-    end
-    # default_trash_lifetime cannot be less than 24 hours
-    if Rails.configuration.Collections.DefaultTrashLifetime < 86400 then
-      raise "default_trash_lifetime is %d, must be at least 86400" % Rails.configuration.Collections.DefaultTrashLifetime
-    end
-  end
-end
diff --git a/services/api/lib/tasks/config_dump.rake b/services/api/lib/tasks/config_dump.rake
deleted file mode 100644 (file)
index 1790a79..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
-namespace :config do
-  desc 'Print active site configuration'
-  task dump: :environment do
-    combined = $arvados_config.deep_dup
-    combined.update $remaining_config
-    puts combined.to_yaml
-  end
-end