-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] [Feature] add batch delete execution_phase api #6267
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: taieeuu <[email protected]>
Code Review Agent Run #50b8feActionable Suggestions - 8
Additional Suggestions - 5
Review Details
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6267 +/- ##
==========================================
- Coverage 36.86% 33.28% -3.59%
==========================================
Files 1318 1020 -298
Lines 134767 109390 -25377
==========================================
- Hits 49684 36410 -13274
+ Misses 80753 69754 -10999
+ Partials 4330 3226 -1104
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Changelist by BitoThis pull request implements the following key changes.
|
sizeCache protoimpl.SizeCache | ||
unknownFields protoimpl.UnknownFields | ||
|
||
ExecutionPhase string `protobuf:"bytes,1,opt,name=execution_phase,json=executionPhase,proto3" json:"execution_phase,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding validation for the execution_phase
field in ExecutionPhaseDeleteRequest
. The field appears to be used for deleting execution phases but lacks input validation to ensure valid phase values are provided. This could potentially lead to runtime errors if invalid phases are specified.
Code suggestion
Check the AI-generated fix before applying
ExecutionPhase string `protobuf:"bytes,1,opt,name=execution_phase,json=executionPhase,proto3" json:"execution_phase,omitempty"` | |
// +required The phase of execution to be deleted. Must be one of the valid execution phases. | |
ExecutionPhase string `protobuf:"bytes,1,opt,name=execution_phase,json=executionPhase,proto3" json:"execution_phase,omitempty" validate:"required,oneof=QUEUED RUNNING SUCCEEDED FAILED ABORTED"` |
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
m.Metrics.executionEndpointMetrics.terminate.Time(func() { | ||
response, err = m.ExecutionManager.DeleteExecutionPhase(ctx, request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a more specific metric name for DeleteExecutionPhase
. Currently using terminate
metric which seems to be shared with termination functionality. This could lead to misleading metrics.
Code suggestion
Check the AI-generated fix before applying
terminate util.RequestMetrics
+ deletePhase util.RequestMetrics
@@ -160,9 +160,9 @@
- m.Metrics.executionEndpointMetrics.terminate.Time(func() {
- response, err = m.ExecutionManager.DeleteExecutionPhase(ctx, request)
- })
- if err != nil {
- return nil, util.TransformAndRecordError(err, &m.Metrics.executionEndpointMetrics.terminate)
- }
- m.Metrics.executionEndpointMetrics.terminate.Success()
+ m.Metrics.executionEndpointMetrics.deletePhase.Time(func() {
+ response, err = m.ExecutionManager.DeleteExecutionPhase(ctx, request)
+ })
+ if err != nil {
+ return nil, util.TransformAndRecordError(err, &m.Metrics.executionEndpointMetrics.deletePhase)
+ }
+ m.Metrics.executionEndpointMetrics.deletePhase.Success()
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
result := r.db.Delete(&models.Execution{}, "phase = ?", executionPhase) | ||
if result.Error != nil { | ||
return result.Error | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding validation to ensure executionPhase
is not empty and matches valid execution phase values. Also, consider adding error handling for when no records are deleted.
Code suggestion
Check the AI-generated fix before applying
result := r.db.Delete(&models.Execution{}, "phase = ?", executionPhase) | |
if result.Error != nil { | |
return result.Error | |
} | |
return nil | |
if executionPhase == "" { | |
return fmt.Errorf("execution phase cannot be empty") | |
} | |
result := r.db.Delete(&models.Execution{}, "phase = ?", executionPhase) | |
if result.Error != nil { | |
return result.Error | |
} | |
if result.RowsAffected == 0 { | |
return fmt.Errorf("no executions found with phase %s", executionPhase) | |
} | |
return nil |
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
_va := make([]interface{}, len(opts)) | ||
for _i := range opts { | ||
_va[_i] = opts[_i] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding validation for the opts
parameter in the DeleteExecutionPhase
method. Currently, there's no check if opts
is nil before iterating over it.
Code suggestion
Check the AI-generated fix before applying
_va := make([]interface{}, len(opts)) | |
for _i := range opts { | |
_va[_i] = opts[_i] | |
} | |
_va := []interface{}{} | |
if opts != nil { | |
_va = make([]interface{}, len(opts)) | |
for _i := range opts { | |
_va[_i] = opts[_i] | |
} | |
} |
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
get: "/api/v1/delete_execution_phase/{execution_phase}" | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DeleteExecutionPhase
endpoint is using GET
HTTP method for a deletion operation. Consider using DELETE
HTTP method instead to better align with REST conventions and make the API more intuitive.
Code suggestion
Check the AI-generated fix before applying
get: "/api/v1/delete_execution_phase/{execution_phase}" | |
}; | |
delete: "/api/v1/delete_execution_phase/{execution_phase}" | |
}; |
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
|
||
err := m.db.ExecutionRepo().Delete(ctx, executionPhase) | ||
if err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error wrapping with context when returning the database error. This would help with debugging by providing more context about what operation failed. Maybe something like: fmt.Errorf("failed to delete execution phase %s: %w", executionPhase, err)
Code suggestion
Check the AI-generated fix before applying
return nil, err | |
return nil, fmt.Errorf("failed to delete execution phase %s: %w", executionPhase, err) |
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
protoReq.ExecutionPhase, err = runtime.String(val) | ||
if err != nil { | ||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "execution_phase", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding validation for empty string in execution_phase
parameter. The current implementation accepts empty strings which could lead to unintended behavior when deleting execution phases.
Code suggestion
Check the AI-generated fix before applying
protoReq.ExecutionPhase, err = runtime.String(val) | |
if err != nil { | |
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "execution_phase", err) | |
} | |
protoReq.ExecutionPhase, err = runtime.String(val) | |
if err != nil { | |
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "execution_phase", err) | |
} | |
if protoReq.ExecutionPhase == "" { | |
return nil, metadata, status.Errorf(codes.InvalidArgument, "parameter %s cannot be empty", "execution_phase") | |
} |
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
in := new(admin.ExecutionPhaseDeleteRequest) | ||
if err := dec(in); err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error validation in the _AdminService_DeleteExecutionPhase_Handler
function to ensure the input request is not nil before proceeding with the decoding operation.
Code suggestion
Check the AI-generated fix before applying
in := new(admin.ExecutionPhaseDeleteRequest) | |
if err := dec(in); err != nil { | |
return nil, err | |
if srv == nil { | |
return nil, status.Error(codes.InvalidArgument, "server interface is nil") | |
} | |
in := new(admin.ExecutionPhaseDeleteRequest) | |
if err := dec(in); err != nil { | |
return nil, err |
Code Review Run #50b8fe
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Tracking issue
Why are the changes needed?
What changes were proposed in this pull request?
How was this patch tested?
Labels
Please add one or more of the following labels to categorize your PR:
This is important to improve the readability of release notes.
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
This PR introduces a new API endpoint for batch deleting execution phases in Flyte, including new protobuf message types (ExecutionPhaseDeleteRequest/Response) and corresponding implementations across multiple languages. The changes encompass the addition of DeleteExecutionPhase functionality in the execution manager, repository layer modifications, and gRPC service definitions with HTTP gateway handlers. The implementation includes proper error handling, validation, and dependency cleanup.Unit tests added: True
Estimated effort to review (1-5, lower is better): 5