[ARVADOS] created: 2bd7edf29bad74e61da31b801afd85b4c33ef7fe

Git user git at public.curoverse.com
Thu Aug 25 13:45:43 EDT 2016


        at  2bd7edf29bad74e61da31b801afd85b4c33ef7fe (commit)


commit 2bd7edf29bad74e61da31b801afd85b4c33ef7fe
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Aug 25 13:44:24 2016 -0400

    9709: Restore logging of manifest_text by default, add config option to omit it.

diff --git a/services/api/app/models/api_client_authorization.rb b/services/api/app/models/api_client_authorization.rb
index 499a61b..f7985a9 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 2908e40..c663d21 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 d0001fd..4a05441 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 ddc6eed..e59f6e5 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 6bca80c..fcd2b80 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')

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list