Skip to content

Commit 1909618

Browse files
committed
cron report ignored pipeline cron
1 parent 548e25e commit 1909618

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

apistructs/pipeline_report.go

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import (
2424
const (
2525
PipelineReportEventMetaKey = "event"
2626
PipelineReportLoopMetaKey = "task-loop"
27+
28+
// PipelineReportSystemPrefixMetaKey pipeline system log report key
29+
PipelineReportSystemPrefixMetaKey = "pipeline-system-"
30+
PipelineReportSystemIgnoreCronKey = PipelineReportSystemPrefixMetaKey + "ignored-cron"
2731
)
2832

2933
// PipelineReportSet 流水线报告集,一条流水线可能会有多个报告,称为报告集

modules/pipeline/services/pipelinesvc/cron.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ func (s *PipelineSvc) RunCronPipelineFunc(id uint64) {
5858

5959
// 如果当前触发时间小于定时开始时间,return
6060
if s.isCronShouldBeIgnored(pc) {
61-
logrus.Warnf("crond: pipelineCronID: %d, triggered but ignored, triggerTime: %s, cronStartFrom: %s",
61+
reason := fmt.Sprintf("crond: pipelineCronID: %d, triggered but ignored, triggerTime: %s, cronStartFrom: %s",
6262
pc.ID, cronTriggerTime, *pc.Extra.CronStartFrom)
63+
logrus.Warnf(reason)
64+
if err := s.reportIgnoredCron(pc, reason); err != nil {
65+
logrus.Errorf("crond: failed to report ignored cron, pipelineCronID: %d, err: %v", pc.ID, err)
66+
}
6367
return
6468
}
6569

@@ -226,3 +230,14 @@ func (s *PipelineSvc) DoCrondAbout(ctx context.Context) {
226230
// 定时补偿
227231
go s.ContinueCompensate(ctx)
228232
}
233+
234+
func (s *PipelineSvc) reportIgnoredCron(pc spec.PipelineCron, reason string) error {
235+
meta := map[string]interface{}{
236+
fmt.Sprintf("%s-%d", apistructs.PipelineReportSystemIgnoreCronKey, pc.ID): pc,
237+
"reason": reason,
238+
}
239+
return s.dbClient.CreatePipelineReport(&spec.PipelineReport{
240+
Type: apistructs.PipelineReportSystemIgnoreCronKey,
241+
Meta: meta,
242+
})
243+
}

0 commit comments

Comments
 (0)