-
Notifications
You must be signed in to change notification settings - Fork 146
Fix historical test count query using wrong release for presubmits #3961
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |||||||||||||||||
| apitype "github.com/openshift/sippy/pkg/apis/api" | ||||||||||||||||||
| "github.com/openshift/sippy/pkg/apis/cache" | ||||||||||||||||||
| "github.com/openshift/sippy/pkg/apis/openshift" | ||||||||||||||||||
| sippyv1 "github.com/openshift/sippy/pkg/apis/sippy/v1" | ||||||||||||||||||
| sippyprocessingv1 "github.com/openshift/sippy/pkg/apis/sippyprocessing/v1" | ||||||||||||||||||
| "github.com/openshift/sippy/pkg/bigquery" | ||||||||||||||||||
| "github.com/openshift/sippy/pkg/dataloader/prowloader" | ||||||||||||||||||
|
|
@@ -612,6 +613,15 @@ func joinSegments(segments []string, start int, separator string) string { | |||||||||||||||||
| return strings.Join(segments[start:], separator) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| func latestReleaseForProduct(releases []sippyv1.Release, product string) string { | ||||||||||||||||||
| for _, r := range releases { | ||||||||||||||||||
| if r.Product == product && r.PreviousRelease != "" && r.Release != models.ReleasePresubmits { | ||||||||||||||||||
| return r.Release | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| return "" | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // JobRunRiskAnalysis checks the test failures and linked bugs for a job run, and reports back an estimated | ||||||||||||||||||
| // risk level for each failed test, and the job run overall. | ||||||||||||||||||
| func JobRunRiskAnalysis( | ||||||||||||||||||
|
|
@@ -623,22 +633,22 @@ func JobRunRiskAnalysis( | |||||||||||||||||
| logger = logger.WithField("func", "JobRunRiskAnalysis") | ||||||||||||||||||
| // If this job is a Presubmit, compare to test results from master, not presubmits, which may perform | ||||||||||||||||||
| // worse due to dev code that hasn't merged. We do not presently track presubmits on branches other than | ||||||||||||||||||
| // master, so it should be safe to assume the latest compareRelease in the db. | ||||||||||||||||||
| // master, so we use the latest OCP release from the db. | ||||||||||||||||||
| compareRelease := jobRun.ProwJob.Release | ||||||||||||||||||
| neverStableJob := false | ||||||||||||||||||
| if compareRelease == models.ReleasePresubmits { | ||||||||||||||||||
| ar, err := GetReleasesFromDB(ctx, dbc) | ||||||||||||||||||
| if err != nil { | ||||||||||||||||||
| return apitype.ProwJobRunRiskAnalysis{}, err | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
640
to
643
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Wrap the release lookup error with caller context. Line 642 returns the database error without identifying the presubmit risk-analysis operation. Wrap it with Proposed fix- return apitype.ProwJobRunRiskAnalysis{}, err
+ return apitype.ProwJobRunRiskAnalysis{}, fmt.Errorf("getting releases for presubmit risk analysis: %w", err)As per coding guidelines, “wrap errors with context using 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||||||||
| if len(ar) == 0 { | ||||||||||||||||||
| return apitype.ProwJobRunRiskAnalysis{}, fmt.Errorf("no releases found in db") | ||||||||||||||||||
| // TODO: Non-OCP are not supported yet. At least ensure adding new releases doesn't break OCP. | ||||||||||||||||||
| compareRelease = latestReleaseForProduct(ar, "OCP") | ||||||||||||||||||
| if compareRelease == "" { | ||||||||||||||||||
| return apitype.ProwJobRunRiskAnalysis{}, fmt.Errorf("no suitable OCP release found") | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| compareRelease = ar[0].Release | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| historicalCount, err := query.ProwJobHistoricalTestCounts(dbc, jobRun.ProwJob.ID, compareRelease) | ||||||||||||||||||
| historicalCount, err := query.ProwJobHistoricalTestCounts(dbc, jobRun.ProwJob.ID, jobRun.ProwJob.Release) | ||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||
|
|
||||||||||||||||||
| // if we had an error we will continue the risk analysis and not elevate based on test counts | ||||||||||||||||||
| if err != nil { | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's replace this with https://github.com/machine424/openshift-sippy/blob/51b437ff66158ef1cd8150ff6d349bc2658db50b/pkg/db/query/release_queries.go#L14