From 0b90a6ee86fdfa5b2b8cb51d66d70cef00dc6800 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 23 Jul 2019 09:40:37 -0400 Subject: [PATCH] 15467: List to map changes (WIP) Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- lib/config/config.default.yml | 34 ++++++++++++------- lib/config/export.go | 1 + lib/config/generated_config.go | 34 ++++++++++++------- sdk/go/arvados/config.go | 14 ++++---- .../app/controllers/application_controller.rb | 2 +- .../arvados/v1/collections_controller.rb | 6 ++-- .../arvados/v1/groups_controller.rb | 2 +- .../arvados/v1/schema_controller.rb | 2 +- services/api/app/mailers/admin_notifier.rb | 4 +-- services/api/app/models/arvados_model.rb | 2 +- services/api/app/models/collection.rb | 6 +++- services/api/app/models/node.rb | 2 +- services/api/app/models/user.rb | 2 +- services/api/config/arvados_config.rb | 22 ++++++++---- .../api/test/unit/container_request_test.rb | 10 +++--- services/api/test/unit/job_test.rb | 8 ++--- 16 files changed, 92 insertions(+), 59 deletions(-) diff --git a/lib/config/config.default.yml b/lib/config/config.default.yml index 595b05f8c9..88177cb1b4 100644 --- a/lib/config/config.default.yml +++ b/lib/config/config.default.yml @@ -178,8 +178,8 @@ Clusters: # API methods to disable. Disabled methods are not listed in the # discovery document, and respond 404 to all requests. - # Example: ["jobs.create", "pipeline_instances.create"] - DisabledAPIs: [] + # Example: {"jobs.create":{}, "pipeline_instances.create": {}} + DisabledAPIs: {} # Interval (seconds) between asynchronous permission view updates. Any # permission-updating API called with the 'async' parameter schedules a an @@ -217,7 +217,14 @@ Clusters: AutoSetupNewUsers: false AutoSetupNewUsersWithVmUUID: "" AutoSetupNewUsersWithRepository: false - AutoSetupUsernameBlacklist: [arvados, git, gitolite, gitolite-admin, root, syslog] + AutoSetupUsernameBlacklist: + arvados: {} + git: {} + gitolite: {} + gitolite-admin: {} + root: {} + syslog: {} + SAMPLE: {} # When new_users_are_active is set to true, new users will be active # immediately. This skips the "self-activate" step which enforces @@ -241,8 +248,8 @@ Clusters: AdminNotifierEmailFrom: arvados@example.com EmailSubjectPrefix: "[ARVADOS] " UserNotifierEmailFrom: arvados@example.com - NewUserNotificationRecipients: [] - NewInactiveUserNotificationRecipients: [] + NewUserNotificationRecipients: {} + NewInactiveUserNotificationRecipients: {} # Set anonymous_user_token to enable anonymous user access. You can get # the token by running "bundle exec ./script/get_anonymous_user_token.rb" @@ -269,13 +276,13 @@ Clusters: MaxDeleteBatch: 0 # Attributes to suppress in events and audit logs. Notably, - # specifying ["manifest_text"] here typically makes the database + # specifying {"manifest_text": {}} here typically makes the database # smaller and faster. # # Warning: Using any non-empty value here can have undesirable side # effects for any client or component that relies on event logs. # Use at your own risk. - UnloggedAttributes: [] + UnloggedAttributes: {} SystemLogs: @@ -410,10 +417,12 @@ Clusters: # to skip the compatibility check (and display a warning message to # that effect). # - # Example for sites running docker < 1.10: ["v1"] - # Example for sites running docker >= 1.10: ["v2"] - # Example for disabling check: [] - SupportedDockerImageFormats: ["v2"] + # Example for sites running docker < 1.10: {"v1": {}} + # Example for sites running docker >= 1.10: {"v2": {}} + # Example for disabling check: {} + SupportedDockerImageFormats: + "v2": {} + SAMPLE: {} # Include details about job reuse decisions in the server log. This # causes additional database queries to run, so it should not be @@ -539,7 +548,8 @@ Clusters: ComputeNodeDomain: "" ComputeNodeNameservers: - - 192.168.1.1 + "192.168.1.1": {} + SAMPLE: {} # Hostname to assign to a compute node when it sends a "ping" and the # hostname in its Node record is nil. diff --git a/lib/config/export.go b/lib/config/export.go index 25d1b7a2cb..6ff72afcc1 100644 --- a/lib/config/export.go +++ b/lib/config/export.go @@ -108,6 +108,7 @@ var whitelist = map[string]bool{ "Containers.SLURM": false, "Containers.StaleLockTimeout": false, "Containers.SupportedDockerImageFormats": true, + "Containers.SupportedDockerImageFormats.*": true, "Containers.UsePreemptibleInstances": true, "EnableBetaController14287": false, "Git": false, diff --git a/lib/config/generated_config.go b/lib/config/generated_config.go index 7704a3faef..05648ca77f 100644 --- a/lib/config/generated_config.go +++ b/lib/config/generated_config.go @@ -184,8 +184,8 @@ Clusters: # API methods to disable. Disabled methods are not listed in the # discovery document, and respond 404 to all requests. - # Example: ["jobs.create", "pipeline_instances.create"] - DisabledAPIs: [] + # Example: {"jobs.create":{}, "pipeline_instances.create": {}} + DisabledAPIs: {} # Interval (seconds) between asynchronous permission view updates. Any # permission-updating API called with the 'async' parameter schedules a an @@ -223,7 +223,14 @@ Clusters: AutoSetupNewUsers: false AutoSetupNewUsersWithVmUUID: "" AutoSetupNewUsersWithRepository: false - AutoSetupUsernameBlacklist: [arvados, git, gitolite, gitolite-admin, root, syslog] + AutoSetupUsernameBlacklist: + arvados: {} + git: {} + gitolite: {} + gitolite-admin: {} + root: {} + syslog: {} + SAMPLE: {} # When new_users_are_active is set to true, new users will be active # immediately. This skips the "self-activate" step which enforces @@ -247,8 +254,8 @@ Clusters: AdminNotifierEmailFrom: arvados@example.com EmailSubjectPrefix: "[ARVADOS] " UserNotifierEmailFrom: arvados@example.com - NewUserNotificationRecipients: [] - NewInactiveUserNotificationRecipients: [] + NewUserNotificationRecipients: {} + NewInactiveUserNotificationRecipients: {} # Set anonymous_user_token to enable anonymous user access. You can get # the token by running "bundle exec ./script/get_anonymous_user_token.rb" @@ -275,13 +282,13 @@ Clusters: MaxDeleteBatch: 0 # Attributes to suppress in events and audit logs. Notably, - # specifying ["manifest_text"] here typically makes the database + # specifying {"manifest_text": {}} here typically makes the database # smaller and faster. # # Warning: Using any non-empty value here can have undesirable side # effects for any client or component that relies on event logs. # Use at your own risk. - UnloggedAttributes: [] + UnloggedAttributes: {} SystemLogs: @@ -416,10 +423,12 @@ Clusters: # to skip the compatibility check (and display a warning message to # that effect). # - # Example for sites running docker < 1.10: ["v1"] - # Example for sites running docker >= 1.10: ["v2"] - # Example for disabling check: [] - SupportedDockerImageFormats: ["v2"] + # Example for sites running docker < 1.10: {"v1": {}} + # Example for sites running docker >= 1.10: {"v2": {}} + # Example for disabling check: {} + SupportedDockerImageFormats: + "v2": {} + SAMPLE: {} # Include details about job reuse decisions in the server log. This # causes additional database queries to run, so it should not be @@ -545,7 +554,8 @@ Clusters: ComputeNodeDomain: "" ComputeNodeNameservers: - - 192.168.1.1 + "192.168.1.1": {} + SAMPLE: {} # Hostname to assign to a compute node when it sends a "ping" and the # hostname in its Node record is nil. diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go index d0ab58ae42..e04849bb89 100644 --- a/sdk/go/arvados/config.go +++ b/sdk/go/arvados/config.go @@ -69,7 +69,7 @@ type Cluster struct { API struct { AsyncPermissionsUpdateInterval Duration - DisabledAPIs []string + DisabledAPIs map[string]struct{} MaxIndexDatabaseRead int MaxItemsPerResponse int MaxRequestAmplification int @@ -83,7 +83,7 @@ type Cluster struct { AuditLogs struct { MaxAge Duration MaxDeleteBatch int - UnloggedAttributes []string + UnloggedAttributes map[string]struct{} } Collections struct { BlobSigning bool @@ -135,10 +135,10 @@ type Cluster struct { AutoSetupNewUsers bool AutoSetupNewUsersWithRepository bool AutoSetupNewUsersWithVmUUID string - AutoSetupUsernameBlacklist []string + AutoSetupUsernameBlacklist map[string]struct{} EmailSubjectPrefix string - NewInactiveUserNotificationRecipients []string - NewUserNotificationRecipients []string + NewInactiveUserNotificationRecipients map[string]struct{} + NewUserNotificationRecipients map[string]struct{} NewUsersAreActive bool UserNotifierEmailFrom string UserProfileNotificationAddress string @@ -267,7 +267,7 @@ type ContainersConfig struct { MinRetryPeriod Duration ReserveExtraRAM ByteSize StaleLockTimeout Duration - SupportedDockerImageFormats []string + SupportedDockerImageFormats map[string]struct{} UsePreemptibleInstances bool JobsAPI struct { @@ -300,7 +300,7 @@ type ContainersConfig struct { DNSServerReloadCommand string DNSServerUpdateCommand string ComputeNodeDomain string - ComputeNodeNameservers []string + ComputeNodeNameservers map[string]struct{} AssignNodeHostname string } } diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index b23515dda4..369043e780 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -433,7 +433,7 @@ class ApplicationController < ActionController::Base end def disable_api_methods - if Rails.configuration.API.DisabledAPIs.include?(controller_name + "." + action_name) + if Rails.configuration.API.DisabledAPIs[controller_name + "." + action_name] send_error("Disabled", status: 404) end end diff --git a/services/api/app/controllers/arvados/v1/collections_controller.rb b/services/api/app/controllers/arvados/v1/collections_controller.rb index a8ef4b91b4..81b9ca9e5b 100644 --- a/services/api/app/controllers/arvados/v1/collections_controller.rb +++ b/services/api/app/controllers/arvados/v1/collections_controller.rb @@ -152,7 +152,7 @@ class Arvados::V1::CollectionsController < ApplicationController if direction == :search_up # Search upstream for jobs where this locator is the output of some job - if !Rails.configuration.API.DisabledAPIs.include?("jobs.list") + if !Rails.configuration.API.DisabledAPIs["jobs.list"] Job.readable_by(*@read_users).where(output: loc.to_s).each do |job| search_edges(visited, job.uuid, :search_up) end @@ -176,7 +176,7 @@ class Arvados::V1::CollectionsController < ApplicationController end # Search downstream for jobs where this locator is in script_parameters - if !Rails.configuration.API.DisabledAPIs.include?("jobs.list") + if !Rails.configuration.API.DisabledAPIs["jobs.list"] Job.readable_by(*@read_users).where(["jobs.script_parameters like ?", "%#{loc.to_s}%"]).each do |job| search_edges(visited, job.uuid, :search_down) end @@ -245,7 +245,7 @@ class Arvados::V1::CollectionsController < ApplicationController if direction == :search_up visited[c.uuid] = c.as_api_response - if !Rails.configuration.API.DisabledAPIs.include?("jobs.list") + if !Rails.configuration.API.DisabledAPIs["jobs.list"] Job.readable_by(*@read_users).where(output: c.portable_data_hash).each do |job| search_edges(visited, job.uuid, :search_up) end diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb index d502d5a698..46d3a75a3a 100644 --- a/services/api/app/controllers/arvados/v1/groups_controller.rb +++ b/services/api/app/controllers/arvados/v1/groups_controller.rb @@ -204,7 +204,7 @@ class Arvados::V1::GroupsController < ApplicationController table_names = Hash[klasses.collect { |k| [k, k.table_name] }] disabled_methods = Rails.configuration.API.DisabledAPIs - avail_klasses = table_names.select{|k, t| !disabled_methods.include?(t+'.index')} + avail_klasses = table_names.select{|k, t| !disabled_methods[t+'.index']} klasses = avail_klasses.keys request_filters.each do |col, op, val| diff --git a/services/api/app/controllers/arvados/v1/schema_controller.rb b/services/api/app/controllers/arvados/v1/schema_controller.rb index 313fe5d0a0..90d3db685e 100644 --- a/services/api/app/controllers/arvados/v1/schema_controller.rb +++ b/services/api/app/controllers/arvados/v1/schema_controller.rb @@ -401,7 +401,7 @@ class Arvados::V1::SchemaController < ApplicationController end end end - Rails.configuration.API.DisabledAPIs.each do |method| + Rails.configuration.API.DisabledAPIs.each do |method, _| ctrl, action = method.split('.', 2) discovery[:resources][ctrl][:methods].delete(action.to_sym) end diff --git a/services/api/app/mailers/admin_notifier.rb b/services/api/app/mailers/admin_notifier.rb index 45e329030f..2c39a3924e 100644 --- a/services/api/app/mailers/admin_notifier.rb +++ b/services/api/app/mailers/admin_notifier.rb @@ -10,7 +10,7 @@ class AdminNotifier < ActionMailer::Base def new_user(user) @user = user if not Rails.configuration.Users.NewUserNotificationRecipients.empty? then - @recipients = Rails.configuration.Users.NewUserNotificationRecipients + @recipients = Rails.configuration.Users.NewUserNotificationRecipients.keys logger.info "Sending mail to #{@recipients} about new user #{@user.uuid} (#{@user.full_name} <#{@user.email}>)" add_to_subject = '' @@ -27,7 +27,7 @@ class AdminNotifier < ActionMailer::Base def new_inactive_user(user) @user = user if not Rails.configuration.Users.NewInactiveUserNotificationRecipients.empty? then - @recipients = Rails.configuration.Users.NewInactiveUserNotificationRecipients + @recipients = Rails.configuration.Users.NewInactiveUserNotificationRecipients.keys logger.info "Sending mail to #{@recipients} about new user #{@user.uuid} (#{@user.full_name} <#{@user.email}>)" mail(to: @recipients, subject: "#{Rails.configuration.Users.EmailSubjectPrefix}New inactive user notification" diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb index 8c8ad8e254..f933126933 100644 --- a/services/api/app/models/arvados_model.rb +++ b/services/api/app/models/arvados_model.rb @@ -422,7 +422,7 @@ class ArvadosModel < ApplicationRecord end def logged_attributes - attributes.except(*Rails.configuration.AuditLogs.UnloggedAttributes) + attributes.except(*Rails.configuration.AuditLogs.UnloggedAttributes.keys) end def self.full_text_searchable_columns diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index ac00e5d39c..649e0f5d09 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -489,13 +489,17 @@ class Collection < ArvadosModel [c.portable_data_hash, c] }] + puts "mg #{migrated_collections} #{collections}" + collections.map { |c| # Check if the listed image is compatible first, if not, then try the # migration link. manifest = Keep::Manifest.new(c.manifest_text) + puts "m1 #{manifest.exact_file_count?(1)} #{manifest.files[0][1]} #{pattern}" if manifest.exact_file_count?(1) and manifest.files[0][1] =~ pattern c elsif m = migrated_collections[migrations[c.portable_data_hash]] + puts "m2 #{manifest.exact_file_count?(1)} #{manifest.files[0][1]} #{pattern}" manifest = Keep::Manifest.new(m.manifest_text) if manifest.exact_file_count?(1) and manifest.files[0][1] =~ pattern m @@ -521,7 +525,7 @@ class Collection < ArvadosModel joins("JOIN collections ON links.head_uuid = collections.uuid"). order("links.created_at DESC") - docker_image_formats = Rails.configuration.Containers.SupportedDockerImageFormats + docker_image_formats = Rails.configuration.Containers.SupportedDockerImageFormats.keys.map(&:to_s) if (docker_image_formats.include? 'v1' and docker_image_formats.include? 'v2') or filter_compatible_format == false diff --git a/services/api/app/models/node.rb b/services/api/app/models/node.rb index 044d83c287..d200bb8011 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.Containers.SLURM.Managed.ComputeNodeNameservers }, :as => :nameservers + t.add lambda { |x| Rails.configuration.Containers.SLURM.Managed.ComputeNodeNameservers.keys }, :as => :nameservers end after_initialize do diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb index fc5ae0a49d..ee44812e00 100644 --- a/services/api/app/models/user.rb +++ b/services/api/app/models/user.rb @@ -381,7 +381,7 @@ class User < ArvadosModel quoted_name = self.class.connection.quote_string(basename) next_username = basename next_suffix = 1 - while Rails.configuration.Users.AutoSetupUsernameBlacklist.include?(next_username) + while Rails.configuration.Users.AutoSetupUsernameBlacklist[next_username] next_suffix += 1 next_username = "%s%i" % [basename, next_suffix] end diff --git a/services/api/config/arvados_config.rb b/services/api/config/arvados_config.rb index cf4b842c4a..575c5f717f 100644 --- a/services/api/config/arvados_config.rb +++ b/services/api/config/arvados_config.rb @@ -73,12 +73,20 @@ end # Now make a copy $arvados_config = $arvados_config_global.deep_dup +def arrayToHash cfg, k, v + val = {} + v.each do |k| + val[k.to_s] = {} + end + ConfigLoader.set_cfg cfg, k, val +end + # Declare all our configuration items. arvcfg = ConfigLoader.new arvcfg.declare_config "ClusterID", NonemptyString, :uuid_prefix arvcfg.declare_config "ManagementToken", String, :ManagementToken arvcfg.declare_config "Git.Repositories", String, :git_repositories_dir -arvcfg.declare_config "API.DisabledAPIs", Array, :disable_api_methods +arvcfg.declare_config "API.DisabledAPIs", Hash, :disable_api_methods, method(:arrayToHash) 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 @@ -87,7 +95,7 @@ arvcfg.declare_config "API.RailsSessionSecretToken", NonemptyString, :secret_tok 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 -arvcfg.declare_config "Users.AutoSetupUsernameBlacklist", Array, :auto_setup_name_blacklist +arvcfg.declare_config "Users.AutoSetupUsernameBlacklist", Hash, :auto_setup_name_blacklist, method(:arrayToHash) arvcfg.declare_config "Users.NewUsersAreActive", Boolean, :new_users_are_active arvcfg.declare_config "Users.AutoAdminUserWithEmail", String, :auto_admin_user arvcfg.declare_config "Users.AutoAdminFirstUser", Boolean, :auto_admin_first_user @@ -95,15 +103,15 @@ arvcfg.declare_config "Users.UserProfileNotificationAddress", String, :user_prof arvcfg.declare_config "Users.AdminNotifierEmailFrom", String, :admin_notifier_email_from arvcfg.declare_config "Users.EmailSubjectPrefix", String, :email_subject_prefix arvcfg.declare_config "Users.UserNotifierEmailFrom", String, :user_notifier_email_from -arvcfg.declare_config "Users.NewUserNotificationRecipients", Array, :new_user_notification_recipients -arvcfg.declare_config "Users.NewInactiveUserNotificationRecipients", Array, :new_inactive_user_notification_recipients +arvcfg.declare_config "Users.NewUserNotificationRecipients", Hash, :new_user_notification_recipients, method(:arrayToHash) +arvcfg.declare_config "Users.NewInactiveUserNotificationRecipients", Hash, :new_inactive_user_notification_recipients, method(:arrayToHash) arvcfg.declare_config "Login.ProviderAppSecret", NonemptyString, :sso_app_secret arvcfg.declare_config "Login.ProviderAppID", NonemptyString, :sso_app_id arvcfg.declare_config "TLS.Insecure", Boolean, :sso_insecure arvcfg.declare_config "Services.SSO.ExternalURL", NonemptyString, :sso_provider_url arvcfg.declare_config "AuditLogs.MaxAge", ActiveSupport::Duration, :max_audit_log_age arvcfg.declare_config "AuditLogs.MaxDeleteBatch", Integer, :max_audit_log_delete_batch -arvcfg.declare_config "AuditLogs.UnloggedAttributes", Array, :unlogged_attributes +arvcfg.declare_config "AuditLogs.UnloggedAttributes", Hash, :unlogged_attributes, method(:arrayToHash) arvcfg.declare_config "SystemLogs.MaxRequestLogParamsSize", Integer, :max_request_log_params_size arvcfg.declare_config "Collections.DefaultReplication", Integer, :default_collection_replication arvcfg.declare_config "Collections.DefaultTrashLifetime", ActiveSupport::Duration, :default_trash_lifetime @@ -113,7 +121,7 @@ arvcfg.declare_config "Collections.TrashSweepInterval", ActiveSupport::Duration, arvcfg.declare_config "Collections.BlobSigningKey", NonemptyString, :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 "Containers.SupportedDockerImageFormats", Array, :docker_image_formats +arvcfg.declare_config "Containers.SupportedDockerImageFormats", Hash, :docker_image_formats, method(:arrayToHash) arvcfg.declare_config "Containers.LogReuseDecisions", Boolean, :log_reuse_decisions arvcfg.declare_config "Containers.DefaultKeepCacheRAM", Integer, :container_default_keep_cache_ram arvcfg.declare_config "Containers.MaxDispatchAttempts", Integer, :max_container_dispatch_attempts @@ -135,7 +143,7 @@ arvcfg.declare_config "Containers.SLURM.Managed.DNSServerConfTemplate", Pathname arvcfg.declare_config "Containers.SLURM.Managed.DNSServerReloadCommand", String, :dns_server_reload_command arvcfg.declare_config "Containers.SLURM.Managed.DNSServerUpdateCommand", String, :dns_server_update_command arvcfg.declare_config "Containers.SLURM.Managed.ComputeNodeDomain", String, :compute_node_domain -arvcfg.declare_config "Containers.SLURM.Managed.ComputeNodeNameservers", Array, :compute_node_nameservers +arvcfg.declare_config "Containers.SLURM.Managed.ComputeNodeNameservers", Hash, :compute_node_nameservers, method(:arrayToHash) arvcfg.declare_config "Containers.SLURM.Managed.AssignNodeHostname", String, :assign_node_hostname arvcfg.declare_config "Containers.JobsAPI.Enable", String, :enable_legacy_jobs_api, ->(cfg, k, v) { ConfigLoader.set_cfg cfg, "Containers.JobsAPI.Enable", v.to_s } arvcfg.declare_config "Containers.JobsAPI.CrunchJobWrapper", String, :crunch_job_wrapper diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb index 69e277cc2c..2637e77937 100644 --- a/services/api/test/unit/container_request_test.rb +++ b/services/api/test/unit/container_request_test.rb @@ -515,7 +515,7 @@ class ContainerRequestTest < ActiveSupport::TestCase test "Container.resolve_container_image(pdh)" do set_user_from_auth :active [[:docker_image, 'v1'], [:docker_image_1_12, 'v2']].each do |coll, ver| - Rails.configuration.Containers.SupportedDockerImageFormats = [ver] + Rails.configuration.Containers.SupportedDockerImageFormats = {ver=>{}} pdh = collections(coll).portable_data_hash resolved = Container.resolve_container_image(pdh) assert_equal resolved, pdh @@ -541,7 +541,7 @@ class ContainerRequestTest < ActiveSupport::TestCase end test "migrated docker image" do - Rails.configuration.Containers.SupportedDockerImageFormats = ['v2'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v2'=>{}} add_docker19_migration_link # Test that it returns only v2 images even though request is for v1 image. @@ -559,7 +559,7 @@ class ContainerRequestTest < ActiveSupport::TestCase end test "use unmigrated docker image" do - Rails.configuration.Containers.SupportedDockerImageFormats = ['v1'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v1'=>{}} add_docker19_migration_link # Test that it returns only supported v1 images even though there is a @@ -578,7 +578,7 @@ class ContainerRequestTest < ActiveSupport::TestCase end test "incompatible docker image v1" do - Rails.configuration.Containers.SupportedDockerImageFormats = ['v1'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v1'=>{}} add_docker19_migration_link # Don't return unsupported v2 image even if we ask for it directly. @@ -591,7 +591,7 @@ class ContainerRequestTest < ActiveSupport::TestCase end test "incompatible docker image v2" do - Rails.configuration.Containers.SupportedDockerImageFormats = ['v2'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v2'=>{}} # No migration link, don't return unsupported v1 image, set_user_from_auth :active diff --git a/services/api/test/unit/job_test.rb b/services/api/test/unit/job_test.rb index f47a1c10f9..33985ac9ec 100644 --- a/services/api/test/unit/job_test.rb +++ b/services/api/test/unit/job_test.rb @@ -426,7 +426,7 @@ class JobTest < ActiveSupport::TestCase end test "use migrated docker image if requesting old-format image by tag" do - Rails.configuration.Containers.SupportedDockerImageFormats = ['v2'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v2'=>{}} add_docker19_migration_link job = Job.create!( job_attrs( @@ -438,7 +438,7 @@ class JobTest < ActiveSupport::TestCase end test "use migrated docker image if requesting old-format image by pdh" do - Rails.configuration.Containers.SupportedDockerImageFormats = ['v2'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v2'=>{}} add_docker19_migration_link job = Job.create!( job_attrs( @@ -455,7 +455,7 @@ class JobTest < ActiveSupport::TestCase [:docker_image_1_12, :docker_image_1_12, :docker_image_1_12], ].each do |existing_image, request_image, expect_image| test "if a #{existing_image} job exists, #{request_image} yields #{expect_image} after migration" do - Rails.configuration.Containers.SupportedDockerImageFormats = ['v1'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v1'=>{}} if existing_image == :docker_image oldjob = Job.create!( @@ -477,7 +477,7 @@ class JobTest < ActiveSupport::TestCase end end - Rails.configuration.Containers.SupportedDockerImageFormats = ['v2'] + Rails.configuration.Containers.SupportedDockerImageFormats = {'v2'=>{}} add_docker19_migration_link # Check that both v1 and v2 images get resolved to v2. -- 2.30.2