Skip to content

controllers/crd: preserve strategy retry counter across failed-CR replace#537

Open
SAY-5 wants to merge 2 commits into
keikoproj:masterfrom
SAY-5:fix/strategy-retry-counter-preserved-on-replace-317
Open

controllers/crd: preserve strategy retry counter across failed-CR replace#537
SAY-5 wants to merge 2 commits into
keikoproj:masterfrom
SAY-5:fix/strategy-retry-counter-preserved-on-replace-317

Conversation

@SAY-5

@SAY-5 SAY-5 commented Apr 20, 2026

Copy link
Copy Markdown

What type of PR is this?

  • Bug fix (non-breaking change which fixes an issue)

Description

SubmitCustomResource in controllers/providers/kubernetes/crd.go clears the strategy retry counter on every successful CR Create. When that Create fires because we just deleted a failed CR via ReplaceConcurrencyPolicy, the reset turns the retry budget into an infinite loop: every replacement re-zeros the counter and the instance group keeps resubmitting a new CR forever regardless of MaxRetries.

Original bug report: #317.

Related issue(s)

Fixes #317

High-level overview of changes

  • Add a local didReplace bool that is flipped to true whenever we kube.Resource(...).Delete(...) a stale/failed CR in the ReplaceConcurrencyPolicy branch.
  • After a successful Create, only call status.SetStrategyRetryCount(0) when !didReplace.

This preserves the existing behaviour on the genuine first-time submission path while honouring MaxRetries on the replace path.

Testing performed

  • make test passes locally.
  • Manually walked the two paths:
    • Fresh submission (activeResources empty): counter still reset to 0 on success, matches previous behaviour.
    • Replace path (ReplaceConcurrencyPolicy deletes one CR then recreates): retry counter is preserved, and once it exceeds MaxRetries the strategy errors out instead of resubmitting indefinitely.

Checklist

  • I've read the CONTRIBUTING doc
  • I've run make test locally and all tests pass
  • I've signed-off my commits with git commit -s for DCO verification
  • Code follows the style guidelines of this project

@SAY-5 SAY-5 requested review from a team as code owners April 20, 2026 20:20
@SAY-5 SAY-5 force-pushed the fix/strategy-retry-counter-preserved-on-replace-317 branch from c3d5a40 to c806aae Compare May 31, 2026 02:41
@SAY-5 SAY-5 requested review from a team as code owners May 31, 2026 02:41
…lace

SubmitCustomResource clears the strategy retry counter on every
successful Create. When the Create happens because we just deleted
a failed CR (ReplaceConcurrencyPolicy), the reset turned the retry
budget into an infinite loop: every replacement re-zeroed the
counter and the instance group would keep submitting a new CR
forever regardless of MaxRetries (keikoproj#317).

Track whether we replaced anything on this pass with a didReplace
bool and only zero the counter on the genuine first-time submission
branch. On replace we keep the accumulated count so the
strategy-level retry budget is actually enforced.

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>

Fixes keikoproj#317

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5 SAY-5 force-pushed the fix/strategy-retry-counter-preserved-on-replace-317 branch from 82cc2a8 to 7cef9f1 Compare June 2, 2026 21:02
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.87%. Comparing base (28af8c2) to head (72cf831).

Files with missing lines Patch % Lines
controllers/providers/kubernetes/crd.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #537      +/-   ##
==========================================
- Coverage   46.89%   46.87%   -0.03%     
==========================================
  Files          40       40              
  Lines        5879     5882       +3     
==========================================
  Hits         2757     2757              
- Misses       2964     2967       +3     
  Partials      158      158              

☔ 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.

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.

MaxRetries: counter is reset on every resource submission

2 participants