From 2bd7edf29bad74e61da31b801afd85b4c33ef7fe Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 25 Aug 2016 13:44:24 -0400 Subject: [PATCH] 9709: Restore logging of manifest_text by default, add config option to omit it. --- services/api/app/models/api_client_authorization.rb | 4 +--- services/api/app/models/arvados_model.rb | 2 +- services/api/app/models/collection.rb | 6 ------ services/api/config/application.default.yml | 8 ++++++++ services/api/test/unit/log_test.rb | 8 +++++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/services/api/app/models/api_client_authorization.rb b/services/api/app/models/api_client_authorization.rb index 499a61b7d3..f7985a986a 100644 --- a/services/api/app/models/api_client_authorization.rb +++ b/services/api/app/models/api_client_authorization.rb @@ -65,9 +65,7 @@ class ApiClientAuthorization < ArvadosModel end def logged_attributes - attrs = attributes.dup - attrs.delete('api_token') - attrs + super.except 'api_token' end def self.default_orders diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb index 2908e40e33..c663d21d52 100644 --- a/services/api/app/models/arvados_model.rb +++ b/services/api/app/models/arvados_model.rb @@ -243,7 +243,7 @@ class ArvadosModel < ActiveRecord::Base end def logged_attributes - attributes + attributes.except *Rails.configuration.unlogged_attributes end def self.full_text_searchable_columns diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index d0001fdc32..4a054413ce 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -360,12 +360,6 @@ class Collection < ArvadosModel super - ["manifest_text"] end - def logged_attributes - attrs = attributes.dup - attrs.delete('manifest_text') - attrs - end - protected def portable_manifest_text self.class.munge_manifest_locators(manifest_text) do |match| diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml index ddc6eede83..e59f6e5b63 100644 --- a/services/api/config/application.default.yml +++ b/services/api/config/application.default.yml @@ -243,6 +243,14 @@ common: # silenced by throttling are not counted against this total. crunch_limit_log_bytes_per_job: 67108864 + # Attributes to avoid saving in events and audit logs. Notably, + # 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. + unlogged_attributes: [] ### ### Crunch, DNS & compute node management diff --git a/services/api/test/unit/log_test.rb b/services/api/test/unit/log_test.rb index 6bca80c778..fcd2b8018d 100644 --- a/services/api/test/unit/log_test.rb +++ b/services/api/test/unit/log_test.rb @@ -56,10 +56,11 @@ class LogTest < ActiveSupport::TestCase def assert_logged_with_clean_properties(obj, event_type, excluded_attr) assert_logged(obj, event_type) do |props| - ['old_attributes', 'new_attributes'].map { |k| props[k] }.compact - .each do |attributes| + ['old_attributes', 'new_attributes'].map do |logattr| + attributes = props[logattr] + next if attributes.nil? refute_includes(attributes, excluded_attr, - "log properties includes #{excluded_attr}") + "log #{logattr} includes #{excluded_attr}") end yield props if block_given? end @@ -271,6 +272,7 @@ class LogTest < ActiveSupport::TestCase end test "manifest_text not included in collection logs" do + Rails.configuration.unlogged_attributes = ["manifest_text"] act_as_system_user do coll = Collection.create(manifest_text: ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo\n") assert_logged_with_clean_properties(coll, :create, 'manifest_text') -- 2.30.2