Skip to content

Commit

Permalink
fix: don't cache deleted configs
Browse files Browse the repository at this point in the history
On the aws cluster, we had two HelmReleases (any many other duplicates)
under the same scraper with same KNN & external ids. One of them is
deleted & the other is active.

On cache init, we would fetch both the helm releases but the older
(deleted) one would replace the active one in the cache.
  • Loading branch information
adityathebe committed Jul 16, 2024
1 parent 5fae642 commit d492ba1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func QueryCache(ctx context.Context, query string, args ...interface{}) (*TempCa
aliases: make(map[string]string),
}
items := []models.ConfigItem{}
if err := ctx.DB().Table("config_items").Where(query, args...).Find(&items).Error; err != nil {
if err := ctx.DB().Table("config_items").Where("deleted_at IS NULL").Where(query, args...).Find(&items).Error; err != nil {
return nil, err
}
for _, item := range items {
Expand Down
1 change: 1 addition & 0 deletions api/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (ctx ScrapeContext) withTempCache(cache *TempCache) ScrapeContext {
ctx.temp = cache
return ctx
}

func (ctx ScrapeContext) InitTempCache() (ScrapeContext, error) {
if ctx.ScrapeConfig().GetPersistedID() == nil {
cache, err := QueryCache(ctx.Context, "scraper_id IS NULL")
Expand Down

0 comments on commit d492ba1

Please sign in to comment.