From f06bbbc56a46c6cf48df81d5405c6c03368a8565 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Fri, 23 Feb 2024 10:54:25 -0800 Subject: [PATCH] SVR-299: Omit hard-coded org-based project filtering (#85) --- .../pkg/manager/impl/execution_manager.go | 19 +++++++++---------- .../pkg/manager/impl/project_manager.go | 10 +++++----- .../pkg/manager/impl/project_manager_test.go | 6 ------ .../validation/launch_plan_validator_test.go | 2 +- .../pkg/manager/impl/workflow_manager_test.go | 15 +++++++-------- .../repositories/gormimpl/task_repo_test.go | 7 +++---- flyteadmin/tests/project_test.go | 2 +- 7 files changed, 26 insertions(+), 35 deletions(-) diff --git a/flyteadmin/pkg/manager/impl/execution_manager.go b/flyteadmin/pkg/manager/impl/execution_manager.go index 1a7a1a5d67..3d94c83e36 100644 --- a/flyteadmin/pkg/manager/impl/execution_manager.go +++ b/flyteadmin/pkg/manager/impl/execution_manager.go @@ -13,16 +13,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "google.golang.org/grpc/codes" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - artifactsIdl "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/artifacts" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" - "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s" - "github.com/flyteorg/flyte/flytestdlib/contextutils" - "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - "github.com/flyteorg/flyte/flytestdlib/storage" - "github.com/flyteorg/flyte/flyteadmin/auth" "github.com/flyteorg/flyte/flyteadmin/pkg/artifacts" cloudeventInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/async/cloudevent/interfaces" @@ -44,7 +34,16 @@ import ( runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" workflowengineInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/workflowengine/interfaces" "github.com/flyteorg/flyte/flyteadmin/plugins" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + artifactsIdl "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/artifacts" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/event" + "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s" + "github.com/flyteorg/flyte/flytestdlib/contextutils" + "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/flyteorg/flyte/flytestdlib/promutils" + "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" + "github.com/flyteorg/flyte/flytestdlib/storage" ) const childContainerQueueKey = "child_queue" diff --git a/flyteadmin/pkg/manager/impl/project_manager.go b/flyteadmin/pkg/manager/impl/project_manager.go index d60ea26456..1697fce9e2 100644 --- a/flyteadmin/pkg/manager/impl/project_manager.go +++ b/flyteadmin/pkg/manager/impl/project_manager.go @@ -19,6 +19,10 @@ import ( "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" ) +var ( + emptyListProjectFilters []common.InlineFilter +) + type ProjectManager struct { db repoInterfaces.Repository config runtimeInterfaces.Configuration @@ -61,11 +65,7 @@ func (m *ProjectManager) ListProjects(ctx context.Context, request admin.Project // Add implicit active filters ordinarily added by database. requestFilters = fmt.Sprintf("eq(state,%d)", admin.Project_ACTIVE) } - spec := util.FilterSpec{ - Org: request.Org, - RequestFilters: requestFilters, - } - filters, err := util.GetDbFilters(spec, common.Project) + filters, err := util.AddRequestFilters(requestFilters, common.Project, emptyListProjectFilters) if err != nil { return nil, err } diff --git a/flyteadmin/pkg/manager/impl/project_manager_test.go b/flyteadmin/pkg/manager/impl/project_manager_test.go index dc6c539c61..20fe644d79 100644 --- a/flyteadmin/pkg/manager/impl/project_manager_test.go +++ b/flyteadmin/pkg/manager/impl/project_manager_test.go @@ -48,10 +48,6 @@ func getMockApplicationConfigForProjectManagerTest() runtimeInterfaces.Applicati func expectedDefaultQueryExpr() []*common.GormQueryExpr { return []*common.GormQueryExpr{ - { - Query: "org = ?", - Args: "", - }, { Query: "state = ?", @@ -112,12 +108,10 @@ func TestListProjects_HighLimit_SortBy_Filter(t *testing.T) { Direction: admin.Sort_DESCENDING, }, }, "", "name desc", []*common.GormQueryExpr{ - expectedDefaultQueryExpr()[0], &common.GormQueryExpr{ Query: "name = ?", Args: "foo", }, - expectedDefaultQueryExpr()[1], }, t) } diff --git a/flyteadmin/pkg/manager/impl/validation/launch_plan_validator_test.go b/flyteadmin/pkg/manager/impl/validation/launch_plan_validator_test.go index 8c2c768d42..86bfc5c6b7 100644 --- a/flyteadmin/pkg/manager/impl/validation/launch_plan_validator_test.go +++ b/flyteadmin/pkg/manager/impl/validation/launch_plan_validator_test.go @@ -317,7 +317,7 @@ func TestValidateSchedule_ArgNotFixed(t *testing.T) { }) t.Run("with rate", func(t *testing.T) { request := testutils.GetLaunchPlanRequestWithFixedRateSchedule(2, admin.FixedRateUnit_HOUR) - + err := validateSchedule(request, inputMap) assert.NotNil(t, err) }) diff --git a/flyteadmin/pkg/manager/impl/workflow_manager_test.go b/flyteadmin/pkg/manager/impl/workflow_manager_test.go index b46a80a41e..06cdb40ef0 100644 --- a/flyteadmin/pkg/manager/impl/workflow_manager_test.go +++ b/flyteadmin/pkg/manager/impl/workflow_manager_test.go @@ -11,14 +11,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" - "github.com/flyteorg/flyte/flytepropeller/pkg/compiler" - engine "github.com/flyteorg/flyte/flytepropeller/pkg/compiler/common" - mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/flyteorg/flyte/flytestdlib/storage" - "github.com/flyteorg/flyte/flytestdlib/utils" - "github.com/flyteorg/flyte/flyteadmin/pkg/artifacts" "github.com/flyteorg/flyte/flyteadmin/pkg/common" commonMocks "github.com/flyteorg/flyte/flyteadmin/pkg/common/mocks" @@ -32,6 +24,13 @@ import ( runtimeMocks "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/mocks" workflowengineInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/workflowengine/interfaces" workflowengineMocks "github.com/flyteorg/flyte/flyteadmin/pkg/workflowengine/mocks" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" + "github.com/flyteorg/flyte/flytepropeller/pkg/compiler" + engine "github.com/flyteorg/flyte/flytepropeller/pkg/compiler/common" + mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" + "github.com/flyteorg/flyte/flytestdlib/storage" + "github.com/flyteorg/flyte/flytestdlib/utils" ) const remoteClosureIdentifier = "s3://flyte/metadata/admin/remote closure id" diff --git a/flyteadmin/pkg/repositories/gormimpl/task_repo_test.go b/flyteadmin/pkg/repositories/gormimpl/task_repo_test.go index d99133105a..b601bd45b4 100644 --- a/flyteadmin/pkg/repositories/gormimpl/task_repo_test.go +++ b/flyteadmin/pkg/repositories/gormimpl/task_repo_test.go @@ -7,14 +7,13 @@ import ( mocket "github.com/Selvatico/go-mocket" "github.com/stretchr/testify/assert" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/flyteorg/flyte/flytestdlib/utils" - "github.com/flyteorg/flyte/flyteadmin/pkg/common" "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/errors" "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/models" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" + "github.com/flyteorg/flyte/flytestdlib/utils" ) const pythonTestTaskType = "python-task" diff --git a/flyteadmin/tests/project_test.go b/flyteadmin/tests/project_test.go index daf3c792f7..0534ca1f3a 100644 --- a/flyteadmin/tests/project_test.go +++ b/flyteadmin/tests/project_test.go @@ -5,13 +5,13 @@ package tests import ( "context" - "github.com/flyteorg/flyte/flytestdlib/utils" "testing" "github.com/stretchr/testify/assert" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" + "github.com/flyteorg/flyte/flytestdlib/utils" ) func TestCreateProject(t *testing.T) {