Skip to content
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

Auto refresh cache tweaks #5759

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (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 @@
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.HandleFinalize(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 @@
}
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) HandleFinalize(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.ClearCache(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 @@
return a.cache.Start(ctx)
}

func (a *adminLaunchPlanExecutor) ClearCache(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

// ClearCache clears the cache of the LaunchPlan execution
ClearCache(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.

Loading