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: change logic of analysis run to better handle errors #2695

Merged
merged 7 commits into from
Apr 28, 2023

Conversation

zachaller
Copy link
Collaborator

@zachaller zachaller commented Apr 4, 2023

The logic for error handling of anaysisruns was incorrect, we returned an error from a go routine that did not get used at all. This cause errors to not get bubbled up into the status field of the AR resource. This changes the logic around a bit to make sure we bubble up the error to the AR object as well as log it.

fixes: #2696

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

Go Published Test Results

1 949 tests   1 949 ✔️  2m 34s ⏱️
   118 suites         0 💤
       1 files           0

Results for commit 35e21aa.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

E2E Tests Published Test Results

    4 files      4 suites   3h 38m 59s ⏱️
  96 tests   79 ✔️   5 💤 12
400 runs  365 ✔️ 20 💤 15

For more details on these failures, see this check.

Results for commit 35e21aa.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.14 🎉

Comparison is base (2355e8b) 81.47% compared to head (35e21aa) 81.62%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2695      +/-   ##
==========================================
+ Coverage   81.47%   81.62%   +0.14%     
==========================================
  Files         133      133              
  Lines       20154    20152       -2     
==========================================
+ Hits        16421    16449      +28     
+ Misses       2881     2849      -32     
- Partials      852      854       +2     
Impacted Files Coverage Δ
analysis/analysis.go 87.96% <100.00%> (+2.42%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@zachaller zachaller marked this pull request as ready for review April 6, 2023 15:50
@zachaller zachaller requested a review from leoluz April 6, 2023 15:50
@sonarcloud
Copy link

sonarcloud bot commented Apr 27, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.4% 3.4% Duplication

Copy link
Contributor

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

pls check my comments

if t.incompleteMeasurement != nil {
newMeasurement = *t.incompleteMeasurement
} else {
startedAt := timeutil.MetaNow()
newMeasurement.StartedAt = &startedAt
}
newMeasurement.Phase = v1alpha1.AnalysisPhaseError
newMeasurement.Message = err.Error()
newMeasurement.Message = providerErr.Error()
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not returning to the caller which will make the function to continue the execution even after the error occurred. Is this new behaviour expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it is expected and is the fix for the actual bug, this function is also in a go routing and the returned error also is not handled by letting the code actually continue we now get provider errors to end users via the MetricRun status etc. The return was there because the old logic had a requirement on the provider being valid in order to call GetMetadata() I reworked it so that is not required anymore and so it should be safe to continue the code and report the error.

Copy link
Contributor

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

LGTM

@leoluz leoluz merged commit ba11d16 into argoproj:master Apr 28, 2023
@zachaller zachaller added cherry-pick-completed Used once we have cherry picked the PR to all requested releases and removed cherry-pick/release-1.3 cherry-pick/release-1.4 labels May 5, 2023
zachaller added a commit that referenced this pull request May 5, 2023
* change logic of analysis run to better haneld errors

Signed-off-by: zachaller <[email protected]>

* change logic to not call GetMetaData if not nil like the old behavior

Signed-off-by: zachaller <[email protected]>

* move code closer to usage

Signed-off-by: zachaller <[email protected]>

* change logic to not always call GetMetadata keeps original behavior

Signed-off-by: zachaller <[email protected]>

* fix logic

Signed-off-by: zachaller <[email protected]>

* cleanup

Signed-off-by: zachaller <[email protected]>

* add test

Signed-off-by: zachaller <[email protected]>

---------

Signed-off-by: zachaller <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-1.5 cherry-pick-completed Used once we have cherry picked the PR to all requested releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AnalysisRun resource keeps on running when the plugin name is mentioned incorrectly in the Analysis Template
3 participants