From 10ae91c3fcd12e25f1593661c220161b00b6c05e Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Mon, 12 Aug 2024 18:57:23 +0200 Subject: [PATCH] Don't error when attempting to trigger schedules for inactive projects (#5649) * Don't error when attempting to trigger schedules for inactive projects Signed-off-by: Katrina Rogan * regen Signed-off-by: Katrina Rogan --------- Signed-off-by: Katrina Rogan Signed-off-by: Vladyslav Libov --- flyteadmin/pkg/errors/errors.go | 12 ++ flyteadmin/pkg/errors/errors_test.go | 12 ++ .../impl/validation/project_validator.go | 3 +- .../scheduler/executor/executor_impl.go | 19 +++ .../scheduler/executor/executor_impl_test.go | 12 ++ .../gen/pb-es/flyteidl/admin/project_pb.ts | 50 +++++++ .../gen/pb-go/flyteidl/admin/project.pb.go | 114 +++++++++++++--- flyteidl/gen/pb-js/flyteidl.d.ts | 58 ++++++++ flyteidl/gen/pb-js/flyteidl.js | 127 ++++++++++++++++++ .../pb_python/flyteidl/admin/project_pb2.py | 4 +- .../pb_python/flyteidl/admin/project_pb2.pyi | 8 ++ flyteidl/gen/pb_rust/flyteidl.admin.rs | 12 ++ flyteidl/protos/flyteidl/admin/project.proto | 12 ++ 13 files changed, 421 insertions(+), 22 deletions(-) diff --git a/flyteadmin/pkg/errors/errors.go b/flyteadmin/pkg/errors/errors.go index 51e5ede579..78727a7305 100644 --- a/flyteadmin/pkg/errors/errors.go +++ b/flyteadmin/pkg/errors/errors.go @@ -202,3 +202,15 @@ func IsDoesNotExistError(err error) bool { adminError, ok := err.(FlyteAdminError) return ok && adminError.Code() == codes.NotFound } + +func NewInactiveProjectError(ctx context.Context, id string) FlyteAdminError { + errMsg := fmt.Sprintf("project [%s] is not active", id) + statusErr, transformationErr := NewFlyteAdminError(codes.InvalidArgument, errMsg).WithDetails(&admin.InactiveProject{ + Id: id, + }) + if transformationErr != nil { + logger.Errorf(ctx, "failed to wrap grpc status in type 'Error': %v", transformationErr) + return NewFlyteAdminErrorf(codes.InvalidArgument, errMsg) + } + return statusErr +} diff --git a/flyteadmin/pkg/errors/errors_test.go b/flyteadmin/pkg/errors/errors_test.go index c126f96d6d..daaa060340 100644 --- a/flyteadmin/pkg/errors/errors_test.go +++ b/flyteadmin/pkg/errors/errors_test.go @@ -310,3 +310,15 @@ func TestIsNotDoesNotExistError(t *testing.T) { func TestIsNotDoesNotExistErrorBecauseOfNoneAdminError(t *testing.T) { assert.False(t, IsDoesNotExistError(errors.New("foo"))) } + +func TestNewInactiveProjectError(t *testing.T) { + err := NewInactiveProjectError(context.TODO(), identifier.GetProject()) + statusErr, ok := status.FromError(err) + + assert.True(t, ok) + + details, ok := statusErr.Details()[0].(*admin.InactiveProject) + + assert.True(t, ok) + assert.Equal(t, identifier.GetProject(), details.Id) +} diff --git a/flyteadmin/pkg/manager/impl/validation/project_validator.go b/flyteadmin/pkg/manager/impl/validation/project_validator.go index 8577c13e2b..8a76ce889d 100644 --- a/flyteadmin/pkg/manager/impl/validation/project_validator.go +++ b/flyteadmin/pkg/manager/impl/validation/project_validator.go @@ -71,8 +71,7 @@ func ValidateProjectAndDomain( projectID, domainID, err) } if *project.State != int32(admin.Project_ACTIVE) { - return errors.NewFlyteAdminErrorf(codes.InvalidArgument, - "project [%s] is not active", projectID) + return errors.NewInactiveProjectError(ctx, projectID) } var validDomain bool domains := config.GetDomainsConfig() diff --git a/flyteadmin/scheduler/executor/executor_impl.go b/flyteadmin/scheduler/executor/executor_impl.go index 30ab7f0677..dffb98e1b6 100644 --- a/flyteadmin/scheduler/executor/executor_impl.go +++ b/flyteadmin/scheduler/executor/executor_impl.go @@ -114,6 +114,10 @@ func (w *executor) Execute(ctx context.Context, scheduledTime time.Time, s model }, func() error { _, execErr := w.adminServiceClient.CreateExecution(context.Background(), executionRequest) + if isInactiveProjectError(execErr) { + logger.Debugf(ctx, "project %+v is inactive, ignoring schedule create failure for %+v", s.Project, s) + return nil + } return execErr }, ) @@ -144,3 +148,18 @@ func getExecutorMetrics(scope promutils.Scope) executorMetrics { "count of successful attempts to fire execution for a schedules"), } } + +func isInactiveProjectError(err error) bool { + statusErr, ok := status.FromError(err) + if !ok { + return false + } + if len(statusErr.Details()) > 0 { + for _, detail := range statusErr.Details() { + if _, ok := detail.(*admin.InactiveProject); ok { + return true + } + } + } + return false +} diff --git a/flyteadmin/scheduler/executor/executor_impl_test.go b/flyteadmin/scheduler/executor/executor_impl_test.go index e864d68d79..fc75367ca9 100644 --- a/flyteadmin/scheduler/executor/executor_impl_test.go +++ b/flyteadmin/scheduler/executor/executor_impl_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/flyteorg/flyte/flyteadmin/pkg/errors" "github.com/flyteorg/flyte/flyteadmin/scheduler/repositories/models" @@ -98,3 +99,14 @@ func TestExecutorInactiveSchedule(t *testing.T) { err := executor.Execute(context.Background(), time.Now(), schedule) assert.Nil(t, err) } + +func TestIsInactiveProjectError(t *testing.T) { + statusErr := status.New(codes.InvalidArgument, "foo") + var transformationErr error + statusErr, transformationErr = statusErr.WithDetails(&admin.InactiveProject{ + Id: "project", + }) + assert.NoError(t, transformationErr) + + assert.True(t, isInactiveProjectError(statusErr.Err())) +} diff --git a/flyteidl/gen/pb-es/flyteidl/admin/project_pb.ts b/flyteidl/gen/pb-es/flyteidl/admin/project_pb.ts index 11f2726e08..a6fc913c03 100644 --- a/flyteidl/gen/pb-es/flyteidl/admin/project_pb.ts +++ b/flyteidl/gen/pb-es/flyteidl/admin/project_pb.ts @@ -540,3 +540,53 @@ export class ProjectGetRequest extends Message { } } +/** + * Error returned for inactive projects + * + * @generated from message flyteidl.admin.InactiveProject + */ +export class InactiveProject extends Message { + /** + * Indicates a unique project. + * +required + * + * @generated from field: string id = 1; + */ + id = ""; + + /** + * Optional, org key applied to the resource. + * + * @generated from field: string org = 2; + */ + org = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "flyteidl.admin.InactiveProject"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "org", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): InactiveProject { + return new InactiveProject().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): InactiveProject { + return new InactiveProject().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): InactiveProject { + return new InactiveProject().fromJsonString(jsonString, options); + } + + static equals(a: InactiveProject | PlainMessage | undefined, b: InactiveProject | PlainMessage | undefined): boolean { + return proto3.util.equals(InactiveProject, a, b); + } +} + diff --git a/flyteidl/gen/pb-go/flyteidl/admin/project.pb.go b/flyteidl/gen/pb-go/flyteidl/admin/project.pb.go index 243f46bf5d..d34451452b 100644 --- a/flyteidl/gen/pb-go/flyteidl/admin/project.pb.go +++ b/flyteidl/gen/pb-go/flyteidl/admin/project.pb.go @@ -661,6 +661,65 @@ func (x *ProjectGetRequest) GetOrg() string { return "" } +// Error returned for inactive projects +type InactiveProject struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Indicates a unique project. + // +required + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Optional, org key applied to the resource. + Org string `protobuf:"bytes,2,opt,name=org,proto3" json:"org,omitempty"` +} + +func (x *InactiveProject) Reset() { + *x = InactiveProject{} + if protoimpl.UnsafeEnabled { + mi := &file_flyteidl_admin_project_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InactiveProject) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InactiveProject) ProtoMessage() {} + +func (x *InactiveProject) ProtoReflect() protoreflect.Message { + mi := &file_flyteidl_admin_project_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InactiveProject.ProtoReflect.Descriptor instead. +func (*InactiveProject) Descriptor() ([]byte, []int) { + return file_flyteidl_admin_project_proto_rawDescGZIP(), []int{10} +} + +func (x *InactiveProject) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *InactiveProject) GetOrg() string { + if x != nil { + return x.Org + } + return "" +} + var File_flyteidl_admin_project_proto protoreflect.FileDescriptor var file_flyteidl_admin_project_proto_rawDesc = []byte{ @@ -725,19 +784,23 @@ var file_flyteidl_admin_project_proto_rawDesc = []byte{ 0x73, 0x65, 0x22, 0x35, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x72, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x72, 0x67, 0x42, 0xb8, 0x01, 0x0a, 0x12, 0x63, 0x6f, - 0x6d, 0x2e, 0x66, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x42, 0x0c, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x6c, 0x79, - 0x74, 0x65, 0x6f, 0x72, 0x67, 0x2f, 0x66, 0x6c, 0x79, 0x74, 0x65, 0x2f, 0x66, 0x6c, 0x79, 0x74, - 0x65, 0x69, 0x64, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x62, 0x2d, 0x67, 0x6f, 0x2f, 0x66, - 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0xa2, 0x02, 0x03, - 0x46, 0x41, 0x58, 0xaa, 0x02, 0x0e, 0x46, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x2e, 0x41, - 0x64, 0x6d, 0x69, 0x6e, 0xca, 0x02, 0x0e, 0x46, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x5c, - 0x41, 0x64, 0x6d, 0x69, 0x6e, 0xe2, 0x02, 0x1a, 0x46, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, - 0x5c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x0f, 0x46, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x3a, 0x3a, 0x41, - 0x64, 0x6d, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x72, 0x67, 0x22, 0x33, 0x0a, 0x0f, 0x49, 0x6e, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, + 0x6f, 0x72, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x72, 0x67, 0x42, 0xb8, + 0x01, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x66, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x2e, + 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x42, 0x0c, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x66, 0x6c, 0x79, 0x74, 0x65, 0x6f, 0x72, 0x67, 0x2f, 0x66, 0x6c, 0x79, 0x74, 0x65, + 0x2f, 0x66, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x62, + 0x2d, 0x67, 0x6f, 0x2f, 0x66, 0x6c, 0x79, 0x74, 0x65, 0x69, 0x64, 0x6c, 0x2f, 0x61, 0x64, 0x6d, + 0x69, 0x6e, 0xa2, 0x02, 0x03, 0x46, 0x41, 0x58, 0xaa, 0x02, 0x0e, 0x46, 0x6c, 0x79, 0x74, 0x65, + 0x69, 0x64, 0x6c, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0xca, 0x02, 0x0e, 0x46, 0x6c, 0x79, 0x74, + 0x65, 0x69, 0x64, 0x6c, 0x5c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0xe2, 0x02, 0x1a, 0x46, 0x6c, 0x79, + 0x74, 0x65, 0x69, 0x64, 0x6c, 0x5c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x46, 0x6c, 0x79, 0x74, 0x65, 0x69, + 0x64, 0x6c, 0x3a, 0x3a, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -753,7 +816,7 @@ func file_flyteidl_admin_project_proto_rawDescGZIP() []byte { } var file_flyteidl_admin_project_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_flyteidl_admin_project_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_flyteidl_admin_project_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_flyteidl_admin_project_proto_goTypes = []interface{}{ (Project_ProjectState)(0), // 0: flyteidl.admin.Project.ProjectState (*GetDomainRequest)(nil), // 1: flyteidl.admin.GetDomainRequest @@ -766,16 +829,17 @@ var file_flyteidl_admin_project_proto_goTypes = []interface{}{ (*ProjectRegisterResponse)(nil), // 8: flyteidl.admin.ProjectRegisterResponse (*ProjectUpdateResponse)(nil), // 9: flyteidl.admin.ProjectUpdateResponse (*ProjectGetRequest)(nil), // 10: flyteidl.admin.ProjectGetRequest - (*Labels)(nil), // 11: flyteidl.admin.Labels - (*Sort)(nil), // 12: flyteidl.admin.Sort + (*InactiveProject)(nil), // 11: flyteidl.admin.InactiveProject + (*Labels)(nil), // 12: flyteidl.admin.Labels + (*Sort)(nil), // 13: flyteidl.admin.Sort } var file_flyteidl_admin_project_proto_depIdxs = []int32{ 2, // 0: flyteidl.admin.GetDomainsResponse.domains:type_name -> flyteidl.admin.Domain 2, // 1: flyteidl.admin.Project.domains:type_name -> flyteidl.admin.Domain - 11, // 2: flyteidl.admin.Project.labels:type_name -> flyteidl.admin.Labels + 12, // 2: flyteidl.admin.Project.labels:type_name -> flyteidl.admin.Labels 0, // 3: flyteidl.admin.Project.state:type_name -> flyteidl.admin.Project.ProjectState 4, // 4: flyteidl.admin.Projects.projects:type_name -> flyteidl.admin.Project - 12, // 5: flyteidl.admin.ProjectListRequest.sort_by:type_name -> flyteidl.admin.Sort + 13, // 5: flyteidl.admin.ProjectListRequest.sort_by:type_name -> flyteidl.admin.Sort 4, // 6: flyteidl.admin.ProjectRegisterRequest.project:type_name -> flyteidl.admin.Project 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type @@ -911,6 +975,18 @@ func file_flyteidl_admin_project_proto_init() { return nil } } + file_flyteidl_admin_project_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InactiveProject); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -918,7 +994,7 @@ func file_flyteidl_admin_project_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_flyteidl_admin_project_proto_rawDesc, NumEnums: 1, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/flyteidl/gen/pb-js/flyteidl.d.ts b/flyteidl/gen/pb-js/flyteidl.d.ts index a1d9a34637..ada71f1f09 100644 --- a/flyteidl/gen/pb-js/flyteidl.d.ts +++ b/flyteidl/gen/pb-js/flyteidl.d.ts @@ -18184,6 +18184,64 @@ export namespace flyteidl { public static verify(message: { [k: string]: any }): (string|null); } + /** Properties of an InactiveProject. */ + interface IInactiveProject { + + /** InactiveProject id */ + id?: (string|null); + + /** InactiveProject org */ + org?: (string|null); + } + + /** Represents an InactiveProject. */ + class InactiveProject implements IInactiveProject { + + /** + * Constructs a new InactiveProject. + * @param [properties] Properties to set + */ + constructor(properties?: flyteidl.admin.IInactiveProject); + + /** InactiveProject id. */ + public id: string; + + /** InactiveProject org. */ + public org: string; + + /** + * Creates a new InactiveProject instance using the specified properties. + * @param [properties] Properties to set + * @returns InactiveProject instance + */ + public static create(properties?: flyteidl.admin.IInactiveProject): flyteidl.admin.InactiveProject; + + /** + * Encodes the specified InactiveProject message. Does not implicitly {@link flyteidl.admin.InactiveProject.verify|verify} messages. + * @param message InactiveProject message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: flyteidl.admin.IInactiveProject, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an InactiveProject message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns InactiveProject + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): flyteidl.admin.InactiveProject; + + /** + * Verifies an InactiveProject message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + } + /** Properties of a ProjectAttributes. */ interface IProjectAttributes { diff --git a/flyteidl/gen/pb-js/flyteidl.js b/flyteidl/gen/pb-js/flyteidl.js index 3402b1bdbb..8f446b4aba 100644 --- a/flyteidl/gen/pb-js/flyteidl.js +++ b/flyteidl/gen/pb-js/flyteidl.js @@ -43952,6 +43952,133 @@ return ProjectGetRequest; })(); + admin.InactiveProject = (function() { + + /** + * Properties of an InactiveProject. + * @memberof flyteidl.admin + * @interface IInactiveProject + * @property {string|null} [id] InactiveProject id + * @property {string|null} [org] InactiveProject org + */ + + /** + * Constructs a new InactiveProject. + * @memberof flyteidl.admin + * @classdesc Represents an InactiveProject. + * @implements IInactiveProject + * @constructor + * @param {flyteidl.admin.IInactiveProject=} [properties] Properties to set + */ + function InactiveProject(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * InactiveProject id. + * @member {string} id + * @memberof flyteidl.admin.InactiveProject + * @instance + */ + InactiveProject.prototype.id = ""; + + /** + * InactiveProject org. + * @member {string} org + * @memberof flyteidl.admin.InactiveProject + * @instance + */ + InactiveProject.prototype.org = ""; + + /** + * Creates a new InactiveProject instance using the specified properties. + * @function create + * @memberof flyteidl.admin.InactiveProject + * @static + * @param {flyteidl.admin.IInactiveProject=} [properties] Properties to set + * @returns {flyteidl.admin.InactiveProject} InactiveProject instance + */ + InactiveProject.create = function create(properties) { + return new InactiveProject(properties); + }; + + /** + * Encodes the specified InactiveProject message. Does not implicitly {@link flyteidl.admin.InactiveProject.verify|verify} messages. + * @function encode + * @memberof flyteidl.admin.InactiveProject + * @static + * @param {flyteidl.admin.IInactiveProject} message InactiveProject message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InactiveProject.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && message.hasOwnProperty("id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.org != null && message.hasOwnProperty("org")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.org); + return writer; + }; + + /** + * Decodes an InactiveProject message from the specified reader or buffer. + * @function decode + * @memberof flyteidl.admin.InactiveProject + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {flyteidl.admin.InactiveProject} InactiveProject + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InactiveProject.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.flyteidl.admin.InactiveProject(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.org = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Verifies an InactiveProject message. + * @function verify + * @memberof flyteidl.admin.InactiveProject + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + InactiveProject.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.org != null && message.hasOwnProperty("org")) + if (!$util.isString(message.org)) + return "org: string expected"; + return null; + }; + + return InactiveProject; + })(); + admin.ProjectAttributes = (function() { /** diff --git a/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.py b/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.py index 885ef84716..c04fdb67e1 100644 --- a/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.py +++ b/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.py @@ -14,7 +14,7 @@ from flyteidl.admin import common_pb2 as flyteidl_dot_admin_dot_common__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1c\x66lyteidl/admin/project.proto\x12\x0e\x66lyteidl.admin\x1a\x1b\x66lyteidl/admin/common.proto\"\x12\n\x10GetDomainRequest\",\n\x06\x44omain\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\"F\n\x12GetDomainsResponse\x12\x30\n\x07\x64omains\x18\x01 \x03(\x0b\x32\x16.flyteidl.admin.DomainR\x07\x64omains\"\xd4\x02\n\x07Project\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\x12\x30\n\x07\x64omains\x18\x03 \x03(\x0b\x32\x16.flyteidl.admin.DomainR\x07\x64omains\x12 \n\x0b\x64\x65scription\x18\x04 \x01(\tR\x0b\x64\x65scription\x12.\n\x06labels\x18\x05 \x01(\x0b\x32\x16.flyteidl.admin.LabelsR\x06labels\x12:\n\x05state\x18\x06 \x01(\x0e\x32$.flyteidl.admin.Project.ProjectStateR\x05state\x12\x10\n\x03org\x18\x07 \x01(\tR\x03org\"S\n\x0cProjectState\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\x0c\n\x08\x41RCHIVED\x10\x01\x12\x14\n\x10SYSTEM_GENERATED\x10\x02\x12\x13\n\x0fSYSTEM_ARCHIVED\x10\x03\"U\n\x08Projects\x12\x33\n\x08projects\x18\x01 \x03(\x0b\x32\x17.flyteidl.admin.ProjectR\x08projects\x12\x14\n\x05token\x18\x02 \x01(\tR\x05token\"\x9b\x01\n\x12ProjectListRequest\x12\x14\n\x05limit\x18\x01 \x01(\rR\x05limit\x12\x14\n\x05token\x18\x02 \x01(\tR\x05token\x12\x18\n\x07\x66ilters\x18\x03 \x01(\tR\x07\x66ilters\x12-\n\x07sort_by\x18\x04 \x01(\x0b\x32\x14.flyteidl.admin.SortR\x06sortBy\x12\x10\n\x03org\x18\x05 \x01(\tR\x03org\"K\n\x16ProjectRegisterRequest\x12\x31\n\x07project\x18\x01 \x01(\x0b\x32\x17.flyteidl.admin.ProjectR\x07project\"\x19\n\x17ProjectRegisterResponse\"\x17\n\x15ProjectUpdateResponse\"5\n\x11ProjectGetRequest\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x10\n\x03org\x18\x02 \x01(\tR\x03orgB\xb8\x01\n\x12\x63om.flyteidl.adminB\x0cProjectProtoP\x01Z;github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin\xa2\x02\x03\x46\x41X\xaa\x02\x0e\x46lyteidl.Admin\xca\x02\x0e\x46lyteidl\\Admin\xe2\x02\x1a\x46lyteidl\\Admin\\GPBMetadata\xea\x02\x0f\x46lyteidl::Adminb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1c\x66lyteidl/admin/project.proto\x12\x0e\x66lyteidl.admin\x1a\x1b\x66lyteidl/admin/common.proto\"\x12\n\x10GetDomainRequest\",\n\x06\x44omain\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\"F\n\x12GetDomainsResponse\x12\x30\n\x07\x64omains\x18\x01 \x03(\x0b\x32\x16.flyteidl.admin.DomainR\x07\x64omains\"\xd4\x02\n\x07Project\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\x12\x30\n\x07\x64omains\x18\x03 \x03(\x0b\x32\x16.flyteidl.admin.DomainR\x07\x64omains\x12 \n\x0b\x64\x65scription\x18\x04 \x01(\tR\x0b\x64\x65scription\x12.\n\x06labels\x18\x05 \x01(\x0b\x32\x16.flyteidl.admin.LabelsR\x06labels\x12:\n\x05state\x18\x06 \x01(\x0e\x32$.flyteidl.admin.Project.ProjectStateR\x05state\x12\x10\n\x03org\x18\x07 \x01(\tR\x03org\"S\n\x0cProjectState\x12\n\n\x06\x41\x43TIVE\x10\x00\x12\x0c\n\x08\x41RCHIVED\x10\x01\x12\x14\n\x10SYSTEM_GENERATED\x10\x02\x12\x13\n\x0fSYSTEM_ARCHIVED\x10\x03\"U\n\x08Projects\x12\x33\n\x08projects\x18\x01 \x03(\x0b\x32\x17.flyteidl.admin.ProjectR\x08projects\x12\x14\n\x05token\x18\x02 \x01(\tR\x05token\"\x9b\x01\n\x12ProjectListRequest\x12\x14\n\x05limit\x18\x01 \x01(\rR\x05limit\x12\x14\n\x05token\x18\x02 \x01(\tR\x05token\x12\x18\n\x07\x66ilters\x18\x03 \x01(\tR\x07\x66ilters\x12-\n\x07sort_by\x18\x04 \x01(\x0b\x32\x14.flyteidl.admin.SortR\x06sortBy\x12\x10\n\x03org\x18\x05 \x01(\tR\x03org\"K\n\x16ProjectRegisterRequest\x12\x31\n\x07project\x18\x01 \x01(\x0b\x32\x17.flyteidl.admin.ProjectR\x07project\"\x19\n\x17ProjectRegisterResponse\"\x17\n\x15ProjectUpdateResponse\"5\n\x11ProjectGetRequest\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x10\n\x03org\x18\x02 \x01(\tR\x03org\"3\n\x0fInactiveProject\x12\x0e\n\x02id\x18\x01 \x01(\tR\x02id\x12\x10\n\x03org\x18\x02 \x01(\tR\x03orgB\xb8\x01\n\x12\x63om.flyteidl.adminB\x0cProjectProtoP\x01Z;github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin\xa2\x02\x03\x46\x41X\xaa\x02\x0e\x46lyteidl.Admin\xca\x02\x0e\x46lyteidl\\Admin\xe2\x02\x1a\x46lyteidl\\Admin\\GPBMetadata\xea\x02\x0f\x46lyteidl::Adminb\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -45,4 +45,6 @@ _globals['_PROJECTUPDATERESPONSE']._serialized_end=930 _globals['_PROJECTGETREQUEST']._serialized_start=932 _globals['_PROJECTGETREQUEST']._serialized_end=985 + _globals['_INACTIVEPROJECT']._serialized_start=987 + _globals['_INACTIVEPROJECT']._serialized_end=1038 # @@protoc_insertion_point(module_scope) diff --git a/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.pyi b/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.pyi index 12750a8959..c775c5aac8 100644 --- a/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.pyi +++ b/flyteidl/gen/pb_python/flyteidl/admin/project_pb2.pyi @@ -96,3 +96,11 @@ class ProjectGetRequest(_message.Message): id: str org: str def __init__(self, id: _Optional[str] = ..., org: _Optional[str] = ...) -> None: ... + +class InactiveProject(_message.Message): + __slots__ = ["id", "org"] + ID_FIELD_NUMBER: _ClassVar[int] + ORG_FIELD_NUMBER: _ClassVar[int] + id: str + org: str + def __init__(self, id: _Optional[str] = ..., org: _Optional[str] = ...) -> None: ... diff --git a/flyteidl/gen/pb_rust/flyteidl.admin.rs b/flyteidl/gen/pb_rust/flyteidl.admin.rs index dcbf3b5df7..ca3270264b 100644 --- a/flyteidl/gen/pb_rust/flyteidl.admin.rs +++ b/flyteidl/gen/pb_rust/flyteidl.admin.rs @@ -2615,6 +2615,18 @@ pub struct ProjectGetRequest { #[prost(string, tag="2")] pub org: ::prost::alloc::string::String, } +/// Error returned for inactive projects +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct InactiveProject { + /// Indicates a unique project. + /// +required + #[prost(string, tag="1")] + pub id: ::prost::alloc::string::String, + /// Optional, org key applied to the resource. + #[prost(string, tag="2")] + pub org: ::prost::alloc::string::String, +} /// Defines a set of custom matching attributes at the project level. /// For more info on matchable attributes, see :ref:`ref_flyteidl.admin.MatchableAttributesConfiguration` #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/flyteidl/protos/flyteidl/admin/project.proto b/flyteidl/protos/flyteidl/admin/project.proto index bbaccd70ff..8b994b7267 100644 --- a/flyteidl/protos/flyteidl/admin/project.proto +++ b/flyteidl/protos/flyteidl/admin/project.proto @@ -118,3 +118,15 @@ message ProjectGetRequest { // Optional, org key applied to the resource. string org = 2; } + + +// Error returned for inactive projects +message InactiveProject { + // Indicates a unique project. + // +required + string id = 1; + + // Optional, org key applied to the resource. + string org = 2; +} +