Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions boilerplate/flyte/end2end/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
("core.control_flow.subworkflows.parent_wf", {"a": 3}),
("core.control_flow.subworkflows.nested_parent_wf", {"a": 3}),
("core.flyte_basics.basic_workflow.my_wf", {"a": 50, "b": "hello"}),
# Getting a 403 for the wikipedia image
# TODO: enable new files and folders workflows
# ("core.flyte_basics.files.rotate_one_workflow", {"in_image": "https://upload.wikimedia.org/wikipedia/commons/d/d2/Julia_set_%28C_%3D_0.285%2C_0.01%29.jpg"}),
("core.flyte_basics.folders.download_and_rotate", {}),
# ("core.flyte_basics.folders.download_and_rotate", {}),
("core.flyte_basics.hello_world.my_wf", {}),
("core.flyte_basics.lp.my_wf", {"val": 4}),
("core.flyte_basics.lp.go_greet", {"day_of_week": "5", "number": 3, "am": True}),
Expand Down
9 changes: 6 additions & 3 deletions pkg/manager/impl/validation/named_entity_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import (
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"google.golang.org/grpc/codes"
"k8s.io/apimachinery/pkg/util/sets"
)

var archivableResourceTypes = sets.NewInt32(int32(core.ResourceType_WORKFLOW), int32(core.ResourceType_TASK))

func ValidateNamedEntityGetRequest(request admin.NamedEntityGetRequest) error {
if err := ValidateResourceType(request.ResourceType); err != nil {
return err
Expand All @@ -29,11 +32,11 @@ func ValidateNamedEntityUpdateRequest(request admin.NamedEntityUpdateRequest) er
return shared.GetMissingArgumentError(shared.Metadata)
}

// Anything but the default state is only permitted for workflow resources.
// Only tasks and workflow resources can be modified from the default state.
if request.Metadata.State != admin.NamedEntityState_NAMED_ENTITY_ACTIVE &&
request.ResourceType != core.ResourceType_WORKFLOW {
!archivableResourceTypes.Has(int32(request.ResourceType)) {
return errors.NewFlyteAdminErrorf(codes.InvalidArgument,
"Only workflow name entities can have their state updated")
"Resource [%s] cannot have its state updated", request.ResourceType.String())
}
return nil
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/manager/impl/validation/named_entity_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ func TestValidateNamedEntityUpdateRequest(t *testing.T) {
State: admin.NamedEntityState_NAMED_ENTITY_ARCHIVED,
},
}))
assert.Nil(t, ValidateNamedEntityUpdateRequest(admin.NamedEntityUpdateRequest{
ResourceType: core.ResourceType_TASK,
Id: &admin.NamedEntityIdentifier{
Project: "project",
Domain: "domain",
Name: "name",
},
Metadata: &admin.NamedEntityMetadata{
State: admin.NamedEntityState_NAMED_ENTITY_ARCHIVED,
},
}))
}

func TestValidateNamedEntityListRequest(t *testing.T) {
Expand Down