flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[flyteadmin] add delete execution phase api

Open taieeuu opened this issue 10 months ago • 9 comments

Tracking issue

Why are the changes needed?

This API provides users with a method to batch delete unnecessary execution records. It accepts the parameters project, domain, and phase, enabling the deletion of execution records that are no longer needed.

What changes were proposed in this pull request?

In the protobuf definition, define an RPC method called DeleteExecutionPhase that accepts project, domain, and phase parameters and uses the DELETE method for the deletion request. In both execution_manager and execution_repo, implement deletion logic that includes input validation and error handling. Unit tests are provided to ensure correct functionality under both successful and failure scenarios.

How was this patch tested?

"All tests passed successfully, and I have also added unit tests."

And you can also test with postman ... tools .

image

Labels

Please add one or more of the following labels to categorize your PR:

  • added: For new features.
  • changed: For changes in existing functionality.
  • deprecated: For soon-to-be-removed features.
  • removed: For features being removed.
  • fixed: For any bug fixed.
  • security: In case of vulnerabilities

This is important to improve the readability of release notes.

Setup process

Screenshots

Check all the applicable boxes

  • [ ] I updated the documentation accordingly.
  • [x] All new and existing tests passed.
  • [x] All commits are signed-off.

Related PRs

Docs link

Summary by Bito

This PR implements a new API endpoint for batch deleting execution phases in Flyte, introducing protobuf message types with implementations in Go, TypeScript, and Rust. It updates execution manager and repository layers, improves encapsulation by replacing direct field access with getter methods, and switches from GET to DELETE methods with proper validation and error handling.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 5

taieeuu avatar Feb 22 '25 05:02 taieeuu

Code Review Agent Run #50b8fe

Actionable Suggestions - 8
  • flyteidl/gen/pb-go/flyteidl/admin/execution.pb.go - 1
  • flyteadmin/pkg/rpc/adminservice/execution.go - 1
    • Consider using specific metric for DeleteExecutionPhase · Line 160-161
  • flyteadmin/pkg/repositories/gormimpl/execution_repo.go - 1
    • Consider adding validation for execution phase · Line 175-179
  • flyteidl/clients/go/admin/mocks/AdminServiceClient.go - 1
  • flyteidl/protos/flyteidl/service/admin.proto - 1
  • flyteadmin/pkg/manager/impl/execution_manager.go - 1
  • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.pb.gw.go - 1
  • flyteidl/gen/pb-go/flyteidl/service/admin_grpc.pb.go - 1
Additional Suggestions - 5
  • flyteidl/gen/pb_python/flyteidl/service/admin_pb2_grpc.py - 1
  • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.pb.gw.go - 1
  • flyteidl/gen/pb-go/flyteidl/service/admin_grpc.pb.go - 2
    • Consider adding matching interface method definition · Line 79-79
    • Consider adding input parameter validation · Line 717-724
  • flyteidl/gen/pb-js/flyteidl.d.ts - 1
Review Details
  • Files reviewed - 25 · Commit Range: 48c547a..48c547a
    • flyteadmin/pkg/manager/impl/execution_manager.go
    • flyteadmin/pkg/manager/interfaces/execution.go
    • flyteadmin/pkg/repositories/gormimpl/execution_repo.go
    • flyteadmin/pkg/repositories/interfaces/execution_repo.go
    • flyteadmin/pkg/rpc/adminservice/execution.go
    • flyteidl/clients/go/admin/mocks/AdminServiceClient.go
    • flyteidl/clients/go/admin/mocks/AdminServiceServer.go
    • flyteidl/gen/pb-es/flyteidl/admin/execution_pb.ts
    • flyteidl/gen/pb-es/flyteidl/service/admin_connect.ts
    • flyteidl/gen/pb-go/flyteidl/admin/execution.pb.go
    • flyteidl/gen/pb-go/flyteidl/service/admin.pb.go
    • flyteidl/gen/pb-go/flyteidl/service/admin_grpc.pb.go
    • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.pb.gw.go
    • flyteidl/gen/pb-js/flyteidl.d.ts
    • flyteidl/gen/pb-js/flyteidl.js
    • flyteidl/gen/pb_python/flyteidl/admin/execution_pb2.py
    • flyteidl/gen/pb_python/flyteidl/admin/execution_pb2.pyi
    • flyteidl/gen/pb_python/flyteidl/service/admin_pb2.py
    • flyteidl/gen/pb_python/flyteidl/service/admin_pb2_grpc.py
    • flyteidl/gen/pb_rust/flyteidl.admin.rs
    • flyteidl/gen/pb_rust/flyteidl.service.tonic.rs
    • flyteidl/protos/flyteidl/admin/execution.proto
    • flyteidl/protos/flyteidl/service/admin.proto
    • go.mod
    • go.sum
  • Files skipped - 2
    • flyteidl/clients/go/assets/admin.swagger.json - Reason: Filter setting
    • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.swagger.json - Reason: Filter setting
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Feb 22 '25 05:02 flyte-bot

Codecov Report

:x: Patch coverage is 38.00000% with 31 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 58.47%. Comparing base (6e5aca7) to head (63aad12). :warning: Report is 179 commits behind head on master.

Files with missing lines Patch % Lines
...eadmin/pkg/repositories/gormimpl/execution_repo.go 0.00% 11 Missing :warning:
flyteadmin/pkg/rpc/adminservice/execution.go 0.00% 11 Missing :warning:
flyteadmin/pkg/manager/impl/execution_manager.go 67.85% 6 Missing and 3 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6267      +/-   ##
==========================================
- Coverage   58.48%   58.47%   -0.01%     
==========================================
  Files         937      937              
  Lines       71088    71138      +50     
==========================================
+ Hits        41577    41601      +24     
- Misses      26359    26382      +23     
- Partials     3152     3155       +3     
Flag Coverage Δ
unittests-datacatalog 59.06% <ø> (ø)
unittests-flyteadmin 56.25% <38.00%> (-0.02%) :arrow_down:
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 64.70% <ø> (ø)
unittests-flyteidl 76.12% <ø> (ø)
unittests-flyteplugins 61.00% <ø> (ø)
unittests-flytepropeller 54.79% <ø> (ø)
unittests-flytestdlib 64.02% <ø> (-0.02%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Feb 22 '25 05:02 codecov[bot]

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
New Feature - API Expansion and Integration

admin.pb.go - Updated RPC method descriptors to incorporate DeleteExecutionPhase with revised arguments and field mappings.

admin_grpc.pb.go - Introduced DeleteExecutionPhase RPC implementation including client stub, server handler, and interceptor wrappers.

admin.pb.gw.go - Added new DELETE endpoint and URL routing for DeleteExecutionPhase, adjusting HTTP handler logic accordingly.

flyteidl.d.ts - Appended new TypeScript definitions for ExecutionPhaseDeleteRequest and ExecutionPhaseDeleteResponse.

execution_manager.go - Adds DeleteExecutionPhase function with input validations and database deletion call.

execution.go - Introduces DeleteExecutionPhase interface definition to standardize API exposure.

execution_repo.go - Implements a Delete method that removes an execution based on project, domain, and phase criteria.

common.go - Updates import and adds ExecutionPhaseDeleteInput struct for encapsulating deletion parameters.

execution_repo.go - Adds Delete method signature to the repository interface.

execution.go - Implements the DeleteExecutionPhase RPC endpoint with adequate error handling and metric tracking.

AdminServiceClient.go - Introduces mock support for DeleteExecutionPhase in the admin service client.

AdminServiceServer.go - Provides server-side mocks to simulate DeleteExecutionPhase responses.

execution_pb.ts - Generates new protobuf message types for ExecutionPhaseDeleteRequest and ExecutionPhaseDeleteResponse.

admin_connect.ts - Updates service definition to include the new DeleteExecutionPhase RPC mapping.

flyteidl.js - Introduced new JavaScript implementations for ExecutionPhaseDeleteRequest/Response and added DeleteExecutionPhase method definitions in the AdminService.

execution_pb2.py - Updated protobuf descriptors with new serialized positions and added message definitions for execution phase deletion.

execution_pb2.pyi - Added Python type definitions for ExecutionPhaseDeleteRequest and ExecutionPhaseDeleteResponse to support the deletion API.

admin_pb2.py - Refactored DESCRIPTOR and updated serialized options to support DeleteExecutionPhase RPC.

admin_pb2_grpc.py - Integrated DeleteExecutionPhase method into gRPC stubs and service handlers.

flyteidl.admin.rs - Added protobuf message definitions for execution phase deletion in Rust.

flyteidl.service.tonic.rs - Implemented client and server support for DeleteExecutionPhase RPC in Rust.

execution.proto - Introduced new message definitions for ExecutionPhaseDeleteRequest and ExecutionPhaseDeleteResponse.

admin.proto - Added DeleteExecutionPhase RPC endpoint with HTTP DELETE mapping.

Testing - Comprehensive Test Coverage

execution_manager_test.go - Adds unit tests covering both successful and error scenarios for the DeleteExecutionPhase API.

execution_interface.go - Implements mock functions for DeleteExecutionPhase to facilitate isolated testing.

execution_repo.go - Introduces a mock delete callback to simulate repository deletion behavior during tests.

Other Improvements - Dependency Cleanup

go.mod - Removed unused/indirect dependencies improving module hygiene.

go.sum - Removed outdated dependency checksum entries aligning with updated dependency ecosystem.

flyte-bot avatar Feb 22 '25 06:02 flyte-bot

Code Review Agent Run #26e38f

Actionable Suggestions - 6
  • flyteidl/gen/pb-es/flyteidl/admin/execution_pb.ts - 1
  • flyteadmin/pkg/manager/impl/execution_manager.go - 2
  • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.pb.gw.go - 1
  • flyteidl/gen/pb_rust/flyteidl.admin.rs - 1
  • flyteadmin/pkg/repositories/interfaces/common.go - 1
    • Consider adding field validation checks · Line 49-52
Additional Suggestions - 1
  • flyteidl/gen/pb-js/flyteidl.d.ts - 1
Review Details
  • Files reviewed - 16 · Commit Range: 48c547a..739b16c
    • flyteadmin/pkg/manager/impl/execution_manager.go
    • flyteadmin/pkg/repositories/gormimpl/execution_repo.go
    • flyteadmin/pkg/repositories/interfaces/common.go
    • flyteadmin/pkg/repositories/interfaces/execution_repo.go
    • flyteidl/gen/pb-es/flyteidl/admin/execution_pb.ts
    • flyteidl/gen/pb-go/flyteidl/admin/execution.pb.go
    • flyteidl/gen/pb-go/flyteidl/service/admin.pb.go
    • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.pb.gw.go
    • flyteidl/gen/pb-js/flyteidl.d.ts
    • flyteidl/gen/pb-js/flyteidl.js
    • flyteidl/gen/pb_python/flyteidl/admin/execution_pb2.py
    • flyteidl/gen/pb_python/flyteidl/admin/execution_pb2.pyi
    • flyteidl/gen/pb_python/flyteidl/service/admin_pb2.py
    • flyteidl/gen/pb_rust/flyteidl.admin.rs
    • flyteidl/protos/flyteidl/admin/execution.proto
    • flyteidl/protos/flyteidl/service/admin.proto
  • Files skipped - 2
    • flyteidl/clients/go/assets/admin.swagger.json - Reason: Filter setting
    • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.swagger.json - Reason: Filter setting
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Feb 28 '25 09:02 flyte-bot

Code Review Agent Run #66451d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 739b16c..c452608
    • flyteidl/gen/pb-go/flyteidl/service/admin.pb.go
    • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.pb.gw.go
    • flyteidl/gen/pb_python/flyteidl/service/admin_pb2.py
    • flyteidl/protos/flyteidl/service/admin.proto
  • Files skipped - 2
    • flyteidl/clients/go/assets/admin.swagger.json - Reason: Filter setting
    • flyteidl/gen/pb-go/gateway/flyteidl/service/admin.swagger.json - Reason: Filter setting
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Mar 01 '25 16:03 flyte-bot

Code Review Agent Run #de2c1d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 6 · Commit Range: c452608..6fccc9b
    • flyteadmin/pkg/manager/impl/execution_manager.go
    • flyteadmin/pkg/manager/impl/execution_manager_test.go
    • flyteadmin/pkg/manager/mocks/execution_interface.go
    • flyteadmin/pkg/repositories/gormimpl/execution_repo.go
    • flyteadmin/pkg/repositories/interfaces/common.go
    • flyteadmin/pkg/repositories/mocks/execution_repo.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Mar 02 '25 17:03 flyte-bot

Code Review Agent Run Status

  • Limitations and other issues:  Failure - Bito Code Review Agent didn't review this pull request automatically because it exceeded the size limit. No action is needed if you didn't intend for the agent to review it. Otherwise, you can initiate the review by typing /review in a comment below.

flyte-bot avatar Mar 05 '25 16:03 flyte-bot

Code Review Agent Run Status

  • Limitations and other issues:  Failure - Bito Code Review Agent didn't review this pull request automatically because it exceeded the size limit. No action is needed if you didn't intend for the agent to review it. Otherwise, you can initiate the review by typing /review in a comment below.

flyte-bot avatar Mar 06 '25 16:03 flyte-bot

before we proceed with deleting items from the db can we maybe write up an issue to address

  1. what we're trying to solve (mass terminate executions)
  2. why the current api is insufficient
  3. and if the current api works, how we can use the remote client in flytekit SDK to allow us to batch terminate executions and accepts a list of input parameters (created at window, current phase filters, etc)

I think as it stands now this PR could orphan executions unintentionally if we're not careful or make it really easy to delete from the DB which is a departure from how flyteadmin currently records entities. Flyteadmin allows us to archive or tombstone various entities but delete is a scarier tool

katrogan avatar Mar 11 '25 14:03 katrogan