Skip to content

Commit 4015c9c

Browse files
committed
few additions
Signed-off-by: Shashank <shashanksingh819@gmail.com>
1 parent 455160e commit 4015c9c

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

cmd/updater/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ func main() {
163163
})
164164
log.Info("Configured concurrency")
165165

166-
groupUpdater := updater.GCS(ctx, client, opt.groupTimeout, opt.buildTimeout, opt.buildConcurrency, opt.confirm, opt.enableIgnoreSkip)
167-
168166
mets := updater.CreateMetrics(prometheus.NewFactory())
169167

168+
groupUpdater := updater.GCS(ctx, client, mets, opt.groupTimeout, opt.buildTimeout, opt.buildConcurrency, opt.confirm, opt.enableIgnoreSkip)
169+
170170
pubsubClient, err := gpubsub.NewClient(ctx, "", option.WithCredentialsFile(opt.creds))
171171
if err != nil {
172172
logrus.WithError(err).Fatal("Failed to create pubsub client")

pkg/updater/updater.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ const componentName = "updater"
4949

5050
// Metrics holds metrics relevant to the Updater.
5151
type Metrics struct {
52-
UpdateState metrics.Cyclic
53-
DelaySeconds metrics.Duration
54-
MoreCounter metrics.Counter
52+
UpdateState metrics.Cyclic
53+
DelaySeconds metrics.Duration
54+
IncompleteUpdates metrics.Counter
5555
}
5656

5757
// CreateMetrics creates metrics for this controller
5858
func CreateMetrics(factory metrics.Factory) *Metrics {
5959
return &Metrics{
60-
UpdateState: factory.NewCyclic(componentName),
61-
DelaySeconds: factory.NewDuration("delay", "Seconds updater is behind schedule", "component"),
62-
MoreCounter: factory.NewCounter("counter", "number of unread columns"),
60+
UpdateState: factory.NewCyclic(componentName),
61+
DelaySeconds: factory.NewDuration("delay", "Seconds updater is behind schedule", "component"),
62+
IncompleteUpdates: factory.NewCounter("incomplete-updates", "number of update attempts that don't complete"),
6363
}
6464
}
6565

@@ -90,7 +90,7 @@ func (mets *Metrics) start() *metrics.CycleReporter {
9090
type GroupUpdater func(parent context.Context, log logrus.FieldLogger, client gcs.Client, tg *configpb.TestGroup, gridPath gcs.Path) (bool, error)
9191

9292
// GCS returns a GCS-based GroupUpdater, which knows how to process result data stored in GCS.
93-
func GCS(poolCtx context.Context, colClient gcs.Client, groupTimeout, buildTimeout time.Duration, concurrency int, write bool, enableIgnoreSkip bool) GroupUpdater {
93+
func GCS(poolCtx context.Context, colClient gcs.Client, mets *Metrics, groupTimeout, buildTimeout time.Duration, concurrency int, write bool, enableIgnoreSkip bool) GroupUpdater {
9494
var readResult *resultReader
9595
if poolCtx == nil {
9696
// TODO(fejta): remove check soon
@@ -107,7 +107,7 @@ func GCS(poolCtx context.Context, colClient gcs.Client, groupTimeout, buildTimeo
107107
defer cancel()
108108
gcsColReader := gcsColumnReader(colClient, buildTimeout, readResult, enableIgnoreSkip)
109109
reprocess := 20 * time.Minute // allow 20m for prow to finish uploading artifacts
110-
return InflateDropAppend(ctx, log, client, tg, gridPath, write, gcsColReader, reprocess)
110+
return InflateDropAppend(ctx, log, client, tg, gridPath, write, gcsColReader, reprocess, mets)
111111
}
112112
}
113113

@@ -738,7 +738,7 @@ func InflateDropAppend(ctx context.Context, alog logrus.FieldLogger, client gcs.
738738
}
739739
if unreadColumns {
740740
log = log.WithField("more", true)
741-
mets.MoreCounter.Add(1)
741+
mets.IncompleteUpdates.Add(1)
742742
}
743743
log.WithFields(logrus.Fields{
744744
"cols": len(grid.Columns),

pkg/updater/updater_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func TestGCS(t *testing.T) {
9595
}
9696
}
9797
}()
98-
updater := GCS(tc.ctx, nil, 0, 0, 0, false, false)
98+
updater := GCS(tc.ctx, nil, nil, 0, 0, 0, false, false)
9999
_, err := updater(ctx, logrus.WithField("case", tc.name), nil, tc.group, gcs.Path{})
100100
switch {
101101
case err != nil:
@@ -425,7 +425,7 @@ func TestUpdate(t *testing.T) {
425425
if tc.groupUpdater == nil {
426426
poolCtx, poolCancel := context.WithCancel(context.Background())
427427
defer poolCancel()
428-
tc.groupUpdater = GCS(poolCtx, client, *tc.groupTimeout, *tc.buildTimeout, tc.buildConcurrency, !tc.skipConfirm, false)
428+
tc.groupUpdater = GCS(poolCtx, client, nil, *tc.groupTimeout, *tc.buildTimeout, tc.buildConcurrency, false, !tc.skipConfirm)
429429
}
430430
opts := &UpdateOptions{
431431
ConfigPath: configPath,
@@ -2059,6 +2059,7 @@ func TestInflateDropAppend(t *testing.T) {
20592059
!tc.skipWrite,
20602060
colReader,
20612061
tc.reprocess,
2062+
nil, //metric
20622063
)
20632064
switch {
20642065
case err != nil:

0 commit comments

Comments
 (0)