[ARVADOS] updated: 1.2.0-88-g49e18f8c1
Git user
git at public.curoverse.com
Thu Sep 20 13:56:13 EDT 2018
Summary of changes:
doc/install/install-api-server.html.textile.liquid | 39 +++++-----------------
.../api/config/initializers/legacy_jobs_api.rb | 36 +++-----------------
.../legacy_jobs_api.rb => lib/enable_jobs_api.rb} | 19 ++++-------
services/api/test/unit/job_test.rb | 28 ++++++++++++++++
4 files changed, 48 insertions(+), 74 deletions(-)
copy services/api/{config/initializers/legacy_jobs_api.rb => lib/enable_jobs_api.rb} (80%)
via 49e18f8c16bda6b6bf56c301b440c9d56d9bcb72 (commit)
via ba54c26be4078cb32d78947837f630a4404a93ae (commit)
from 985bfe119f34bbf39a7007bee1fc1c03db9ab8bf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 49e18f8c16bda6b6bf56c301b440c9d56d9bcb72
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date: Thu Sep 20 13:55:19 2018 -0400
10865: Update documentation, replace disable_api_methods with enable_legacy_jobs_api
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/doc/install/install-api-server.html.textile.liquid b/doc/install/install-api-server.html.textile.liquid
index a25942fe2..a6b843b16 100644
--- a/doc/install/install-api-server.html.textile.liquid
+++ b/doc/install/install-api-server.html.textile.liquid
@@ -158,39 +158,18 @@ Example @application.yml@:
</code></pre>
</notextile>
-h3(#disable_api_methods). disable_api_methods
+h3(#enable_legacy_jobs_api). enable_legacy_jobs_api
-Set the @disable_api_methods@ configuration option to disable the deprecated @jobs@ API. This will prevent users from accidentally submitting jobs that won't run. "All new installations should use the containers API.":crunch2-slurm/install-prerequisites.html
+Enable the legacy "Jobs API":install-crunch-dispatch.html . Note: new installations should use the "Containers API":crunch2-slurm/install-prerequisites.html
+
+Disabling the jobs API means methods involving @jobs@, @job_tasks@, @pipeline_templates@ and @pipeline_instances@ are disabled. This functionality is superceded by the containers API which consists of @container_requests@, @containers@ and @workflows at . Arvados clients (such as @arvados-cwl-runner@) detect which APIs are available and adjust behavior accordingly.
+
+* auto -- (default) enable the Jobs API only if it has been used before (i.e., there are job records in the database), otherwise disable jobs API .
+* true -- enable the Jobs API even if there are no existing job records.
+* false -- disable the Jobs API even in the presence of existing job records.
<notextile>
-<pre><code>
- disable_api_methods:
- - jobs.create
- - pipeline_instances.create
- - pipeline_templates.create
- - jobs.get
- - pipeline_instances.get
- - pipeline_templates.get
- - jobs.list
- - pipeline_instances.list
- - pipeline_templates.list
- - jobs.index
- - pipeline_instances.index
- - pipeline_templates.index
- - jobs.update
- - pipeline_instances.update
- - pipeline_templates.update
- - jobs.queue
- - jobs.queue_size
- - job_tasks.create
- - job_tasks.get
- - job_tasks.list
- - job_tasks.index
- - job_tasks.update
- - jobs.show
- - pipeline_instances.show
- - pipeline_templates.show
- - job_tasks.show
+<pre><code> enable_legacy_jobs_api: <span class="userinput">auto</span>
</code></pre>
</notextile>
diff --git a/services/api/config/initializers/legacy_jobs_api.rb b/services/api/config/initializers/legacy_jobs_api.rb
index ae98a3d13..9ea6b2884 100644
--- a/services/api/config/initializers/legacy_jobs_api.rb
+++ b/services/api/config/initializers/legacy_jobs_api.rb
@@ -10,5 +10,7 @@ require_relative 'load_config.rb'
require 'enable_jobs_api'
Server::Application.configure do
- check_enable_legacy_jobs_api
+ if ActiveRecord::Base.connection.tables.include?('jobs')
+ check_enable_legacy_jobs_api
+ end
end
commit ba54c26be4078cb32d78947837f630a4404a93ae
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date: Thu Sep 20 12:57:40 2018 -0400
10865: Add test for check_enable_legacy_jobs_api
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/services/api/config/initializers/legacy_jobs_api.rb b/services/api/config/initializers/legacy_jobs_api.rb
index eecf337da..ae98a3d13 100644
--- a/services/api/config/initializers/legacy_jobs_api.rb
+++ b/services/api/config/initializers/legacy_jobs_api.rb
@@ -7,38 +7,8 @@
# classes.
require_relative 'load_config.rb'
+require 'enable_jobs_api'
+
Server::Application.configure do
- # Use exec_query because the Job model isn't loaded yet
- # it returns the string '0', not converted to integer.
- if Rails.configuration.enable_legacy_jobs_api == false ||
- (Rails.configuration.enable_legacy_jobs_api == "auto" &&
- ActiveRecord::Base.connection.exec_query('select count(*) from jobs').first['count'] == '0')
- Rails.configuration.disable_api_methods = ["jobs.create",
- "pipeline_instances.create",
- "pipeline_templates.create",
- "jobs.get",
- "pipeline_instances.get",
- "pipeline_templates.get",
- "jobs.list",
- "pipeline_instances.list",
- "pipeline_templates.list",
- "jobs.index",
- "pipeline_instances.index",
- "pipeline_templates.index",
- "jobs.update",
- "pipeline_instances.update",
- "pipeline_templates.update",
- "jobs.queue",
- "jobs.queue_size",
- "job_tasks.create",
- "job_tasks.get",
- "job_tasks.list",
- "job_tasks.index",
- "job_tasks.update",
- "jobs.show",
- "pipeline_instances.show",
- "pipeline_templates.show",
- "jobs.show",
- "job_tasks.show"]
- end
+ check_enable_legacy_jobs_api
end
diff --git a/services/api/config/initializers/legacy_jobs_api.rb b/services/api/lib/enable_jobs_api.rb
similarity index 80%
copy from services/api/config/initializers/legacy_jobs_api.rb
copy to services/api/lib/enable_jobs_api.rb
index eecf337da..d99edd801 100644
--- a/services/api/config/initializers/legacy_jobs_api.rb
+++ b/services/api/lib/enable_jobs_api.rb
@@ -2,18 +2,7 @@
#
# SPDX-License-Identifier: AGPL-3.0
-# Config must be done before we files; otherwise they
-# won't be able to use Rails.configuration.* to initialize their
-# classes.
-require_relative 'load_config.rb'
-
-Server::Application.configure do
- # Use exec_query because the Job model isn't loaded yet
- # it returns the string '0', not converted to integer.
- if Rails.configuration.enable_legacy_jobs_api == false ||
- (Rails.configuration.enable_legacy_jobs_api == "auto" &&
- ActiveRecord::Base.connection.exec_query('select count(*) from jobs').first['count'] == '0')
- Rails.configuration.disable_api_methods = ["jobs.create",
+Disable_jobs_api_method_list = ["jobs.create",
"pipeline_instances.create",
"pipeline_templates.create",
"jobs.get",
@@ -40,5 +29,11 @@ Server::Application.configure do
"pipeline_templates.show",
"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" &&
+ ActiveRecord::Base.connection.exec_query("select count(*) from jobs").first["count"] == "0")
+ Rails.configuration.disable_api_methods = Disable_jobs_api_method_list
end
end
diff --git a/services/api/test/unit/job_test.rb b/services/api/test/unit/job_test.rb
index 5f389c254..fc6a97cf7 100644
--- a/services/api/test/unit/job_test.rb
+++ b/services/api/test/unit/job_test.rb
@@ -645,4 +645,32 @@ class JobTest < ActiveSupport::TestCase
child = Job.find_by_uuid job.components.collect{|_, uuid| uuid}[0]
assert_equal Job::Cancelled, child.state
end
+
+ test 'enable legacy api configuration option = true' do
+ Rails.configuration.enable_legacy_jobs_api = true
+ check_enable_legacy_jobs_api
+ assert_equal [], Rails.configuration.disable_api_methods
+ end
+
+ test 'enable legacy api configuration option = false' do
+ Rails.configuration.enable_legacy_jobs_api = false
+ check_enable_legacy_jobs_api
+ assert_equal Disable_jobs_api_method_list, Rails.configuration.disable_api_methods
+ end
+
+ test 'enable legacy api configuration option = auto, has jobs' do
+ Rails.configuration.enable_legacy_jobs_api = "auto"
+ check_enable_legacy_jobs_api
+ assert_equal [], Rails.configuration.disable_api_methods
+ end
+
+ test 'enable legacy api configuration option = auto, no jobs' do
+ Rails.configuration.enable_legacy_jobs_api = "auto"
+ act_as_system_user do
+ Job.destroy_all
+ end
+ puts "ZZZ #{Job.count}"
+ check_enable_legacy_jobs_api
+ assert_equal Disable_jobs_api_method_list, Rails.configuration.disable_api_methods
+ end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list