Skip to content

Commit f190e5b

Browse files
Merge pull request #3562 from dgoodwin/remove-variant-junit-table-overrides
Delete the unused rarely run jobs / variant overrides feature
2 parents ee7dded + 2f7a72d commit f190e5b

17 files changed

Lines changed: 45 additions & 465 deletions

File tree

cmd/sippy/annotatejobruns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Example run: sippy annotate-job-runs --google-service-account-credential-file=f
180180
return errors.WithMessage(err, "couldn't get DB client")
181181
}
182182

183-
allVariants, errs := componentreadiness.GetJobVariants(ctx, bqprovider.NewBigQueryProvider(bigQueryClient, nil))
183+
allVariants, errs := componentreadiness.GetJobVariants(ctx, bqprovider.NewBigQueryProvider(bigQueryClient))
184184
if len(errs) > 0 {
185185
return fmt.Errorf("failed to get job variants: %v", errs)
186186
}

cmd/sippy/automatejira.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,7 @@ func NewAutomateJiraCommand() *cobra.Command {
165165
return fmt.Errorf("couldn't get jira client: jira auth is not configured")
166166
}
167167

168-
config, err := f.ConfigFlags.GetConfig()
169-
if err != nil {
170-
log.WithError(err).Warn("error reading config file")
171-
}
172-
173-
provider := bqprovider.NewBigQueryProvider(bigQueryClient, config.ComponentReadinessConfig.VariantJunitTableOverrides)
168+
provider := bqprovider.NewBigQueryProvider(bigQueryClient)
174169
allVariants, errs := componentreadiness.GetJobVariants(ctx, provider)
175170
if len(errs) > 0 {
176171
return fmt.Errorf("failed to get job variants: %v", errs)

cmd/sippy/component_readiness.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (f *ComponentReadinessFlags) runServerMode() error {
187187
log.WithError(err).Warn("unable to initialize Jira client, bug filing will be disabled")
188188
}
189189

190-
crDataProvider := bqprovider.NewBigQueryProvider(bigQueryClient, config.ComponentReadinessConfig.VariantJunitTableOverrides)
190+
crDataProvider := bqprovider.NewBigQueryProvider(bigQueryClient)
191191

192192
server := sippyserver.NewServer(
193193
sippyserver.ModeOpenShift,

cmd/sippy/load.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ func NewLoadCommand() *cobra.Command {
223223
dbc, bqc, config, views.ComponentReadiness, releaseConfigs,
224224
f.ComponentReadinessFlags.CRTimeRoundingFactor,
225225
regressionStore,
226-
config.ComponentReadinessConfig.VariantJunitTableOverrides,
227226
)
228227
if err != nil {
229228
return errors.Wrap(err, "error creating regression cache loader")

cmd/sippy/serve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func NewServeCommand() *cobra.Command {
133133
bigQueryClient = f.CacheFlags.DecorateBiqQueryClientWithPersistentCache(bigQueryClient)
134134
}
135135

136-
crDataProvider = bqprovider.NewBigQueryProvider(bigQueryClient, config.ComponentReadinessConfig.VariantJunitTableOverrides)
136+
crDataProvider = bqprovider.NewBigQueryProvider(bigQueryClient)
137137
}
138138

139139
case "postgres":

config/openshift-customizations.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# This file is used as an overlay to customize the generated config, so it contains the Presubmit pseudorelease.
22
prow:
33
url: https://prow.ci.openshift.org/prowjobs.js
4-
componentReadiness:
5-
variantJunitTableOverrides:
6-
- variantName: JobTier
7-
variantValue: rare
8-
tableName: junit_rarely_run_jobs
9-
relativeStart: end-90d
104
releases:
115
"3.11":
126
jobs:

pkg/api/componentreadiness/dataprovider/bigquery/provider.go

Lines changed: 5 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"sort"
77
"strconv"
88
"strings"
9-
"sync"
109
"time"
1110

1211
"cloud.google.com/go/bigquery"
@@ -19,11 +18,9 @@ import (
1918
"github.com/openshift/sippy/pkg/apis/api/componentreport/crtest"
2019
"github.com/openshift/sippy/pkg/apis/api/componentreport/reqopts"
2120
apiCache "github.com/openshift/sippy/pkg/apis/cache"
22-
configv1 "github.com/openshift/sippy/pkg/apis/config/v1"
2321
v1 "github.com/openshift/sippy/pkg/apis/sippy/v1"
2422
bqcachedclient "github.com/openshift/sippy/pkg/bigquery"
2523
"github.com/openshift/sippy/pkg/bigquery/bqlabel"
26-
"github.com/openshift/sippy/pkg/util"
2724
"github.com/openshift/sippy/pkg/util/param"
2825
"github.com/openshift/sippy/pkg/util/sets"
2926
)
@@ -33,12 +30,11 @@ var _ dataprovider.DataProvider = &BigQueryProvider{}
3330
// BigQueryProvider implements dataprovider.DataProvider using Google BigQuery
3431
// as the backing data store, wrapping the existing query generators.
3532
type BigQueryProvider struct {
36-
client *bqcachedclient.Client
37-
variantJunitTableOverrides []configv1.VariantJunitTableOverride
33+
client *bqcachedclient.Client
3834
}
3935

40-
func NewBigQueryProvider(client *bqcachedclient.Client, overrides []configv1.VariantJunitTableOverride) *BigQueryProvider {
41-
return &BigQueryProvider{client: client, variantJunitTableOverrides: overrides}
36+
func NewBigQueryProvider(client *bqcachedclient.Client) *BigQueryProvider {
37+
return &BigQueryProvider{client: client}
4238
}
4339

4440
// Client returns the underlying BigQuery client for callers that still need direct access
@@ -72,92 +68,7 @@ func (p *BigQueryProvider) QuerySampleTestStatus(ctx context.Context, reqOptions
7268
includeVariants map[string][]string,
7369
start, end time.Time) (map[string]crstatus.TestStatus, []error) {
7470

75-
fLog := log.WithField("func", "QuerySampleTestStatus")
76-
77-
// Filter out overridden variants from the default query
78-
filteredVariants, skipDefault := copyIncludeVariantsAndRemoveOverrides(p.variantJunitTableOverrides, -1, includeVariants)
79-
80-
type result struct {
81-
status map[string]crstatus.TestStatus
82-
errs []error
83-
}
84-
resultCh := make(chan result)
85-
var wg sync.WaitGroup
86-
87-
// Run default query (unless all variants were overridden)
88-
if !skipDefault {
89-
wg.Add(1)
90-
go func() {
91-
defer wg.Done()
92-
select {
93-
case <-ctx.Done():
94-
return
95-
default:
96-
fLog.Infof("running default sample query with includeVariants: %+v", filteredVariants)
97-
s, e := p.querySampleTestStatusForTable(ctx, reqOptions, allJobVariants, filteredVariants, start, end, DefaultJunitTable)
98-
resultCh <- result{s, e}
99-
}
100-
}()
101-
}
102-
103-
// Run override queries for applicable variants
104-
for i, or := range p.variantJunitTableOverrides {
105-
if !containsOverriddenVariant(includeVariants, or.VariantName, or.VariantValue) {
106-
continue
107-
}
108-
index, override := i, or
109-
wg.Add(1)
110-
go func() {
111-
defer wg.Done()
112-
select {
113-
case <-ctx.Done():
114-
return
115-
default:
116-
overrideVariants, skip := copyIncludeVariantsAndRemoveOverrides(p.variantJunitTableOverrides, index, includeVariants)
117-
if skip {
118-
fLog.Infof("skipping override sample query as all values for a variant were overridden")
119-
return
120-
}
121-
overrideEnd := end
122-
overrideStart, err := util.ParseCRReleaseTime([]v1.Release{}, "", override.RelativeStart,
123-
true, &overrideEnd, reqOptions.CacheOption.CRTimeRoundingFactor)
124-
if err != nil {
125-
resultCh <- result{nil, []error{err}}
126-
return
127-
}
128-
fLog.Infof("running override sample query for %+v with includeVariants: %+v", override, overrideVariants)
129-
s, e := p.querySampleTestStatusForTable(ctx, reqOptions, allJobVariants, overrideVariants, overrideStart, overrideEnd, override.TableName)
130-
resultCh <- result{s, e}
131-
}
132-
}()
133-
}
134-
135-
go func() {
136-
wg.Wait()
137-
close(resultCh)
138-
}()
139-
140-
merged := make(map[string]crstatus.TestStatus)
141-
var allErrs []error
142-
for r := range resultCh {
143-
allErrs = append(allErrs, r.errs...)
144-
for k, v := range r.status {
145-
merged[k] = v
146-
}
147-
}
148-
if len(allErrs) > 0 {
149-
return nil, allErrs
150-
}
151-
return merged, nil
152-
}
153-
154-
func (p *BigQueryProvider) querySampleTestStatusForTable(ctx context.Context, reqOptions reqopts.RequestOptions,
155-
allJobVariants crtest.JobVariants,
156-
includeVariants map[string][]string,
157-
start, end time.Time,
158-
junitTable string) (map[string]crstatus.TestStatus, []error) {
159-
160-
generator := NewSampleQueryGenerator(p.client, reqOptions, allJobVariants, includeVariants, start, end, junitTable)
71+
generator := NewSampleQueryGenerator(p.client, reqOptions, allJobVariants, includeVariants, start, end)
16172
result, errs := apiPkg.GetDataFromCacheOrGenerate[crstatus.ReportTestStatus](
16273
ctx, p.client.Cache, reqOptions.CacheOption,
16374
apiPkg.NewCacheSpec(generator, "SampleTestStatus~", &reqOptions.SampleRelease.End),
@@ -194,89 +105,7 @@ func (p *BigQueryProvider) QuerySampleJobRunTestStatus(ctx context.Context, reqO
194105
includeVariants map[string][]string,
195106
start, end time.Time) (map[string][]crstatus.TestJobRunRows, []error) {
196107

197-
fLog := log.WithField("func", "QuerySampleJobRunTestStatus")
198-
199-
filteredVariants, skipDefault := copyIncludeVariantsAndRemoveOverrides(p.variantJunitTableOverrides, -1, includeVariants)
200-
201-
type result struct {
202-
status map[string][]crstatus.TestJobRunRows
203-
errs []error
204-
}
205-
resultCh := make(chan result)
206-
var wg sync.WaitGroup
207-
208-
if !skipDefault {
209-
wg.Add(1)
210-
go func() {
211-
defer wg.Done()
212-
select {
213-
case <-ctx.Done():
214-
return
215-
default:
216-
fLog.Infof("running default sample job run query with includeVariants: %+v", filteredVariants)
217-
s, e := p.querySampleJobRunTestStatusForTable(ctx, reqOptions, allJobVariants, filteredVariants, start, end, DefaultJunitTable)
218-
resultCh <- result{s, e}
219-
}
220-
}()
221-
}
222-
223-
for i, or := range p.variantJunitTableOverrides {
224-
if !containsOverriddenVariant(includeVariants, or.VariantName, or.VariantValue) {
225-
continue
226-
}
227-
index, override := i, or
228-
wg.Add(1)
229-
go func() {
230-
defer wg.Done()
231-
select {
232-
case <-ctx.Done():
233-
return
234-
default:
235-
overrideVariants, skip := copyIncludeVariantsAndRemoveOverrides(p.variantJunitTableOverrides, index, includeVariants)
236-
if skip {
237-
fLog.Infof("skipping override sample job run query as all values for a variant were overridden")
238-
return
239-
}
240-
overrideEnd := end
241-
overrideStart, err := util.ParseCRReleaseTime([]v1.Release{}, "", override.RelativeStart,
242-
true, &overrideEnd, reqOptions.CacheOption.CRTimeRoundingFactor)
243-
if err != nil {
244-
resultCh <- result{nil, []error{err}}
245-
return
246-
}
247-
fLog.Infof("running override sample job run query for %+v with includeVariants: %+v", override, overrideVariants)
248-
s, e := p.querySampleJobRunTestStatusForTable(ctx, reqOptions, allJobVariants, overrideVariants, overrideStart, overrideEnd, override.TableName)
249-
resultCh <- result{s, e}
250-
}
251-
}()
252-
}
253-
254-
go func() {
255-
wg.Wait()
256-
close(resultCh)
257-
}()
258-
259-
merged := make(map[string][]crstatus.TestJobRunRows)
260-
var allErrs []error
261-
for r := range resultCh {
262-
allErrs = append(allErrs, r.errs...)
263-
for k, v := range r.status {
264-
merged[k] = v
265-
}
266-
}
267-
if len(allErrs) > 0 {
268-
return nil, allErrs
269-
}
270-
return merged, nil
271-
}
272-
273-
func (p *BigQueryProvider) querySampleJobRunTestStatusForTable(ctx context.Context, reqOptions reqopts.RequestOptions,
274-
allJobVariants crtest.JobVariants,
275-
includeVariants map[string][]string,
276-
start, end time.Time,
277-
junitTable string) (map[string][]crstatus.TestJobRunRows, []error) {
278-
279-
generator := NewSampleTestDetailsQueryGenerator(p.client, reqOptions, allJobVariants, includeVariants, start, end, junitTable)
108+
generator := NewSampleTestDetailsQueryGenerator(p.client, reqOptions, allJobVariants, includeVariants, start, end)
280109
result, errs := apiPkg.GetDataFromCacheOrGenerate[crstatus.TestJobRunStatuses](
281110
ctx, p.client.Cache, reqOptions.CacheOption,
282111
apiPkg.NewCacheSpec(generator, "SampleJobRunTestStatusV2~", &end),
@@ -568,58 +397,3 @@ func getSingleColumnResultToSlice(ctx context.Context, q *bigquery.Query) ([]str
568397
}
569398
return names, nil
570399
}
571-
572-
// containsOverriddenVariant checks whether the given variant key/value pair
573-
// is present in the includeVariants map (i.e. the request actually includes
574-
// data for this overridden variant).
575-
func containsOverriddenVariant(includeVariants map[string][]string, key, value string) bool {
576-
for k, v := range includeVariants {
577-
if k != key {
578-
continue
579-
}
580-
for _, vv := range v {
581-
if vv == value {
582-
return true
583-
}
584-
}
585-
}
586-
return false
587-
}
588-
589-
// copyIncludeVariantsAndRemoveOverrides copies includeVariants and removes
590-
// overridden variant values. For the default query (currOverride=-1), all
591-
// overridden values are removed. For an override query at index i, only
592-
// other overrides' values are removed. Returns true if the query should be
593-
// skipped because all values for a variant were removed.
594-
func copyIncludeVariantsAndRemoveOverrides(
595-
overrides []configv1.VariantJunitTableOverride,
596-
currOverride int,
597-
includeVariants map[string][]string) (map[string][]string, bool) {
598-
599-
cp := make(map[string][]string)
600-
for key, values := range includeVariants {
601-
var newSlice []string
602-
for _, v := range values {
603-
if !shouldSkipVariant(overrides, currOverride, key, v) {
604-
newSlice = append(newSlice, v)
605-
}
606-
}
607-
if len(newSlice) == 0 {
608-
return cp, true
609-
}
610-
cp[key] = newSlice
611-
}
612-
return cp, false
613-
}
614-
615-
func shouldSkipVariant(overrides []configv1.VariantJunitTableOverride, currOverride int, key, value string) bool {
616-
for i, override := range overrides {
617-
if i == currOverride {
618-
return false
619-
}
620-
if override.VariantName == key && override.VariantValue == value {
621-
return true
622-
}
623-
}
624-
return false
625-
}

0 commit comments

Comments
 (0)