Skip to content

Commit

Permalink
SVR-299: Omit hard-coded org-based project filtering (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrogan authored Feb 23, 2024
1 parent 785f31e commit f06bbbc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 35 deletions.
19 changes: 9 additions & 10 deletions flyteadmin/pkg/manager/impl/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions flyteadmin/pkg/manager/impl/project_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 0 additions & 6 deletions flyteadmin/pkg/manager/impl/project_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ func getMockApplicationConfigForProjectManagerTest() runtimeInterfaces.Applicati

func expectedDefaultQueryExpr() []*common.GormQueryExpr {
return []*common.GormQueryExpr{
{
Query: "org = ?",
Args: "",
},
{

Query: "state = ?",
Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
15 changes: 7 additions & 8 deletions flyteadmin/pkg/manager/impl/workflow_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions flyteadmin/pkg/repositories/gormimpl/task_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion flyteadmin/tests/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f06bbbc

Please sign in to comment.