Skip to content

feat(executor): support immediate GC cleanup when MaxTTL <= 0#7052

Open
mvanhorn wants to merge 1 commit intoflyteorg:v2from
mvanhorn:osc/7008-gc-maxttl-immediate-cleanup
Open

feat(executor): support immediate GC cleanup when MaxTTL <= 0#7052
mvanhorn wants to merge 1 commit intoflyteorg:v2from
mvanhorn:osc/7008-gc-maxttl-immediate-cleanup

Conversation

@mvanhorn
Copy link

@mvanhorn mvanhorn commented Mar 19, 2026

Tracking issue

Closes #7008

Why are the changes needed?

The TaskAction garbage collector (added in #6994) currently rejects MaxTTL <= 0 with a validation error at startup (executor/setup.go:125). Operators who want aggressive cleanup of completed TaskActions have no way to express "delete immediately on each GC cycle."

The issue proposes treating MaxTTL <= 0 as "immediate deletion" - a natural extension of the existing TTL behavior where smaller values mean faster cleanup.

What changes were proposed in this pull request?

  1. Removed the MaxTTL <= 0 validation error in executor/setup.go. GC now starts with any MaxTTL value when interval > 0.

  2. Added immediate-deletion logic in executor/pkg/controller/garbage_collector.go. When maxTTL <= 0, the collect() function uses a far-future cutoff (9999-12-31.23-59) so all terminal TaskActions are eligible for deletion regardless of their completed time. The existing label-based string comparison (completedTime < cutoff) works unchanged since the far-future value is lexicographically greater than any real timestamp.

  3. Updated config documentation in executor/pkg/config/config.go to note the <= 0 behavior in the pflag help text.

MaxTTL value Behavior
> 0 Delete terminal TaskActions older than MaxTTL (unchanged)
<= 0 Delete all terminal TaskActions on each GC cycle

Existing configurations with positive MaxTTL are not affected.

How was this patch tested?

Added two Ginkgo test cases in executor/pkg/controller/garbage_collector_test.go:

  • maxTTL = 0: verifies a recently-completed TaskAction is deleted immediately
  • maxTTL = -1h: verifies negative values behave the same as zero

Ran go fmt ./... and go vet ./... locally - both pass clean.

This contribution was developed with AI assistance (Claude Code + Codex).

Labels

  • added: New GC behavior for MaxTTL <= 0.
  • main

When GC is enabled (interval > 0), treat MaxTTL <= 0 as "delete all
terminal TaskActions immediately on each GC cycle" instead of returning
a validation error. This is useful for environments that want aggressive
cleanup of completed TaskActions without a retention window.

Closes flyteorg#7008

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn mvanhorn force-pushed the osc/7008-gc-maxttl-immediate-cleanup branch from b496db8 to d602c27 Compare March 19, 2026 04:17
@github-actions github-actions bot mentioned this pull request Mar 18, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant