Skip to content

Commit

Permalink
fix: fix compliance job timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Dec 17, 2024
1 parent c1fa50a commit 82dd6ae
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assets/integrations/integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"SourceCode": "https://github.com/opengovern/og-describer-github",
"schema_ids": ["github"],
"PackageURL": "ghcr.io/opengovern/og-describer-github",
"PackageTag": "local-v0.3.9"
"PackageTag": "local-v0.4.0"
},
{
"id": 5,
Expand Down
3 changes: 2 additions & 1 deletion services/describe/db/compliance_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ func (db Database) UpdateComplianceJobAreAllRunnersQueued(id uint, areAllRunners
return nil
}

func (db Database) UpdateComplianceJobsTimedOut(complianceIntervalHours int64) error {
func (db Database) UpdateComplianceJobsTimedOut(withIncidents bool, complianceIntervalHours int64) error {
tx := db.ORM.
Model(&model.ComplianceJob{}).
Where("with_incidents = ?", withIncidents).
Where(fmt.Sprintf("created_at < NOW() - INTERVAL '%d MINUTES'", complianceIntervalHours)).
Where("status IN ?", []string{string(model.ComplianceJobCreated),
string(model.ComplianceJobRunnersInProgress),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (s *JobScheduler) runPublisher(ctx context.Context) error {

s.logger.Info("Query Runner publisher started")

err := s.db.UpdateComplianceJobsTimedOut(20)
err := s.db.UpdateComplianceJobsTimedOut(false, 20)
if err != nil {
s.logger.Error("failed to update timed out query runners", zap.Error(err))
}
Expand Down
2 changes: 1 addition & 1 deletion services/describe/schedulers/compliance/summarizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *JobScheduler) runSummarizer(ctx context.Context, manuals bool) error {
return err
}

err = s.db.UpdateComplianceJobsTimedOut(24 * 60)
err = s.db.UpdateComplianceJobsTimedOut(true, 24*60)
if err != nil {
s.logger.Error("failed to update compliance jobs timed out", zap.Error(err))
return err
Expand Down

0 comments on commit 82dd6ae

Please sign in to comment.