mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
k8s probe: Fix a panic (nil pointer deref) when a cronjob has never been scheduled
in which case cj.Status.LastScheduled is nil. New behaviour is to omit it from the map (and therefore the display) if it has never been scheduled.
This commit is contained in:
@@ -63,11 +63,14 @@ func (cj *cronJob) Selectors() ([]labels.Selector, error) {
|
||||
}
|
||||
|
||||
func (cj *cronJob) GetNode() report.Node {
|
||||
return cj.MetaNode(report.MakeCronJobNodeID(cj.UID())).WithLatests(map[string]string{
|
||||
NodeType: "CronJob",
|
||||
Schedule: cj.Spec.Schedule,
|
||||
Suspended: fmt.Sprint(cj.Spec.Suspend != nil && *cj.Spec.Suspend), // nil -> false
|
||||
LastScheduled: cj.Status.LastScheduleTime.Format(time.RFC3339Nano),
|
||||
ActiveJobs: fmt.Sprint(len(cj.jobs)),
|
||||
})
|
||||
latest := map[string]string{
|
||||
NodeType: "CronJob",
|
||||
Schedule: cj.Spec.Schedule,
|
||||
Suspended: fmt.Sprint(cj.Spec.Suspend != nil && *cj.Spec.Suspend), // nil -> false
|
||||
ActiveJobs: fmt.Sprint(len(cj.jobs)),
|
||||
}
|
||||
if cj.Status.LastScheduleTime != nil {
|
||||
latest[LastScheduled] = cj.Status.LastScheduleTime.Format(time.RFC3339Nano)
|
||||
}
|
||||
return cj.MetaNode(report.MakeCronJobNodeID(cj.UID())).WithLatests(latest)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user