Skip to content

Commit

Permalink
chore: delete transformed checks from cron
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Jul 10, 2023
1 parent 1e41b4f commit 1eecedd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 4 additions & 7 deletions pkg/db/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,10 @@ func DeleteChecks(id []string) error {
return Gorm.Table("checks").Where("id IN (?)", id).UpdateColumn("deleted_at", time.Now()).Error
}

func GetCanary(id string) (*pkg.Canary, error) {
var model *pkg.Canary
if err := Gorm.Where("id = ?", id).First(&model).Error; err != nil {
return nil, err
}

return model, nil
func GetCanary(id string) (pkg.Canary, error) {
var model pkg.Canary
err := Gorm.Where("id = ?", id).First(&model).Error
return model, err
}

func FindCanaryByID(id string) (*pkg.Canary, error) {
Expand Down
9 changes: 8 additions & 1 deletion pkg/jobs/canary/canary_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func StartScanCanaryConfigs(dataFile string, configFiles []string) {
type CanaryJob struct {
*kommons.Client
Kubernetes kubernetes.Interface
v1.Canary
Canary v1.Canary
DBCanary pkg.Canary
// model pkg.Canary
LogPass bool
LogFail bool
Expand Down Expand Up @@ -111,6 +112,11 @@ func (job CanaryJob) Run() {
logger.Errorf("error deleting transformed checks for canary %s: %v", job.Canary.GetPersistedID(), err)
}

if len(checksToMarkHealthy) > 0 {
// Remove from cron and let the transformed checks repopulate
DeleteCanaryJob(job.DBCanary.ID.String())
}

// Update last runtime map
canaryLastRuntimes.Store(job.Canary.GetPersistedID(), time.Now())
}
Expand Down Expand Up @@ -268,6 +274,7 @@ func SyncCanaryJob(canary v1.Canary) error {
Client: Kommons,
Kubernetes: Kubernetes,
Canary: canary,
DBCanary: dbCanary,
LogPass: canary.IsTrace() || canary.IsDebug() || LogPass,
LogFail: canary.IsTrace() || canary.IsDebug() || LogFail,
}
Expand Down

0 comments on commit 1eecedd

Please sign in to comment.