[ARVADOS] updated: 2.1.0-446-g96370576f

Git user git at public.arvados.org
Tue Mar 2 21:32:19 UTC 2021


Summary of changes:
 lib/controller/rpc/conn.go            |  2 +-
 sdk/go/arvados/fs_project_test.go     | 16 ++++++++++++++++
 sdk/go/arvados/fs_site_test.go        |  1 +
 services/api/test/fixtures/groups.yml | 13 +++++++++++++
 4 files changed, 31 insertions(+), 1 deletion(-)

  discards  c1adfa7409d8f5186a93df589ea8ad9b1eb6414e (commit)
       via  96370576f11dd97429dd5a2424de7a5cafaa84ca (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (c1adfa7409d8f5186a93df589ea8ad9b1eb6414e)
            \
             N -- N -- N (96370576f11dd97429dd5a2424de7a5cafaa84ca)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

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 96370576f11dd97429dd5a2424de7a5cafaa84ca
Author: Ward Vandewege <ward at curii.com>
Date:   Fri Feb 26 11:19:57 2021 -0500

    17119: make controller understand filter groups.
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/lib/controller/rpc/conn.go b/lib/controller/rpc/conn.go
index b3713d938..6941e1487 100644
--- a/lib/controller/rpc/conn.go
+++ b/lib/controller/rpc/conn.go
@@ -23,6 +23,7 @@ import (
 
 	"git.arvados.org/arvados.git/sdk/go/arvados"
 	"git.arvados.org/arvados.git/sdk/go/auth"
+	"git.arvados.org/arvados.git/sdk/go/ctxlog"
 	"git.arvados.org/arvados.git/sdk/go/httpserver"
 )
 
@@ -445,9 +446,47 @@ func (conn *Conn) GroupList(ctx context.Context, options arvados.ListOptions) (a
 }
 
 func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupContentsOptions) (arvados.ObjectList, error) {
-	ep := arvados.EndpointGroupContents
+	// The requested UUID can be a user (virtual home project), which we just pass on to
+	// the API server.
+	if strings.Index(options.UUID, "j7d0g") != 6 {
+		ep := arvados.EndpointGroupContents
+		var resp arvados.ObjectList
+		err := conn.requestAndDecode(ctx, &resp, ep, nil, options)
+		return resp, err
+	}
+
+	log := ctxlog.FromContext(ctx)
 	var resp arvados.ObjectList
-	err := conn.requestAndDecode(ctx, &resp, ep, nil, options)
+
+	// Get the group object
+	epGet := arvados.EndpointGroupGet
+	var respGroup arvados.Group
+	err := conn.requestAndDecode(ctx, &respGroup, epGet, nil, options)
+	if err != nil {
+		return resp, err
+	}
+
+	// If the group has groupClass 'filter', apply the filters before getting the contents.
+	if respGroup.GroupClass == "filter" {
+		if filters, ok := respGroup.Properties["filters"]; ok {
+			for _, f := range filters.([]interface{}) {
+				// f is supposed to be a []string
+				tmp, ok2 := f.([]interface{})
+				if !ok2 || len(tmp) < 3 {
+					log.Warnf("filter unparsable: %T, %+v, original field: %T, %+v\n", tmp, tmp, f, f)
+					continue
+				}
+				var filter arvados.Filter
+				filter.Attr = tmp[0].(string)
+				filter.Operator = tmp[1].(string)
+				filter.Operand = tmp[2]
+				options.Filters = append(options.Filters, filter)
+			}
+		}
+	}
+
+	ep := arvados.EndpointGroupContents
+	err = conn.requestAndDecode(ctx, &resp, ep, nil, options)
 	return resp, err
 }
 
diff --git a/sdk/go/arvados/fs_project_test.go b/sdk/go/arvados/fs_project_test.go
index 86facd681..56a2bb826 100644
--- a/sdk/go/arvados/fs_project_test.go
+++ b/sdk/go/arvados/fs_project_test.go
@@ -39,6 +39,22 @@ func (sc *spyingClient) RequestAndDecode(dst interface{}, method, path string, b
 	return sc.Client.RequestAndDecode(dst, method, path, body, params)
 }
 
+// TestFilterGroup is a very basic filter group test. It makes sure that a
+// collection and group that match the filter are present, and that a group
+// that does not match the filter is not present.
+func (s *SiteFSSuite) TestFilterGroup(c *check.C) {
+	s.fs.MountProject("fg", fixtureThisFilterGroupUUID)
+
+	_, err := s.fs.OpenFile("/fg/baz_file", 0, 0)
+	c.Assert(err, check.IsNil)
+
+	_, err = s.fs.OpenFile("/fg/A Subproject", 0, 0)
+	c.Assert(err, check.IsNil)
+
+	_, err = s.fs.OpenFile("/fg/A Project", 0, 0)
+	c.Assert(err, check.Not(check.IsNil))
+}
+
 func (s *SiteFSSuite) TestCurrentUserHome(c *check.C) {
 	s.fs.MountProject("home", "")
 	s.testHomeProject(c, "/home")
diff --git a/sdk/go/arvados/fs_site_test.go b/sdk/go/arvados/fs_site_test.go
index 778b12015..9245023ba 100644
--- a/sdk/go/arvados/fs_site_test.go
+++ b/sdk/go/arvados/fs_site_test.go
@@ -18,6 +18,7 @@ const (
 	// package].
 	fixtureActiveToken             = "3kg6k6lzmp9kj5cpkcoxie963cmvjahbt2fod9zru30k1jqdmi"
 	fixtureAProjectUUID            = "zzzzz-j7d0g-v955i6s2oi1cbso"
+	fixtureThisFilterGroupUUID     = "zzzzz-j7d0g-thisfiltergroup"
 	fixtureFooAndBarFilesInDirUUID = "zzzzz-4zz18-foonbarfilesdir"
 	fixtureFooCollectionName       = "zzzzz-4zz18-fy296fx3hot09f7 added sometime"
 	fixtureFooCollectionPDH        = "1f4b0bc7583c2a7f9102c395f4ffc5e3+45"
diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb
index 394b5603b..79d7b2fb5 100644
--- a/services/api/app/controllers/arvados/v1/groups_controller.rb
+++ b/services/api/app/controllers/arvados/v1/groups_controller.rb
@@ -227,12 +227,30 @@ class Arvados::V1::GroupsController < ApplicationController
       end
     end
 
+    # filter groups need to be limited to those classes mentioned in the filters
+    # @object can also be a User object (virtual home project)
+    if @object and @object.is_a?(Group) and @object.group_class == "filter"
+      if request_filters.length() == 0
+        raise ArgumentError.new("Filter group needs to have filters defined")
+      end
+      request_filters.each do |col, op, val|
+        if col.index('.')
+          col = col.split('.')[0]
+          col = col.capitalize.sub(/s$/,'')
+          wanted_klasses << col
+        end
+      end
+    end
+
     filter_by_owner = {}
     if @object
-      if params['recursive']
-        filter_by_owner[:owner_uuid] = [@object.uuid] + @object.descendant_project_uuids
-      else
-        filter_by_owner[:owner_uuid] = @object.uuid
+      # filter groups should not have an owner_uuid filter applied
+      if ! @object.is_a?(Group) or (@object.is_a?(Group) and @object.group_class != "filter")
+        if params['recursive']
+          filter_by_owner[:owner_uuid] = [@object.uuid] + @object.descendant_project_uuids
+        else
+          filter_by_owner[:owner_uuid] = @object.uuid
+        end
       end
 
       if params['exclude_home_project']
diff --git a/services/api/test/fixtures/groups.yml b/services/api/test/fixtures/groups.yml
index 31a72f172..bf0641891 100644
--- a/services/api/test/fixtures/groups.yml
+++ b/services/api/test/fixtures/groups.yml
@@ -107,6 +107,19 @@ asubproject:
   description: "Test project belonging to active user's first test project"
   group_class: project
 
+afiltergroup:
+  uuid: zzzzz-j7d0g-thisfiltergroup
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  created_at: 2014-04-21 15:37:48 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  modified_at: 2014-04-21 15:37:48 -0400
+  updated_at: 2014-04-21 15:37:48 -0400
+  name: This filter group
+  group_class: filter
+  properties:
+    filters: [[ "collections.name", "like", "baz%" ], [ "groups.name", "=", "A Subproject" ]]
+
 future_project_viewing_group:
   uuid: zzzzz-j7d0g-futrprojviewgrp
   owner_uuid: zzzzz-tpzed-000000000000000

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list