-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathmetrics.go
632 lines (548 loc) · 19.6 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
/*
Copyright 2019 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package taskrunmetrics
import (
"context"
"fmt"
"sync"
"time"
"github.com/pkg/errors"
"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
listers "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1"
"github.com/tektoncd/pipeline/pkg/pod"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"knative.dev/pkg/apis"
"knative.dev/pkg/logging"
"knative.dev/pkg/metrics"
)
const anonymous = "anonymous"
var (
pipelinerunTag = tag.MustNewKey("pipelinerun")
pipelineTag = tag.MustNewKey("pipeline")
taskrunTag = tag.MustNewKey("taskrun")
taskTag = tag.MustNewKey("task")
namespaceTag = tag.MustNewKey("namespace")
statusTag = tag.MustNewKey("status")
reasonTag = tag.MustNewKey("reason")
podTag = tag.MustNewKey("pod")
trDurationView *view.View
prTRDurationView *view.View
trCountView *view.View
trTotalView *view.View
runningTRsCountView *view.View
runningTRsView *view.View
runningTRsThrottledByQuotaCountView *view.View
runningTRsThrottledByNodeCountView *view.View
runningTRsThrottledByQuotaView *view.View
runningTRsThrottledByNodeView *view.View
runningTRsWaitingOnTaskResolutionCountView *view.View
podLatencyView *view.View
trDuration = stats.Float64(
"taskrun_duration_seconds",
"The taskrun's execution time in seconds",
stats.UnitDimensionless)
prTRDuration = stats.Float64(
"pipelinerun_taskrun_duration_seconds",
"The pipelinerun's taskrun execution time in seconds",
stats.UnitDimensionless)
trCount = stats.Float64("taskrun_count",
"number of taskruns",
stats.UnitDimensionless)
trTotal = stats.Float64("taskrun_total",
"Number of taskruns",
stats.UnitDimensionless)
runningTRsCount = stats.Float64("running_taskruns_count",
"Number of taskruns executing currently",
stats.UnitDimensionless)
runningTRs = stats.Float64("running_taskruns",
"Number of taskruns executing currently",
stats.UnitDimensionless)
runningTRsThrottledByQuotaCount = stats.Float64("running_taskruns_throttled_by_quota_count",
"Number of taskruns executing currently, but whose underlying Pods or Containers are suspended by k8s because of defined ResourceQuotas. Such suspensions can occur as part of initial scheduling of the Pod, or scheduling of any of the subsequent Container(s) in the Pod after the first Container is started",
stats.UnitDimensionless)
runningTRsThrottledByNodeCount = stats.Float64("running_taskruns_throttled_by_node_count",
"Number of taskruns executing currently, but whose underlying Pods or Containers are suspended by k8s because of Node level constraints. Such suspensions can occur as part of initial scheduling of the Pod, or scheduling of any of the subsequent Container(s) in the Pod after the first Container is started",
stats.UnitDimensionless)
runningTRsWaitingOnTaskResolutionCount = stats.Float64("running_taskruns_waiting_on_task_resolution_count",
"Number of taskruns executing currently that are waiting on resolution requests for their task references.",
stats.UnitDimensionless)
runningTRsThrottledByQuota = stats.Float64("running_taskruns_throttled_by_quota",
"Number of taskruns executing currently, but whose underlying Pods or Containers are suspended by k8s because of defined ResourceQuotas. Such suspensions can occur as part of initial scheduling of the Pod, or scheduling of any of the subsequent Container(s) in the Pod after the first Container is started",
stats.UnitDimensionless)
runningTRsThrottledByNode = stats.Float64("running_taskruns_throttled_by_node",
"Number of taskruns executing currently, but whose underlying Pods or Containers are suspended by k8s because of Node level constraints. Such suspensions can occur as part of initial scheduling of the Pod, or scheduling of any of the subsequent Container(s) in the Pod after the first Container is started",
stats.UnitDimensionless)
podLatency = stats.Float64("taskruns_pod_latency_milliseconds",
"scheduling latency for the taskruns pods",
stats.UnitMilliseconds)
)
// Recorder is used to actually record TaskRun metrics
type Recorder struct {
mutex sync.Mutex
initialized bool
cfg *config.Metrics
ReportingPeriod time.Duration
insertTaskTag func(task,
taskrun string) []tag.Mutator
insertPipelineTag func(pipeline,
pipelinerun string) []tag.Mutator
}
// We cannot register the view multiple times, so NewRecorder lazily
// initializes this singleton and returns the same recorder across any
// subsequent invocations.
var (
once sync.Once
r *Recorder
errRegistering error
)
// NewRecorder creates a new metrics recorder instance
// to log the TaskRun related metrics
func NewRecorder(ctx context.Context) (*Recorder, error) {
once.Do(func() {
cfg := config.FromContextOrDefaults(ctx)
r = &Recorder{
initialized: true,
cfg: cfg.Metrics,
// Default to reporting metrics every 30s.
ReportingPeriod: 30 * time.Second,
}
errRegistering = viewRegister(cfg.Metrics)
if errRegistering != nil {
r.initialized = false
return
}
})
return r, errRegistering
}
func viewRegister(cfg *config.Metrics) error {
r.mutex.Lock()
defer r.mutex.Unlock()
var prunTag []tag.Key
switch cfg.PipelinerunLevel {
case config.PipelinerunLevelAtPipelinerun:
prunTag = []tag.Key{pipelineTag, pipelinerunTag}
r.insertPipelineTag = pipelinerunInsertTag
case config.PipelinerunLevelAtPipeline:
prunTag = []tag.Key{pipelineTag}
r.insertPipelineTag = pipelineInsertTag
case config.PipelinerunLevelAtNS:
prunTag = []tag.Key{}
r.insertPipelineTag = nilInsertTag
default:
return errors.New("invalid config for PipelinerunLevel: " + cfg.PipelinerunLevel)
}
var trunTag []tag.Key
switch cfg.TaskrunLevel {
case config.TaskrunLevelAtTaskrun:
trunTag = []tag.Key{taskTag, taskrunTag}
r.insertTaskTag = taskrunInsertTag
case config.TaskrunLevelAtTask:
trunTag = []tag.Key{taskTag}
r.insertTaskTag = taskInsertTag
case config.PipelinerunLevelAtNS:
trunTag = []tag.Key{}
r.insertTaskTag = nilInsertTag
default:
return errors.New("invalid config for TaskrunLevel: " + cfg.TaskrunLevel)
}
distribution := view.Distribution(10, 30, 60, 300, 900, 1800, 3600, 5400, 10800, 21600, 43200, 86400)
if cfg.TaskrunLevel == config.TaskrunLevelAtTaskrun ||
cfg.PipelinerunLevel == config.PipelinerunLevelAtPipelinerun {
distribution = view.LastValue()
} else {
switch cfg.DurationTaskrunType {
case config.DurationTaskrunTypeHistogram:
case config.DurationTaskrunTypeLastValue:
distribution = view.LastValue()
default:
return errors.New("invalid config for DurationTaskrunType: " + cfg.DurationTaskrunType)
}
}
trCountViewTags := []tag.Key{statusTag}
if cfg.CountWithReason {
trCountViewTags = append(trCountViewTags, reasonTag)
trunTag = append(trunTag, reasonTag)
}
trDurationView = &view.View{
Description: trDuration.Description(),
Measure: trDuration,
Aggregation: distribution,
TagKeys: append([]tag.Key{statusTag, namespaceTag}, trunTag...),
}
prTRDurationView = &view.View{
Description: prTRDuration.Description(),
Measure: prTRDuration,
Aggregation: distribution,
TagKeys: append([]tag.Key{statusTag, namespaceTag}, append(trunTag, prunTag...)...),
}
trCountView = &view.View{
Description: trCount.Description(),
Measure: trCount,
Aggregation: view.Count(),
TagKeys: trCountViewTags,
}
trTotalView = &view.View{
Description: trTotal.Description(),
Measure: trTotal,
Aggregation: view.Count(),
TagKeys: []tag.Key{statusTag},
}
runningTRsCountView = &view.View{
Description: runningTRsCount.Description(),
Measure: runningTRsCount,
Aggregation: view.LastValue(),
}
runningTRsView = &view.View{
Description: runningTRs.Description(),
Measure: runningTRs,
Aggregation: view.LastValue(),
}
runningTRsThrottledByQuotaCountView = &view.View{
Description: runningTRsThrottledByQuotaCount.Description(),
Measure: runningTRsThrottledByQuotaCount,
Aggregation: view.LastValue(),
}
runningTRsThrottledByNodeCountView = &view.View{
Description: runningTRsThrottledByNodeCount.Description(),
Measure: runningTRsThrottledByNodeCount,
Aggregation: view.LastValue(),
}
runningTRsWaitingOnTaskResolutionCountView = &view.View{
Description: runningTRsWaitingOnTaskResolutionCount.Description(),
Measure: runningTRsWaitingOnTaskResolutionCount,
Aggregation: view.LastValue(),
}
throttleViewTags := []tag.Key{}
if cfg.ThrottleWithNamespace {
throttleViewTags = append(throttleViewTags, namespaceTag)
}
runningTRsThrottledByQuotaView = &view.View{
Description: runningTRsThrottledByQuota.Description(),
Measure: runningTRsThrottledByQuota,
Aggregation: view.LastValue(),
TagKeys: throttleViewTags,
}
runningTRsThrottledByNodeView = &view.View{
Description: runningTRsThrottledByNode.Description(),
Measure: runningTRsThrottledByNode,
Aggregation: view.LastValue(),
TagKeys: throttleViewTags,
}
podLatencyView = &view.View{
Description: podLatency.Description(),
Measure: podLatency,
Aggregation: view.LastValue(),
TagKeys: append([]tag.Key{namespaceTag, podTag}, trunTag...),
}
return view.Register(
trDurationView,
prTRDurationView,
trCountView,
trTotalView,
runningTRsCountView,
runningTRsView,
runningTRsThrottledByQuotaCountView,
runningTRsThrottledByNodeCountView,
runningTRsWaitingOnTaskResolutionCountView,
runningTRsThrottledByQuotaView,
runningTRsThrottledByNodeView,
podLatencyView,
)
}
func viewUnregister() {
view.Unregister(
trDurationView,
prTRDurationView,
trCountView,
trTotalView,
runningTRsCountView,
runningTRsView,
runningTRsThrottledByQuotaCountView,
runningTRsThrottledByNodeCountView,
runningTRsWaitingOnTaskResolutionCountView,
runningTRsThrottledByQuotaView,
runningTRsThrottledByNodeView,
podLatencyView,
)
}
// OnStore returns a function that checks if metrics are configured for a config.Store, and registers it if so
func OnStore(logger *zap.SugaredLogger, r *Recorder) func(name string, value interface{}) {
return func(name string, value interface{}) {
if name == config.GetMetricsConfigName() {
cfg, ok := value.(*config.Metrics)
if !ok {
logger.Error("Failed to do type insertion for extracting metrics config")
return
}
r.updateConfig(cfg)
// Update metrics according to the configuration
viewUnregister()
err := viewRegister(cfg)
if err != nil {
logger.Errorf("Failed to register View %v ", err)
return
}
}
}
}
func pipelinerunInsertTag(pipeline, pipelinerun string) []tag.Mutator {
return []tag.Mutator{
tag.Insert(pipelineTag, pipeline),
tag.Insert(pipelinerunTag, pipelinerun),
}
}
func pipelineInsertTag(pipeline, pipelinerun string) []tag.Mutator {
return []tag.Mutator{tag.Insert(pipelineTag, pipeline)}
}
func taskrunInsertTag(task, taskrun string) []tag.Mutator {
return []tag.Mutator{
tag.Insert(taskTag, task),
tag.Insert(taskrunTag, taskrun),
}
}
func taskInsertTag(task, taskrun string) []tag.Mutator {
return []tag.Mutator{tag.Insert(taskTag, task)}
}
func nilInsertTag(task, taskrun string) []tag.Mutator {
return []tag.Mutator{}
}
func getTaskTagName(tr *v1.TaskRun) string {
taskName := anonymous
switch {
case tr.Spec.TaskRef != nil && len(tr.Spec.TaskRef.Name) > 0:
taskName = tr.Spec.TaskRef.Name
case tr.Spec.TaskSpec != nil:
pipelineTaskTable, hasPipelineTaskTable := tr.Labels[pipeline.PipelineTaskLabelKey]
if hasPipelineTaskTable && len(pipelineTaskTable) > 0 {
taskName = pipelineTaskTable
}
case tr.Spec.TaskRef != nil && tr.Spec.TaskRef.Kind == v1.ClusterTaskRefKind:
clusterTaskLabel, hasClusterTaskLabel := tr.Labels[pipeline.ClusterTaskLabelKey]
if hasClusterTaskLabel && len(clusterTaskLabel) > 0 {
taskName = clusterTaskLabel
}
default:
if len(tr.Labels) > 0 {
taskLabel, hasTaskLabel := tr.Labels[pipeline.TaskLabelKey]
if hasTaskLabel && len(taskLabel) > 0 {
taskName = taskLabel
}
}
}
return taskName
}
func (r *Recorder) updateConfig(cfg *config.Metrics) {
r.mutex.Lock()
defer r.mutex.Unlock()
r.cfg = cfg
}
// DurationAndCount logs the duration of TaskRun execution and
// count for number of TaskRuns succeed or failed
// returns an error if its failed to log the metrics
func (r *Recorder) DurationAndCount(ctx context.Context, tr *v1.TaskRun, beforeCondition *apis.Condition) error {
if !r.initialized {
return fmt.Errorf("ignoring the metrics recording for %s , failed to initialize the metrics recorder", tr.Name)
}
afterCondition := tr.Status.GetCondition(apis.ConditionSucceeded)
if equality.Semantic.DeepEqual(beforeCondition, afterCondition) {
return nil
}
r.mutex.Lock()
defer r.mutex.Unlock()
duration := time.Since(tr.Status.StartTime.Time)
if tr.Status.CompletionTime != nil {
duration = tr.Status.CompletionTime.Sub(tr.Status.StartTime.Time)
}
taskName := getTaskTagName(tr)
cond := tr.Status.GetCondition(apis.ConditionSucceeded)
status := "success"
if cond.Status == corev1.ConditionFalse {
status = "failed"
}
reason := cond.Reason
durationStat := trDuration
tags := []tag.Mutator{tag.Insert(namespaceTag, tr.Namespace), tag.Insert(statusTag, status), tag.Insert(reasonTag, reason)}
if ok, pipeline, pipelinerun := IsPartOfPipeline(tr); ok {
durationStat = prTRDuration
tags = append(tags, r.insertPipelineTag(pipeline, pipelinerun)...)
}
tags = append(tags, r.insertTaskTag(taskName, tr.Name)...)
ctx, err := tag.New(ctx, tags...)
if err != nil {
return err
}
metrics.Record(ctx, durationStat.M(duration.Seconds()))
metrics.Record(ctx, trCount.M(1))
metrics.Record(ctx, trTotal.M(1))
return nil
}
// RunningTaskRuns logs the number of TaskRuns running right now
// returns an error if its failed to log the metrics
func (r *Recorder) RunningTaskRuns(ctx context.Context, lister listers.TaskRunLister) error {
r.mutex.Lock()
defer r.mutex.Unlock()
if !r.initialized {
return errors.New("ignoring the metrics recording, failed to initialize the metrics recorder")
}
trs, err := lister.List(labels.Everything())
if err != nil {
return err
}
addNamespaceLabelToQuotaThrottleMetric := r.cfg != nil && r.cfg.ThrottleWithNamespace
var runningTrs int
trsThrottledByQuota := map[string]int{}
trsThrottledByQuotaCount := 0
trsThrottledByNode := map[string]int{}
trsThrottledByNodeCount := 0
var trsWaitResolvingTaskRef int
for _, pr := range trs {
// initialize metrics with namespace tag to zero if unset; will then update as needed below
_, ok := trsThrottledByQuota[pr.Namespace]
if !ok {
trsThrottledByQuota[pr.Namespace] = 0
}
_, ok = trsThrottledByNode[pr.Namespace]
if !ok {
trsThrottledByNode[pr.Namespace] = 0
}
if pr.IsDone() {
continue
}
runningTrs++
succeedCondition := pr.Status.GetCondition(apis.ConditionSucceeded)
if succeedCondition != nil && succeedCondition.Status == corev1.ConditionUnknown {
switch succeedCondition.Reason {
case pod.ReasonExceededResourceQuota:
trsThrottledByQuotaCount++
cnt := trsThrottledByQuota[pr.Namespace]
cnt++
trsThrottledByQuota[pr.Namespace] = cnt
case pod.ReasonExceededNodeResources:
trsThrottledByNodeCount++
cnt := trsThrottledByNode[pr.Namespace]
cnt++
trsThrottledByNode[pr.Namespace] = cnt
case v1.TaskRunReasonResolvingTaskRef:
trsWaitResolvingTaskRef++
}
}
}
ctx, err = tag.New(ctx)
if err != nil {
return err
}
metrics.Record(ctx, runningTRsCount.M(float64(runningTrs)))
metrics.Record(ctx, runningTRs.M(float64(runningTrs)))
metrics.Record(ctx, runningTRsWaitingOnTaskResolutionCount.M(float64(trsWaitResolvingTaskRef)))
metrics.Record(ctx, runningTRsThrottledByQuotaCount.M(float64(trsThrottledByQuotaCount)))
metrics.Record(ctx, runningTRsThrottledByNodeCount.M(float64(trsThrottledByNodeCount)))
for ns, cnt := range trsThrottledByQuota {
var mutators []tag.Mutator
if addNamespaceLabelToQuotaThrottleMetric {
mutators = []tag.Mutator{tag.Insert(namespaceTag, ns)}
}
ctx, err := tag.New(ctx, mutators...)
if err != nil {
return err
}
metrics.Record(ctx, runningTRsThrottledByQuota.M(float64(cnt)))
}
for ns, cnt := range trsThrottledByNode {
var mutators []tag.Mutator
if addNamespaceLabelToQuotaThrottleMetric {
mutators = []tag.Mutator{tag.Insert(namespaceTag, ns)}
}
ctx, err := tag.New(ctx, mutators...)
if err != nil {
return err
}
metrics.Record(ctx, runningTRsThrottledByNode.M(float64(cnt)))
}
return nil
}
// ReportRunningTaskRuns invokes RunningTaskRuns on our configured PeriodSeconds
// until the context is cancelled.
func (r *Recorder) ReportRunningTaskRuns(ctx context.Context, lister listers.TaskRunLister) {
logger := logging.FromContext(ctx)
for {
delay := time.NewTimer(r.ReportingPeriod)
select {
case <-ctx.Done():
// When the context is cancelled, stop reporting.
if !delay.Stop() {
<-delay.C
}
return
case <-delay.C:
// Every 30s surface a metric for the number of running tasks, as well as those running tasks that are currently throttled by k8s,
// and those running tasks waiting on task reference resolution
if err := r.RunningTaskRuns(ctx, lister); err != nil {
logger.Warnf("Failed to log the metrics : %v", err)
}
}
}
}
// RecordPodLatency logs the duration required to schedule the pod for TaskRun
// returns an error if its failed to log the metrics
func (r *Recorder) RecordPodLatency(ctx context.Context, pod *corev1.Pod, tr *v1.TaskRun) error {
r.mutex.Lock()
defer r.mutex.Unlock()
if !r.initialized {
return errors.New("ignoring the metrics recording for pod , failed to initialize the metrics recorder")
}
scheduledTime := getScheduledTime(pod)
if scheduledTime.IsZero() {
return errors.New("pod has never got scheduled")
}
latency := scheduledTime.Sub(pod.CreationTimestamp.Time)
taskName := getTaskTagName(tr)
ctx, err := tag.New(
ctx,
append([]tag.Mutator{
tag.Insert(namespaceTag, tr.Namespace),
tag.Insert(podTag, pod.Name),
},
r.insertTaskTag(taskName, tr.Name)...)...)
if err != nil {
return err
}
metrics.Record(ctx, podLatency.M(float64(latency.Milliseconds())))
return nil
}
// IsPartOfPipeline return true if TaskRun is a part of a Pipeline.
// It also return the name of Pipeline and PipelineRun
func IsPartOfPipeline(tr *v1.TaskRun) (bool, string, string) {
pipelineLabel, hasPipelineLabel := tr.Labels[pipeline.PipelineLabelKey]
pipelineRunLabel, hasPipelineRunLabel := tr.Labels[pipeline.PipelineRunLabelKey]
if hasPipelineLabel && hasPipelineRunLabel {
return true, pipelineLabel, pipelineRunLabel
}
return false, "", ""
}
func getScheduledTime(pod *corev1.Pod) metav1.Time {
for _, c := range pod.Status.Conditions {
if c.Type == corev1.PodScheduled {
return c.LastTransitionTime
}
}
return metav1.Time{}
}