13593: Cleans up old experimental code.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 12 Mar 2019 15:04:49 +0000 (12:04 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 12 Mar 2019 15:04:49 +0000 (12:04 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/api/app/models/group.rb
services/api/app/models/link.rb
services/api/app/models/user.rb
services/api/config/application.default.yml
services/api/script/permission-updater.rb [deleted file]

index f4d5ec589d865493d4db19f4182834ed6946f349..46bb447d10f507b6e4fe03b7983e6cfa25111016 100644 (file)
@@ -40,7 +40,7 @@ class Group < ArvadosModel
   def invalidate_permissions_cache
     # Ensure a new group can be accessed by the appropriate users
     # immediately after being created.
-    User.invalidate_permissions_cache db_current_time.to_i, self.async_permissions_update
+    User.invalidate_permissions_cache self.async_permissions_update
   end
 
   def assign_name
index bf21cf4b672263b784d24b4f2cfcb00d65c0b195..ac3efe310dc6435ae5b4b303991778c84838eb41 100644 (file)
@@ -68,7 +68,7 @@ class Link < ArvadosModel
       # permissions for head_uuid and tail_uuid, and invalidate the
       # cache for only those users. (This would require a browseable
       # cache.)
-      User.invalidate_permissions_cache db_current_time.to_i
+      User.invalidate_permissions_cache
     end
   end
 
index 2f3c6c89cb830de0d2b022f67c2c36b14c8d1d71..8ed97e6b14c7b5ea313c856a4c548cbc591917ac 100644 (file)
@@ -141,16 +141,11 @@ class User < ArvadosModel
     true
   end
 
-  def self.invalidate_permissions_cache(timestamp=nil, async=false)
-    if Rails.configuration.async_permissions_update
-      timestamp = DbCurrentTime::db_current_time.to_i if timestamp.nil?
-      connection.execute "NOTIFY invalidate_permissions_cache, '#{timestamp}'"
-    else
-      refresh_permission_view(async)
-    end
+  def self.invalidate_permissions_cache(async=false)
+    refresh_permission_view(async)
   end
 
-  def invalidate_permissions_cache(timestamp=nil)
+  def invalidate_permissions_cache
     User.invalidate_permissions_cache
   end
 
index b7520228242685f9968891b900fe98d4cef28b1b..8f0dbf4e496b15e73d37083c5d2ac84dd1e8f61d 100644 (file)
@@ -496,12 +496,6 @@ common:
   # (included in vendor packages).
   package_version: false
 
-  # Enable asynchronous permission graph rebuild.  Must run
-  # script/permission-updater.rb as a separate process.  When the permission
-  # cache is invalidated, the background process will update the permission
-  # graph cache.  This feature is experimental!
-  async_permissions_update: false
-
   # Default value for container_count_max for container requests.  This is the
   # number of times Arvados will create a new container to satisfy a container
   # request.  If a container is cancelled it will retry a new container if
diff --git a/services/api/script/permission-updater.rb b/services/api/script/permission-updater.rb
deleted file mode 100755 (executable)
index 985aa05..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env ruby
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
-ENV["RAILS_ENV"] = ARGV[0] || ENV["RAILS_ENV"] || "development"
-require File.dirname(__FILE__) + '/../config/boot'
-require File.dirname(__FILE__) + '/../config/environment'
-include DbCurrentTime
-
-def update_permissions
-  timestamp = DbCurrentTime::db_current_time.to_i
-  Rails.logger.info "Begin updating permission cache"
-  User.all.each do |u|
-    u.calculate_group_permissions
-  end
-  Rails.cache.write "last_updated_permissions", timestamp
-  Rails.logger.info "Permission cache updated"
-end
-
-ActiveRecord::Base.connection_pool.with_connection do |connection|
-  conn = connection.instance_variable_get(:@connection)
-  begin
-    conn.async_exec "LISTEN invalidate_permissions_cache"
-
-    # Initial refresh of permissions graph
-    update_permissions
-
-    while true
-      # wait_for_notify will block until there is a change
-      # notification from Postgres about the permission cache,
-      # and then rebuild the permission cache.
-      conn.wait_for_notify do |channel, pid, payload|
-        last_updated = Rails.cache.read("last_updated_permissions")
-        Rails.logger.info "Got notify #{payload} last update #{last_updated}"
-        if last_updated.nil? || last_updated.to_i <= payload.to_i
-          update_permissions
-        end
-      end
-    end
-  ensure
-    # Don't want the connection to still be listening once we return
-    # it to the pool - could result in weird behavior for the next
-    # thread to check it out.
-    conn.async_exec "UNLISTEN *"
-  end
-end