[ARVADOS] updated: 1.3.0-2385-ge2ed71e15

Git user git at public.arvados.org
Tue Mar 31 18:49:46 UTC 2020


Summary of changes:
 lib/controller/federation/conn.go                  |  3 +++
 sdk/go/arvados/api.go                              |  5 +++--
 sdk/python/arvados/commands/federation_migrate.py  | 25 ++++++++++++++++------
 .../app/controllers/arvados/v1/users_controller.rb |  8 +++++++
 4 files changed, 32 insertions(+), 9 deletions(-)

       via  e2ed71e15de22c629b5b5e174aa351cce03ee381 (commit)
      from  1ef8afb74ea146eb3c8cead75d892a5c7a3aaa99 (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 e2ed71e15de22c629b5b5e174aa351cce03ee381
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Tue Mar 31 14:42:46 2020 -0400

    16263: Add no_federation to user update
    
    We might agree on a different API but try this and see if it helps
    pass the test.
    
    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 f67ea6713..05ea7769f 100644
--- a/lib/controller/federation/conn.go
+++ b/lib/controller/federation/conn.go
@@ -447,6 +447,9 @@ func (conn *Conn) UserCreate(ctx context.Context, options arvados.CreateOptions)
 }
 
 func (conn *Conn) UserUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.User, error) {
+	if options.NoFederation {
+		return conn.local.UserUpdate(ctx, options)
+	}
 	return conn.chooseBackend(options.UUID).UserUpdate(ctx, options)
 }
 
diff --git a/sdk/go/arvados/api.go b/sdk/go/arvados/api.go
index a30da6242..f3fdd254f 100644
--- a/sdk/go/arvados/api.go
+++ b/sdk/go/arvados/api.go
@@ -95,8 +95,9 @@ type CreateOptions struct {
 }
 
 type UpdateOptions struct {
-	UUID  string                 `json:"uuid"`
-	Attrs map[string]interface{} `json:"attrs"`
+	UUID         string                 `json:"uuid"`
+	Attrs        map[string]interface{} `json:"attrs"`
+	NoFederation bool                   `json:"no_federation"`
 }
 
 type UpdateUUIDOptions struct {
diff --git a/sdk/python/arvados/commands/federation_migrate.py b/sdk/python/arvados/commands/federation_migrate.py
index e1b8ee7d8..0eaf1c03e 100755
--- a/sdk/python/arvados/commands/federation_migrate.py
+++ b/sdk/python/arvados/commands/federation_migrate.py
@@ -173,8 +173,13 @@ def update_username(args, email, user_uuid, username, migratecluster, migratearv
         try:
             conflicts = migratearv.users().list(filters=[["username", "=", username]], no_federation=True).execute()
             if conflicts["items"]:
-                migratearv.users().update(uuid=conflicts["items"][0]["uuid"], body={"user": {"username": username+"migrate"}}).execute()
-            migratearv.users().update(uuid=user_uuid, body={"user": {"username": username}}).execute()
+                # There's already a user with the username, move the old user out of the way
+                migratearv.users().update(uuid=conflicts["items"][0]["uuid"],
+                                          no_federation=True,
+                                          body={"user": {"username": username+"migrate"}}).execute()
+            migratearv.users().update(uuid=user_uuid,
+                                      no_federation=True,
+                                      body={"user": {"username": username}}).execute()
         except arvados.errors.ApiError as e:
             print("(%s) Error updating username of %s to '%s' on %s: %s" % (email, user_uuid, username, migratecluster, e))
 
@@ -204,10 +209,14 @@ def choose_new_user(args, by_email, email, userhome, username, old_user_uuid, cl
             user = None
             try:
                 olduser = oldhomearv.users().get(uuid=old_user_uuid).execute()
-                conflicts = homearv.users().list(filters=[["username", "=", username]], no_federation=True).execute()
+                conflicts = homearv.users().list(filters=[["username", "=", username]],
+                                                 no_federation=True).execute()
                 if conflicts["items"]:
-                    homearv.users().update(uuid=conflicts["items"][0]["uuid"], body={"user": {"username": username+"migrate"}}).execute()
-                user = homearv.users().create(body={"user": {"email": email, "username": username, "is_active": olduser["is_active"]}}).execute()
+                    homearv.users().update(uuid=conflicts["items"][0]["uuid"],
+                                           no_federation=True,
+                                           body={"user": {"username": username+"migrate"}}).execute()
+                user = homearv.users().create(body={"user": {"email": email, "username": username,
+                                                             "is_active": olduser["is_active"]}}).execute()
             except arvados.errors.ApiError as e:
                 print("(%s) Could not create user: %s" % (email, str(e)))
                 return None
@@ -259,7 +268,8 @@ def activate_remote_user(args, email, homearv, migratearv, old_user_uuid, new_us
     try:
         ru = urllib.parse.urlparse(migratearv._rootDesc["rootUrl"])
         if not args.dry_run:
-            newuser = arvados.api(host=ru.netloc, token=salted, insecure=os.environ.get("ARVADOS_API_HOST_INSECURE")).users().current().execute()
+            newuser = arvados.api(host=ru.netloc, token=salted,
+                                  insecure=os.environ.get("ARVADOS_API_HOST_INSECURE")).users().current().execute()
         else:
             newuser = {"is_active": True, "username": username}
     except arvados.errors.ApiError as e:
@@ -270,7 +280,8 @@ def activate_remote_user(args, email, homearv, migratearv, old_user_uuid, new_us
         print("(%s) Activating user %s on %s" % (email, new_user_uuid, migratecluster))
         try:
             if not args.dry_run:
-                migratearv.users().update(uuid=new_user_uuid, body={"is_active": True}).execute()
+                migratearv.users().update(uuid=new_user_uuid, no_federation=True,
+                                          body={"is_active": True}).execute()
         except arvados.errors.ApiError as e:
             print("(%s) Could not activate user %s on %s: %s" % (email, new_user_uuid, migratecluster, e))
             return None
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 289e82567..475f6d54a 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -249,6 +249,14 @@ class Arvados::V1::UsersController < ApplicationController
     }
   end
 
+  def self._update_requires_parameters
+    super.merge({
+      no_federation: {
+        type: 'boolean', required: false,
+      },
+    })
+  end
+
   def self._update_uuid_requires_parameters
     {
       new_uuid: {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list