Skip to content

Commit

Permalink
Merge pull request #2089 from opengovern/fix-add-linode
Browse files Browse the repository at this point in the history
fix: ignore not found error for delete old resources
  • Loading branch information
artaasadi authored Dec 1, 2024
2 parents cc620d1 + b2d0103 commit 1f730dd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions services/describe/scheduler_describe_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ func (s *Scheduler) cleanupDescribeResourcesNotInIntegrations(ctx context.Contex
resource.EsIndex = idx
err = s.es.Delete(key, idx)
if err != nil {
s.logger.Error("failed to delete resource from open-search", zap.Error(err))
if !strings.Contains(err.Error(), "404 Not Found") {
s.logger.Error("failed to delete resource from open-search", zap.Error(err))
}
}

lookupResource := es2.LookupResource{
Expand All @@ -302,7 +304,9 @@ func (s *Scheduler) cleanupDescribeResourcesNotInIntegrations(ctx context.Contex
lookupResource.EsIndex = idx
err = s.es.Delete(key, idx)
if err != nil {
s.logger.Error("failed to delete lookup from open-search", zap.Error(err))
if !strings.Contains(err.Error(), "404 Not Found") {
s.logger.Error("failed to delete lookup from open-search", zap.Error(err))
}
}

resourceFinding := types.ResourceFinding{
Expand All @@ -316,9 +320,13 @@ func (s *Scheduler) cleanupDescribeResourcesNotInIntegrations(ctx context.Contex
resourceFinding.EsIndex = idx
err = s.es.Delete(key, idx)
if err != nil {
s.logger.Error("failed to delete resource finding from open-search", zap.Error(err))
if !strings.Contains(err.Error(), "404 Not Found") {
s.logger.Error("failed to delete resource finding from open-search", zap.Error(err))
}
}
}
s.logger.Info("deleted resource count", zap.Int("count", totalDeletedCount),
zap.Any("deleted integrations", deletedIntegrationIDs))
}
s.logger.Info("total deleted resource count", zap.Int("count", totalDeletedCount),
zap.Any("deleted integrations", deletedIntegrationIDs))
Expand Down

0 comments on commit 1f730dd

Please sign in to comment.