[BUG] v2: run-level overwrite_cache is ignored, cached tasks still hit
Describe the bug
flyte.with_runcontext(overwrite_cache=True).run(...) sets RunSpec.overwrite_cache and RunSpec.cache_config.overwrite_cache, but the v2 backend never reads either. A cached task in such a run still gets a cache hit, and a serialized one still waits on another run's reservation.
Neither field is read anywhere outside gen/ on main (6fc4786d8):
applyRunSpecToTaskAction(actions/k8s/client.go) projects env vars, interruptible, pod template, service account and raw data prefix into theTaskActionSpec, but not the overwrite flag, andTaskActionSpechas no field for it.evaluateCacheBeforeExecution(executor/pkg/controller/taskaction_cache.go) always callsCatalog.Getand, for serializable tasks,GetOrExtendReservation.writeTaskOutputsToCachealways callsCatalog.Put, which keeps an existing entry, although the cache service client already hasUpdate(Putwithoverwrite: true).
Expected behavior
As in v1 propeller (nodes/executor.go, nodes/cache.go): with the overwrite flag on, a cacheable task skips the lookup (CACHE_SKIPPED), skips the serialization reservation, runs, and writes its outputs with Update, replacing the cached entry.
How to reproduce
import flyte
env = flyte.TaskEnvironment("overwrite-repro")
@env.task(cache=flyte.Cache(behavior="override", version_override="1"))
async def now() -> str:
import datetime
return datetime.datetime.now().isoformat()
flyte.init_from_config()
first = flyte.run(now)
first.wait()
second = flyte.with_runcontext(overwrite_cache=True).run(now)
second.wait()
# Expected: second runs and returns a new timestamp. Actual: cache hit, same timestamp.
Proposed fix
TaskActionSpec.OverwriteCache bool, set inapplyRunSpecToTaskActionfromRunSpec.overwrite_cache || RunSpec.cache_config.overwrite_cacheand copied ininheritRunContextFromParentTaskAction, so child actions get it too.- In
taskaction_cache.go, carry it intaskCacheConfig: skip the lookup and the reservation (also inmaintainCacheReservation), and write withCatalog.Updateinstead ofPut.
Environment
Flyte v2.0.55 (self-hosted), flyte SDK 2.13.4.
The documented behavior matches your expected result: overwrite_cache=True should re-execute tasks and replace cached results. The provided sources don’t verify whether the v2 backend currently honors this flag or confirm the proposed code changes. Run context
Would you like more detail?
Sources:
This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.
Mention @herald to ask follow-up questions. See runllm.com for more!