Merge pull request #3683 from chaunceyjiang/cronjob

fix panic when printing log when lastSuccessfulTime of cronjob is nil
This commit is contained in:
karmada-bot 2023-06-20 14:26:47 +08:00 committed by GitHub
commit 1791270cbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -214,8 +214,8 @@ func aggregateCronJobStatus(object *unstructured.Unstructured, aggregatedStatusI
if err = json.Unmarshal(item.Status.Raw, temp); err != nil {
return nil, err
}
klog.V(3).Infof("Grab cronJob(%s/%s) status from cluster(%s), active: %+v, lastScheduleTime: %s, lastSuccessfulTime: %s",
cronjob.Namespace, cronjob.Name, item.ClusterName, temp.Active, temp.LastScheduleTime.String(), temp.LastSuccessfulTime.String())
klog.V(3).Infof("Grab cronJob(%s/%s) status from cluster(%s), active: %+v, lastScheduleTime: %+v, lastSuccessfulTime: %+v",
cronjob.Namespace, cronjob.Name, item.ClusterName, temp.Active, temp.LastScheduleTime, temp.LastSuccessfulTime)
newStatus.Active = append(newStatus.Active, temp.Active...)
if newStatus.LastScheduleTime == nil {
newStatus.LastScheduleTime = temp.LastScheduleTime

View File

@ -995,7 +995,7 @@ func Test_aggregateCronJobStatus(t *testing.T) {
},
},
"lastScheduleTime": "2023-02-08T07:16:00Z",
"lastSuccessfulTime": "2023-02-08T07:15:00Z",
"lastSuccessfulTime": nil,
})
cronjobStatusRaw2, _ := helper.BuildStatusRawExtension(map[string]interface{}{
"active": []corev1.ObjectReference{