[ARVADOS] updated: 2.1.0-49-gd2b777edd

Git user git at public.arvados.org
Tue Nov 24 15:03:05 UTC 2020


Summary of changes:
 .../app/controllers/application_controller.rb       |  2 +-
 apps/workbench/app/controllers/users_controller.rb  | 12 ++++++++++++
 apps/workbench/app/views/users/profile.html.erb     | 21 +++++++++++----------
 lib/controller/federation/conn.go                   | 13 ++++++++++++-
 4 files changed, 36 insertions(+), 12 deletions(-)

       via  d2b777eddf66e409a2ea74818fc8d17d6e25d9a6 (commit)
       via  3ceb9e0b9023d1f18c3118ddfa38358f4fc50868 (commit)
       via  ad2fd38b6c67f72c6eb9426f1a320d9517b694cd (commit)
      from  df6a469478a5f102e16682d0ab1d5f7dce67aaf3 (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 d2b777eddf66e409a2ea74818fc8d17d6e25d9a6
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Mon Nov 23 10:59:06 2020 -0500

    17154: Add comment.  Use strings.HasPrefix
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index d782bcb40..21ea7a8e6 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -39,6 +39,17 @@ class UsersController < ApplicationController
 
   def profile
     params[:offer_return_to] ||= params[:return_to]
+
+    # In a federation situation, when you get a user record using
+    # "current user of token" it can fetch a stale user record from
+    # the local cluster. So even if profile settings were just written
+    # to the user record on the login cluster (because the user just
+    # filled out the profile), those profile settings may not appear
+    # in the "current user" response because it is returning a cached
+    # record from the local cluster.
+    #
+    # In this case, explicitly fetching user record forces it to get a
+    # fresh record from the login cluster.
     Thread.current[:user] = User.find(current_user.uuid)
   end
 
diff --git a/lib/controller/federation/conn.go b/lib/controller/federation/conn.go
index 7cfb2b579..fc23327a7 100644
--- a/lib/controller/federation/conn.go
+++ b/lib/controller/federation/conn.go
@@ -458,7 +458,7 @@ func (conn *Conn) UserUpdate(ctx context.Context, options arvados.UpdateOptions)
 	if err != nil {
 		return resp, err
 	}
-	if options.UUID[:5] != conn.cluster.ClusterID {
+	if !strings.HasPrefix(options.UUID, conn.cluster.ClusterID) {
 		// Copy the updated user record to the local cluster
 		err = conn.batchUpdateUsers(ctx, arvados.ListOptions{}, []arvados.User{resp})
 		if err != nil {

commit 3ceb9e0b9023d1f18c3118ddfa38358f4fc50868
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Fri Nov 20 16:01:25 2020 -0500

    17154: Copy updates on federated users to local cluster
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/lib/controller/federation/conn.go b/lib/controller/federation/conn.go
index f07c3b631..7cfb2b579 100644
--- a/lib/controller/federation/conn.go
+++ b/lib/controller/federation/conn.go
@@ -454,7 +454,18 @@ func (conn *Conn) UserUpdate(ctx context.Context, options arvados.UpdateOptions)
 	if options.BypassFederation {
 		return conn.local.UserUpdate(ctx, options)
 	}
-	return conn.chooseBackend(options.UUID).UserUpdate(ctx, options)
+	resp, err := conn.chooseBackend(options.UUID).UserUpdate(ctx, options)
+	if err != nil {
+		return resp, err
+	}
+	if options.UUID[:5] != conn.cluster.ClusterID {
+		// Copy the updated user record to the local cluster
+		err = conn.batchUpdateUsers(ctx, arvados.ListOptions{}, []arvados.User{resp})
+		if err != nil {
+			return arvados.User{}, err
+		}
+	}
+	return resp, err
 }
 
 func (conn *Conn) UserUpdateUUID(ctx context.Context, options arvados.UpdateUUIDOptions) (arvados.User, error) {

commit ad2fd38b6c67f72c6eb9426f1a320d9517b694cd
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Fri Nov 20 15:25:27 2020 -0500

    17154: Make sure most current user record is loaded.
    
    Convert 'option' items (which are symbols) to strings for value comparison
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index cf4bfa8c5..6d139cd5f 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -760,7 +760,7 @@ class ApplicationController < ActionController::Base
     if current_user && !profile_config.empty?
       current_user_profile = current_user.prefs[:profile]
       profile_config.each do |k, entry|
-        if entry['Required']
+        if entry[:Required]
           if !current_user_profile ||
              !current_user_profile[k] ||
              current_user_profile[k].empty?
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 27fc12bf4..d782bcb40 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -39,6 +39,7 @@ class UsersController < ApplicationController
 
   def profile
     params[:offer_return_to] ||= params[:return_to]
+    Thread.current[:user] = User.find(current_user.uuid)
   end
 
   def activity
diff --git a/apps/workbench/app/views/users/profile.html.erb b/apps/workbench/app/views/users/profile.html.erb
index 6692196da..caa22bda1 100644
--- a/apps/workbench/app/views/users/profile.html.erb
+++ b/apps/workbench/app/views/users/profile.html.erb
@@ -68,29 +68,30 @@ SPDX-License-Identifier: AGPL-3.0 %>
               </div>
 
               <% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
-                <% if entry['Key'] %>
+                <% if entry[:Key] %>
                   <%
                       show_save_button = true
-                      label = entry['Required'] ? '* ' : ''
-                      label += entry['FormFieldTitle']
-                      value = current_user_profile[entry['Key'].to_sym] if current_user_profile
+                      label = entry[:Required] ? '* ' : ''
+                      label += entry[:FormFieldTitle]
+                      value = current_user_profile[entry[:Key].to_sym] if current_user_profile
                   %>
                   <div class="form-group">
-                    <label for="<%=entry['Key']%>"
+                    <label for="<%=entry[:Key]%>"
                            class="col-sm-3 control-label"
-                           style=<%="color:red" if entry['Required']&&(!value||value.empty?)%>> <%=label%>
+                           style=<%="color:red" if entry[:Required]&&(!value||value.empty?)%>> <%=label%>
                     </label>
-                    <% if entry['Type'] == 'select' %>
+                    <% if entry[:Type] == 'select' %>
                       <div class="col-sm-8">
-                        <select class="form-control" name="user[prefs][profile][<%=entry['Key']%>]">
-                          <% entry['Options'].each do |option, _| %>
+                        <select class="form-control" name="user[prefs][profile][<%=entry[:Key]%>]">
+                          <% entry[:Options].each do |option, _| %>
+			    <% option = option.to_s %>
                             <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
                           <% end %>
                         </select>
                       </div>
                     <% else %>
                       <div class="col-sm-8">
-                        <input type="text" class="form-control" name="user[prefs][profile][<%=entry['Key']%>]" placeholder="<%=entry['FormFieldDescription']%>" value="<%=value%>" ></input>
+                        <input type="text" class="form-control" name="user[prefs][profile][<%=entry[:Key]%>]" placeholder="<%=entry[:FormFieldDescription]%>" value="<%=value%>" ></input>
                       </div>
                     <% end %>
                   </div>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list