Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(appcontroller): if a history limit is negative, automatically converted to 0 #22036

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

kingbj940429
Copy link

Related to #21691

There are two Expected Behaviors

  1. A readable error message pointing out that negative values are not allowed.
  2. Silently interpreting the revisionHistoryLimit as 0.

I choose num 2.

Before

image
image

After

image
image

Checklist:

  • [] Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@kingbj940429 kingbj940429 requested a review from a team as a code owner February 26, 2025 17:02
Copy link

bunnyshell bot commented Feb 26, 2025

✅ Preview Environment deployed on Bunnyshell

Component Endpoints
argocd https://argocd-nhe6hb.bunnyenv.com/
argocd-ttyd https://argocd-web-cli-nhe6hb.bunnyenv.com/

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

kingbj940429 and others added 11 commits February 27, 2025 02:09
fix(appcontroller): if a history limit is negative, automatically converted to 0

Signed-off-by: kingbj0429 <[email protected]>
…oproj#21887) (argoproj#21936)

Signed-off-by: rumstead <[email protected]>
Co-authored-by: Ishita Sequeira <[email protected]>
Co-authored-by: Blake Pettersson <[email protected]>
Signed-off-by: kingbj0429 <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: kingbj0429 <[email protected]>
Signed-off-by: reggie-k <[email protected]>
Signed-off-by: Regina Voloshin <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Co-authored-by: rumstead <[email protected]>
Co-authored-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: kingbj0429 <[email protected]>
…#21990)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: kingbj0429 <[email protected]>
…rgoproj#21989)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: kingbj0429 <[email protected]>
Signed-off-by: Isaac Gaskin <[email protected]>
Signed-off-by: kingbj0429 <[email protected]>
Signed-off-by: nitishfy <[email protected]>
Signed-off-by: Nitish Kumar <[email protected]>
Co-authored-by: Blake Pettersson <[email protected]>
Signed-off-by: kingbj0429 <[email protected]>
@kingbj940429 kingbj940429 force-pushed the kingbj940429/fix-history-causes-panic branch from 0a156f9 to bb59553 Compare February 26, 2025 17:10
@kingbj940429 kingbj940429 requested review from a team as code owners February 26, 2025 17:10
@@ -1287,6 +1287,9 @@ func (in RevisionHistories) LastRevisionHistory() RevisionHistory {

// Trunc truncates the list of history items to size n
func (in RevisionHistories) Trunc(n int) RevisionHistories {
if n < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

although a smallish change, we should add some test cases

Copy link
Author

Choose a reason for hiding this comment

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

which test cases do I add? :)

Copy link
Member

Choose a reason for hiding this comment

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

I would expand on Test_appStateManager_persistRevisionHistory and add a case where "-1" becomes 0. It should be pretty easy to get 100% code coverage on your changes :)

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@b88ad57). Learn more about missing BASE report.
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/apis/application/v1alpha1/types.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #22036   +/-   ##
=========================================
  Coverage          ?   55.74%           
=========================================
  Files             ?      342           
  Lines             ?    57077           
  Branches          ?        0           
=========================================
  Hits              ?    31816           
  Misses            ?    22619           
  Partials          ?     2642           

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

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.

9 participants