Skip to content

Commit

Permalink
clear lp cache on workflow node finalize
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Dittamo <[email protected]>
  • Loading branch information
pvditt committed Sep 18, 2024
1 parent a2259ce commit e3a0fe4
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 3 deletions.
10 changes: 7 additions & 3 deletions flytepropeller/pkg/controller/nodes/subworkflow/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func newMetrics(scope promutils.Scope) metrics {
}

func (w *workflowNodeHandler) FinalizeRequired() bool {
return false
return true

Check warning on line 36 in flytepropeller/pkg/controller/nodes/subworkflow/handler.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/handler.go#L36

Added line #L36 was not covered by tests
}

func (w *workflowNodeHandler) Setup(_ context.Context, _ interfaces.SetupContext) error {
Expand Down Expand Up @@ -120,8 +120,12 @@ func (w *workflowNodeHandler) Abort(ctx context.Context, nCtx interfaces.NodeExe
return nil
}

func (w *workflowNodeHandler) Finalize(ctx context.Context, _ interfaces.NodeExecutionContext) error {
logger.Warnf(ctx, "Subworkflow finalize invoked. Nothing to be done")
func (w *workflowNodeHandler) Finalize(ctx context.Context, nCtx interfaces.NodeExecutionContext) error {
logger.Warnf(ctx, "Subworkflow finalize invoked. Clearing up the cache")
wfNode := nCtx.Node().GetWorkflowNode()
if wfNode.GetLaunchPlanRefID() != nil {
return w.lpHandler.Finalize(ctx, nCtx)

Check warning on line 127 in flytepropeller/pkg/controller/nodes/subworkflow/handler.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/handler.go#L123-L127

Added lines #L123 - L127 were not covered by tests
}
return nil
}

Expand Down
17 changes: 17 additions & 0 deletions flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,20 @@ func (l *launchPlanHandler) HandleAbort(ctx context.Context, nCtx interfaces.Nod
}
return l.launchPlan.Kill(ctx, childID, fmt.Sprintf("cascading abort as parent execution id [%s] aborted, reason [%s]", nCtx.ExecutionContext().GetName(), reason))
}

func (l *launchPlanHandler) Finalize(ctx context.Context, nCtx interfaces.NodeExecutionContext) error {
parentNodeExecutionID, err := getParentNodeExecutionID(nCtx)
if err != nil {
return err

Check warning on line 236 in flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go#L233-L236

Added lines #L233 - L236 were not covered by tests
}
childID, err := GetChildWorkflowExecutionIDForExecution(
parentNodeExecutionID,
nCtx,
)
if err != nil {

Check warning on line 242 in flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go#L238-L242

Added lines #L238 - L242 were not covered by tests
// THIS SHOULD NEVER HAPPEN
return err

Check warning on line 244 in flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go#L244

Added line #L244 was not covered by tests
}

return l.launchPlan.Finalize(ctx, childID)

Check warning on line 247 in flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/launchplan.go#L247

Added line #L247 was not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ func (a *adminLaunchPlanExecutor) Initialize(ctx context.Context) error {
return a.cache.Start(ctx)
}

func (a *adminLaunchPlanExecutor) Finalize(ctx context.Context, executionID *core.WorkflowExecutionIdentifier) error {
return a.cache.DeleteDelayed(executionID.String())

Check warning on line 228 in flytepropeller/pkg/controller/nodes/subworkflow/launchplan/admin.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/launchplan/admin.go#L227-L228

Added lines #L227 - L228 were not covered by tests
}

func (a *adminLaunchPlanExecutor) syncItem(ctx context.Context, batch cache.Batch) (
resp []cache.ItemSyncResponse, err error) {
resp = make([]cache.ItemSyncResponse, 0, len(batch))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type Executor interface {

// Initialize initializes Executor.
Initialize(ctx context.Context) error

// Finalize clears the cache of the LaunchPlan execution
Finalize(ctx context.Context, executionID *core.WorkflowExecutionIdentifier) error
}

type Reader interface {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3a0fe4

Please sign in to comment.