[ARVADOS] created: 2.1.0-654-g03aade6dd

Git user git at public.arvados.org
Thu Apr 15 18:57:31 UTC 2021


        at  03aade6dd988f91b1037f39754438846c4844cfb (commit)


commit 03aade6dd988f91b1037f39754438846c4844cfb
Author: Tom Clegg <tom at curii.com>
Date:   Thu Apr 15 14:55:44 2021 -0400

    17528: Don't load config when doing assets:precompile in postinst.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/apps/workbench/config/application.rb b/apps/workbench/config/application.rb
index 42bf4da24..2880af2d6 100644
--- a/apps/workbench/config/application.rb
+++ b/apps/workbench/config/application.rb
@@ -27,6 +27,8 @@ end
 
 module ArvadosWorkbench
   class Application < Rails::Application
+    # The following is to avoid SafeYAML's warning message
+    SafeYAML::OPTIONS[:default_mode] = :safe
 
     require_relative "arvados_config.rb"
 
diff --git a/apps/workbench/config/arvados_config.rb b/apps/workbench/config/arvados_config.rb
index 007e8d068..fb99b3117 100644
--- a/apps/workbench/config/arvados_config.rb
+++ b/apps/workbench/config/arvados_config.rb
@@ -31,19 +31,25 @@ clusterID, clusterConfig = confs["Clusters"].first
 $arvados_config_defaults = clusterConfig
 $arvados_config_defaults["ClusterID"] = clusterID
 
-# Load the global config file
-Open3.popen2("arvados-server", "config-dump", "-skip-legacy") do |stdin, stdout, status_thread|
-  confs = YAML.load(stdout, deserialize_symbols: false)
-  if confs && !confs.empty?
-    # config-dump merges defaults with user configuration, so every
-    # key should be set.
-    clusterID, clusterConfig = confs["Clusters"].first
-    $arvados_config_global = clusterConfig
-    $arvados_config_global["ClusterID"] = clusterID
-  else
-    # config-dump failed, assume we will be loading from legacy
-    # application.yml, initialize with defaults.
-    $arvados_config_global = $arvados_config_defaults.deep_dup
+if ENV["ARVADOS_CONFIG"] == "none"
+  # Don't load config. This magic value is set by postinst so it can
+  # run "rake assets:precompile" without a real config.
+  $arvados_config_global = $arvados_config_defaults.deep_dup
+else
+  # Load the global config file
+  Open3.popen2("arvados-server", "config-dump", "-skip-legacy") do |stdin, stdout, status_thread|
+    confs = YAML.load(stdout, deserialize_symbols: false)
+    if confs && !confs.empty?
+      # config-dump merges defaults with user configuration, so every
+      # key should be set.
+      clusterID, clusterConfig = confs["Clusters"].first
+      $arvados_config_global = clusterConfig
+      $arvados_config_global["ClusterID"] = clusterID
+    else
+      # config-dump failed, assume we will be loading from legacy
+      # application.yml, initialize with defaults.
+      $arvados_config_global = $arvados_config_defaults.deep_dup
+    end
   end
 end
 
@@ -189,7 +195,8 @@ ArvadosWorkbench::Application.configure do
   ConfigLoader.copy_into_config $arvados_config, config
   ConfigLoader.copy_into_config $remaining_config, config
   secrets.secret_key_base = $arvados_config["Workbench"]["SecretKeyBase"]
-  ConfigValidators.validate_wb2_url_config()
-  ConfigValidators.validate_download_config()
-
+  if ENV["ARVADOS_CONFIG"] != "none"
+    ConfigValidators.validate_wb2_url_config()
+    ConfigValidators.validate_download_config()
+  end
 end
diff --git a/build/rails-package-scripts/README.md b/build/rails-package-scripts/README.md
index 35549d9cd..6ac2539f8 100644
--- a/build/rails-package-scripts/README.md
+++ b/build/rails-package-scripts/README.md
@@ -15,4 +15,3 @@ postinst.sh lets the early parts define a few hooks to control behavior:
 * After it installs the core configuration files (database.yml, application.yml, and production.rb) to /etc/arvados/server, it calls setup_extra_conffiles.  By default this is a noop function (in step2.sh).
 * Before it restarts nginx, it calls setup_before_nginx_restart.  By default this is a noop function (in step2.sh).  API server defines this to set up the internal git repository, if necessary.
 * $RAILSPKG_DATABASE_LOAD_TASK defines the Rake task to load the database.  API server uses db:structure:load.  Workbench doesn't set this, which causes the postinst to skip all database work.
-* If $RAILSPKG_SUPPORTS_CONFIG_CHECK != 1, it won't run the config:check rake task.
diff --git a/build/rails-package-scripts/postinst.sh b/build/rails-package-scripts/postinst.sh
index 3eb2d2c5e..6b069957a 100644
--- a/build/rails-package-scripts/postinst.sh
+++ b/build/rails-package-scripts/postinst.sh
@@ -226,19 +226,19 @@ configure_version() {
       prepare_database
   fi
 
-  if [ 11 = "$RAILSPKG_SUPPORTS_CONFIG_CHECK$APPLICATION_READY" ]; then
+  # Here, "ARVADOS_CONFIG=none" tells arvados_config.rb not to try
+  # loading config from /etc: it might not exist on a new install, and
+  # assets:precompile doesn't depend on config anyway.
+  run_and_report "Precompiling assets" \
+                 ARVADOS_CONFIG=none $COMMAND_PREFIX bundle exec rake assets:precompile -q -s 2>/dev/null || true
+
+  if [ -e /etc/arvados/config.yml ]; then
+      # warn about config errors (deprecated/removed keys from
+      # previous version, etc)
       run_and_report "Checking configuration for completeness" \
-          $COMMAND_PREFIX bundle exec rake config:check || APPLICATION_READY=0
+                     $COMMAND_PREFIX bundle exec rake config:check || true
   fi
 
-  # precompile assets; thankfully this does not take long
-  if [ "$APPLICATION_READY" = "1" ]; then
-      run_and_report "Precompiling assets" \
-          $COMMAND_PREFIX bundle exec rake assets:precompile -q -s 2>/dev/null \
-          || APPLICATION_READY=0
-  else
-      echo "Precompiling assets... skipped."
-  fi
   chown -R "$WWW_OWNER:" $RELEASE_PATH/tmp
 
   setup_before_nginx_restart
diff --git a/build/rails-package-scripts/step2.sh b/build/rails-package-scripts/step2.sh
index 482d27a6a..41c9cd71e 100644
--- a/build/rails-package-scripts/step2.sh
+++ b/build/rails-package-scripts/step2.sh
@@ -11,7 +11,7 @@ if [ -z "$INSTALL_PATH" ]; then
 
 PACKAGE BUILD ERROR: $0 is missing package metadata.
 
-This package is buggy.  Please mail <support at curoverse.com> to let
+This package is buggy.  Please mail <packaging at arvados.org> to let
 us know the name and version number of the package you tried to
 install, and we'll get it fixed.
 
@@ -23,7 +23,6 @@ RELEASE_PATH=$INSTALL_PATH/current
 RELEASE_CONFIG_PATH=$RELEASE_PATH/config
 SHARED_PATH=$INSTALL_PATH/shared
 
-RAILSPKG_SUPPORTS_CONFIG_CHECK=${RAILSPKG_SUPPORTS_CONFIG_CHECK:-1}
 if ! type setup_extra_conffiles >/dev/null 2>&1; then
     setup_extra_conffiles() { return; }
 fi
diff --git a/services/api/config/arvados_config.rb b/services/api/config/arvados_config.rb
index 72c11649d..eb48e271b 100644
--- a/services/api/config/arvados_config.rb
+++ b/services/api/config/arvados_config.rb
@@ -56,19 +56,25 @@ clusterID, clusterConfig = confs["Clusters"].first
 $arvados_config_defaults = clusterConfig
 $arvados_config_defaults["ClusterID"] = clusterID
 
-# Load the global config file
-Open3.popen2("arvados-server", "config-dump", "-skip-legacy") do |stdin, stdout, status_thread|
-  confs = YAML.load(stdout, deserialize_symbols: false)
-  if confs && !confs.empty?
-    # config-dump merges defaults with user configuration, so every
-    # key should be set.
-    clusterID, clusterConfig = confs["Clusters"].first
-    $arvados_config_global = clusterConfig
-    $arvados_config_global["ClusterID"] = clusterID
-  else
-    # config-dump failed, assume we will be loading from legacy
-    # application.yml, initialize with defaults.
-    $arvados_config_global = $arvados_config_defaults.deep_dup
+if ENV["ARVADOS_CONFIG"] == "none"
+  # Don't load config. This magic value is set by postinst so it can
+  # run "rake assets:precompile" without a real config.
+  $arvados_config_global = $arvados_config_defaults.deep_dup
+else
+  # Load the global config file
+  Open3.popen2("arvados-server", "config-dump", "-skip-legacy") do |stdin, stdout, status_thread|
+    confs = YAML.load(stdout, deserialize_symbols: false)
+    if confs && !confs.empty?
+      # config-dump merges defaults with user configuration, so every
+      # key should be set.
+      clusterID, clusterConfig = confs["Clusters"].first
+      $arvados_config_global = clusterConfig
+      $arvados_config_global["ClusterID"] = clusterID
+    else
+      # config-dump failed, assume we will be loading from legacy
+      # application.yml, initialize with defaults.
+      $arvados_config_global = $arvados_config_defaults.deep_dup
+    end
   end
 end
 
@@ -125,7 +131,7 @@ arvcfg.declare_config "Collections.DefaultTrashLifetime", ActiveSupport::Duratio
 arvcfg.declare_config "Collections.CollectionVersioning", Boolean, :collection_versioning
 arvcfg.declare_config "Collections.PreserveVersionIfIdle", ActiveSupport::Duration, :preserve_version_if_idle
 arvcfg.declare_config "Collections.TrashSweepInterval", ActiveSupport::Duration, :trash_sweep_interval
-arvcfg.declare_config "Collections.BlobSigningKey", NonemptyString, :blob_signing_key
+arvcfg.declare_config "Collections.BlobSigningKey", String, :blob_signing_key
 arvcfg.declare_config "Collections.BlobSigningTTL", ActiveSupport::Duration, :blob_signature_ttl
 arvcfg.declare_config "Collections.BlobSigning", Boolean, :permit_create_collection_with_unsigned_manifest, ->(cfg, k, v) { ConfigLoader.set_cfg cfg, "Collections.BlobSigning", !v }
 arvcfg.declare_config "Collections.ForwardSlashNameSubstitution", String
@@ -266,6 +272,15 @@ if ::Rails.env.to_s == "test"
   $arvados_config["PostgreSQL"]["Connection"]["collation"] = "en_US.UTF-8"
 end
 
+if ENV["ARVADOS_CONFIG"] == "none"
+  # We need the postgresql connection URI to be valid, even if we
+  # don't use it.
+  $arvados_config["PostgreSQL"]["Connection"]["host"] = "localhost"
+  $arvados_config["PostgreSQL"]["Connection"]["user"] = "x"
+  $arvados_config["PostgreSQL"]["Connection"]["password"] = "x"
+  $arvados_config["PostgreSQL"]["Connection"]["dbname"] = "x"
+end
+
 if $arvados_config["PostgreSQL"]["Connection"]["password"].empty?
   raise "Database password is empty, PostgreSQL section is: #{$arvados_config["PostgreSQL"]}"
 end
diff --git a/services/api/config/initializers/legacy_jobs_api.rb b/services/api/config/initializers/legacy_jobs_api.rb
index 2abe40566..b6a2895f7 100644
--- a/services/api/config/initializers/legacy_jobs_api.rb
+++ b/services/api/config/initializers/legacy_jobs_api.rb
@@ -10,7 +10,7 @@ require 'enable_jobs_api'
 
 Rails.application.configure do
   begin
-    if ActiveRecord::Base.connection.tables.include?('jobs')
+    if ENV["ARVADOS_CONFIG"] != "none" && ActiveRecord::Base.connection.tables.include?('jobs')
       check_enable_legacy_jobs_api
     end
   rescue ActiveRecord::NoDatabaseError

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list