Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Add UpdateTagfunc
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwudayi committed Sep 12, 2023
1 parent 6f49854 commit 935dd1d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/manager/impl/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,12 +1340,16 @@ func (m *ExecutionManager) UpdateExecution(ctx context.Context, request admin.Ex
logger.Debugf(ctx, "Failed to get execution model for request [%+v] with err: %v", request, err)
return nil, err
}

if err = transformers.UpdateExecutionModelStateChangeDetails(executionModel, request.State, requestedAt,
getUser(ctx)); err != nil {
return nil, err
}

if err = transformers.UpdateExecutionModelTag(executionModel, request.Tags); err != nil {
return nil, err
}

if err := m.db.ExecutionRepo().Update(ctx, *executionModel); err != nil {
return nil, err
}
Expand Down
38 changes: 38 additions & 0 deletions pkg/repositories/transformers/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,44 @@ func UpdateExecutionModelStateChangeDetails(executionModel *models.Execution, st
return nil
}

//Update tag information of existing execution model.
func UpdateExecutionModelTag(executionModel *models.Execution, tagsUpdatedTo []string) error {
//tagUpdatedAt time.Time, tagUpdatedBy string) error {



// First: I need to figure out why is executionclosure here.. Do I need it?
//var closure admin.ExecutionClosure
//err := proto.Unmarshal(executionModel.Closure, &closure)
//if err != nil {
// return errors.NewFlyteAdminErrorf(codes.Internal, "Failed to unmarshal execution closure: %v", err)
//}

// Update the closure with the same
//var tagUpdatedAtProto *timestamppb.Timestamp
// Default use the createdAt timestamp as the state change occurredAt time
//if stateUpdatedAtProto, err = ptypes.TimestampProto(stateUpdatedAt); err != nil {
// return err
//}

// combine tags and tagsUpdatedTo to one []models.AdminTag and then write back to executionModel.Tags
for _, tag := range tagsUpdatedTo {
executionModel.Tags = append(executionModel.Tags, models.AdminTag{Name: tag})
}
//I need to figure out where is tag is wrote?
//closure.StateChangeDetails = &admin.ExecutionStateChangeDetails{
// Tags: tagsUpdatedTo,
// Principal: stateUpdatedBy,
// OccurredAt: stateUpdatedAtProto,
//}
//marshaledClosure, err := proto.Marshal(&closure)
//if err != nil {
// return errors.NewFlyteAdminErrorf(codes.Internal, "Failed to marshal execution closure: %v", err)
//}
//executionModel.Closure = marshaledClosure
return nil
}

// The execution abort metadata is recorded but the phase is not actually updated *until* the abort event is propagated
// by flytepropeller. The metadata is preemptively saved at the time of the abort.
func SetExecutionAborting(execution *models.Execution, cause, principal string) error {
Expand Down

0 comments on commit 935dd1d

Please sign in to comment.