Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: delete transformed checks from cron #1136

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions pkg/db/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ func PersistCheck(check pkg.Check, canaryID uuid.UUID) (uuid.UUID, error) {
"deleted_at": nil,
}

// Deletions for transformed checks are handled separately
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moshloop
Not sure why we put this, removing it

if check.Transformed {
delete(assignments, "deleted_at")
}
tx := Gorm.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "canary_id"}, {Name: "type"}, {Name: "name"}, {Name: "agent_id"}},
DoUpdates: clause.Assignments(assignments),
Expand Down Expand Up @@ -178,13 +174,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
8 changes: 5 additions & 3 deletions 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will use DB object from now on, will slowly deprecate uses of the old spec

// model pkg.Canary
LogPass bool
LogFail bool
Expand Down Expand Up @@ -216,7 +217,7 @@ type CanaryStatusPayload struct {

func findCronEntry(id string) *cron.Entry {
for _, entry := range CanaryScheduler.Entries() {
if entry.Job.(CanaryJob).GetPersistedID() == id {
if entry.Job.(CanaryJob).Canary.GetPersistedID() == id {
return &entry
}
}
Expand Down Expand Up @@ -268,6 +269,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 Expand Up @@ -361,7 +363,7 @@ func DeleteCanaryJob(id string) {
}

func ReconcileDeletedCanaryChecks() {
jobHistory := models.NewJobHistory("ReconcileDeletedTopologyComponents", "", "").Start()
jobHistory := models.NewJobHistory("ReconcileDeletedCanaryChecks", "", "").Start()
_ = db.PersistJobHistory(jobHistory)
defer func() { _ = db.PersistJobHistory(jobHistory.End()) }()

Expand Down
Loading