Skip to content

fix(metricprovider): implement Terminate for Kayenta provider. Fixes #4815#4825

Open
Goutham-Annem wants to merge 1 commit into
argoproj:masterfrom
Goutham-Annem:fix/4815-kayenta-terminate
Open

fix(metricprovider): implement Terminate for Kayenta provider. Fixes #4815#4825
Goutham-Annem wants to merge 1 commit into
argoproj:masterfrom
Goutham-Annem:fix/4815-kayenta-terminate

Conversation

@Goutham-Annem

Copy link
Copy Markdown

Fixes #4815

Problem

The Kayenta metric provider is asynchronous — Run() POSTs a canary analysis job and returns AnalysisPhaseRunning, then Resume() polls until the job completes. When an AnalysisRun is terminated while a Kayenta measurement is in-flight, the controller calls Terminate() on the provider.

Previously, Terminate() only logged a warning and returned the measurement unchanged (still with AnalysisPhaseRunning). Because the analysis framework only considers the AnalysisRun terminated once all measurements reach a completed phase, the stuck AnalysisPhaseRunning measurement caused a resource leak — the AnalysisRun could never fully terminate.

Fix

Set FinishedAt and transition the measurement phase to AnalysisPhaseSuccessful so the normal termination path in analysis.go can proceed. Since Kayenta does not expose a job cancellation API the in-flight analysis job is left to expire naturally on Kayenta's side; only the controller-side measurement state needs to be resolved.

Also corrects the misleading doc comment on Resume(), which incorrectly stated the method would never be called — in fact Resume() is the polling path for every in-flight Kayenta measurement.

Testing

  • Updated the existing TestRunSuccessfully test to assert that Terminate sets AnalysisPhaseSuccessful and a non-nil FinishedAt.
  • Added a dedicated TestTerminate test covering the standalone Terminate path.
$ go test ./metricproviders/kayenta/...
ok      github.com/argoproj/argo-rollouts/metricproviders/kayenta      0.532s

Checklist

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional with a list of types and scopes found here, (b) states what changed, and (c) suffixes the related issues number.
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change.
  • I have used LLM/AI/Agent tools for this PR but I am responsible for all code of this PR
  • I understand what the code does and WHY/HOW it works in several scenarios
  • I know if my code is just adding new functionality or changing old functionality for existing users

…rgoproj#4815

The Kayenta provider can return AnalysisPhaseRunning from Run(), making it
an asynchronous provider. When an AnalysisRun is terminated while a Kayenta
measurement is in-flight, the controller calls Terminate() on the provider.

Previously, Terminate() returned the measurement unchanged (still with phase
AnalysisPhaseRunning), so the AnalysisRun could never fully terminate —
leaking the in-flight measurement indefinitely.

Fix: set FinishedAt and transition the phase to AnalysisPhaseSuccessful so
the AnalysisRun termination path can proceed normally. Also correct the
misleading doc comment on Resume() which implied it would never be called.

Signed-off-by: Goutham Annem <gouthemannem@gmail.com>
@Goutham-Annem Goutham-Annem requested a review from a team as a code owner July 5, 2026 17:08
@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Published E2E Test Results

  4 files    4 suites   3h 45m 4s ⏱️
122 tests 115 ✅  7 💤 0 ❌
488 runs  460 ✅ 28 💤 0 ❌

Results for commit e2fc199.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Published Unit Test Results

2 517 tests   2 517 ✅  3m 23s ⏱️
  130 suites      0 💤
    1 files        0 ❌

Results for commit e2fc199.

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.97%. Comparing base (d1c2967) to head (e2fc199).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4825      +/-   ##
==========================================
- Coverage   85.09%   84.97%   -0.12%     
==========================================
  Files         166      166              
  Lines       19136    19139       +3     
==========================================
- Hits        16283    16264      -19     
- Misses       2005     2016      +11     
- Partials      848      859      +11     
Flag Coverage Δ
e2e 52.71% <0.00%> (-0.26%) ⬇️
unit-tests 81.39% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

The Kayenta metricprovider does not implement Terminate correctly

1 participant