Skip to content

Commit

Permalink
fix(webapi): Ensure cache deletion on abort workflow (#5235)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw authored Apr 22, 2024
1 parent 4ff2707 commit 0ffab4a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions flyteplugins/go/tasks/pluginmachinery/internal/webapi/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,19 @@ func (c CorePlugin) Abort(ctx context.Context, tCtx core.TaskExecutionContext) e
}

func (c CorePlugin) Finalize(ctx context.Context, tCtx core.TaskExecutionContext) error {
cacheItemID := tCtx.TaskExecutionMetadata().GetTaskExecutionID().GetGeneratedName()
err := c.cache.DeleteDelayed(cacheItemID)
if err != nil {
logger.Errorf(ctx, "Failed to delete resource [%v] from cache. Error: %v", cacheItemID, err)
return fmt.Errorf("failed to delete resource [%v] from cache. Error: %v", cacheItemID, err)
}

if len(c.p.GetConfig().ResourceQuotas) == 0 {
// If there are no defined quotas, there is nothing to cleanup.
return nil
}

logger.Infof(ctx, "Attempting to finalize resource [%v].",
tCtx.TaskExecutionMetadata().GetTaskExecutionID().GetGeneratedName())
logger.Infof(ctx, "Attempting to finalize resource [%v].", cacheItemID)

return c.tokenAllocator.releaseToken(ctx, c.p, tCtx, c.metrics)
}
Expand Down

0 comments on commit 0ffab4a

Please sign in to comment.