Skip to content

Add ARCHIVED state to LaunchPlanState enum#7056

Open
blaketastic2 wants to merge 4 commits intoflyteorg:masterfrom
blaketastic2:blake/launchplan-archived-state
Open

Add ARCHIVED state to LaunchPlanState enum#7056
blaketastic2 wants to merge 4 commits intoflyteorg:masterfrom
blaketastic2:blake/launchplan-archived-state

Conversation

@blaketastic2
Copy link
Copy Markdown

Tracking issue

N/A — this addresses a common operational pain point with no existing tracking issue.

Why are the changes needed?

Every pyflyte register creates new launch plan versions, and nothing cleans up old ones. Over time this leads to heavier list queries, more data to page through, and increased memory pressure on Admin.

Today the only cleanup mechanism is UpdateLaunchPlan to set state INACTIVE, but INACTIVE has meaning in the active/inactive schedule lifecycle — conflating "old cruft" with "intentionally deactivated" makes filtering unreliable. Users who discover downstream launch plans via ListLaunchPlans (e.g. filtering on workflow.short_description) get back all versions across all deploys when they only care about the latest.

Adding ARCHIVED (value 2) gives operators a distinct state they can set on old versions and filter out (ne(state,2)), enabling a scheduled cleanup pattern: keep the most recent N versions per named entity, archive the rest, never touch the active one.

What changes were proposed in this pull request?

flyteidl (proto + generated code):

  • Add ARCHIVED = 2 to the LaunchPlanState enum in launch_plan.proto
  • Regenerate bindings for Go, Python, Rust, TypeScript, and JavaScript
  • Update both swagger JSON files (gateway + client assets)

flyteadmin:

  • Add archiveLaunchPlan method to LaunchPlanManager — same behavior as disableLaunchPlan (disables any active schedule, updates the DB) but sets state to ARCHIVED instead of INACTIVE
  • Add case admin.LaunchPlanState_ARCHIVED to the UpdateLaunchPlan switch

flytectl:

  • Repurpose the --archive flag to set LaunchPlanState_ARCHIVED instead of mapping to INACTIVE. This flag was previously deprecated in [Feature]Remove namespace from all non kustomize configuration #449 as an alias for --deactivate because "archive" was misleading when no ARCHIVED state existed. Now that the state exists, --archive does what the name implies.
  • Update mutual exclusion logic to handle three flags (--activate, --deactivate, --archive)
  • Remove the now-unused deprecatedCommandWarning function
  • Update help text and flag descriptions

Note on --archive behavioral change: Prior to this PR, --archive was a deprecated alias for --deactivate (set state to INACTIVE/0). After this PR, --archive sets state to ARCHIVED/2. Anyone relying on the deprecated --archive flag to deactivate launch plans should switch to --deactivate.

How was this patch tested?

  • Updated TestLaunchPlanCanBeArchived in flytectl to verify --archive now sets ARCHIVED state
  • All existing flyteadmin manager impl tests pass (launch plan manager, transformers, utils, validation)
  • All existing flytectl update tests pass
  • Both flyteadmin and flytectl compile cleanly

Labels

  • added: New ARCHIVED launch plan state

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Launch plan versions accumulate over time as each pyflyte register
creates new versions. This adds an ARCHIVED state (value=2) so old
versions can be marked and filtered out of list queries (e.g.
ne(state,2)) without conflating them with INACTIVE, which has meaning
in the active/inactive schedule lifecycle.

Archiving a launch plan disables any active schedule (same as
deactivate) but preserves the ability to launch executions from it.

Changes:
- flyteidl: Add ARCHIVED=2 to LaunchPlanState enum, regenerate bindings
- flyteadmin: Add archiveLaunchPlan handler in UpdateLaunchPlan switch
- flytectl: Repurpose --archive flag to set ARCHIVED state (was a
  deprecated alias for --deactivate)

Signed-off-by: Blake Naccarato <blake.naccarato@gmail.com>
Signed-off-by: Blake <blaketastic2@gmail.com>
Remove "hidden from list queries by default" language from proto
comments and CLI help. Archived launch plans are not automatically
excluded from list results — callers must add a ne(state,2) filter.

Signed-off-by: Blake Naccarato <blake.naccarato@gmail.com>
Signed-off-by: Blake <blaketastic2@gmail.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 73.91304% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.95%. Comparing base (f3ab1b7) to head (97b152f).

Files with missing lines Patch % Lines
flyteadmin/pkg/manager/impl/launch_plan_manager.go 65.71% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7056      +/-   ##
==========================================
- Coverage   56.95%   56.95%   -0.01%     
==========================================
  Files         931      931              
  Lines       58188    58225      +37     
==========================================
+ Hits        33141    33160      +19     
- Misses      22005    22019      +14     
- Partials     3042     3046       +4     
Flag Coverage Δ
unittests-datacatalog 53.51% <ø> (ø)
unittests-flyteadmin 53.13% <65.71%> (-0.01%) ⬇️
unittests-flytecopilot 43.06% <ø> (ø)
unittests-flytectl 64.03% <100.00%> (+0.01%) ⬆️
unittests-flyteidl 75.71% <ø> (ø)
unittests-flyteplugins 60.15% <ø> (ø)
unittests-flytepropeller 53.65% <ø> (ø)
unittests-flytestdlib 63.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add case 2 (ARCHIVED) to LaunchPlanClosure and
  LaunchPlanUpdateRequest verify functions in flyteidl.js
- Reword Archive pflag description to avoid comma that causes
  double-space artifact in pflags code generation

Signed-off-by: Blake <blaketastic2@gmail.com>
@blaketastic2 blaketastic2 force-pushed the blake/launchplan-archived-state branch from 63d7c37 to 9549a4c Compare March 20, 2026 14:19
setCount++
}
if activate == deactivate && deactivate {
if setCount > 1 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we do deactivate and archive? It shouldn't raise an error

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are three distinct states in the enum (ACTIVE, INACTIVE, ARCHIVED), and each flag maps to exactly one LaunchPlanState value. If we allowed --deactivate --archive together it would be ambiguous — we'd have to silently pick one, which is more confusing than just asking the user to specify a single flag.

Archive already implies the launch plan won't be scheduled (the server-side behavior disables any active schedule), so there's no need to also pass --deactivate. If the intent is to archive, --archive alone is sufficient.

Cover the archive path with tests for the happy path (with and without
a schedule) and database error propagation.

Signed-off-by: Blake <blaketastic2@gmail.com>
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.

2 participants