@@ -247,9 +247,9 @@ func (s *ChefIngestServer) ProcessNodeDelete(ctx context.Context,
247
247
return & response.ProcessNodeDeleteResponse {}, nil
248
248
}
249
249
250
- func (s * ChefIngestServer ) GetIndicesEligableForReindexing () (map [string ]backend.IndexSettingsVersion , error ) {
250
+ func (s * ChefIngestServer ) GetIndicesEligableForReindexing (ctx context. Context ) (map [string ]backend.IndexSettingsVersion , error ) {
251
251
var eligableIndices = make (map [string ]backend.IndexSettingsVersion )
252
- indices , err := s .client .GetIndices (context . Background () )
252
+ indices , err := s .client .GetIndices (ctx )
253
253
if err != nil {
254
254
return nil , status .Errorf (codes .Internal , "failed to fetch indices: %s" , err )
255
255
}
@@ -277,13 +277,18 @@ OuterLoop:
277
277
eligableIndices [index .Index ] = * versionSettings
278
278
}
279
279
280
+ if len (eligableIndices ) == 0 {
281
+ log .Info ("No indices are eligable for reindexing" )
282
+ return nil , status .Errorf (codes .NotFound , "no indices are eligable for reindexing" )
283
+ }
284
+
280
285
return eligableIndices , nil
281
286
}
282
287
283
288
func (s * ChefIngestServer ) StartReindex (ctx context.Context , req * ingest.StartReindexRequest ) (* ingest.StartReindexResponse , error ) {
284
289
log .Info ("Received request to start reindexing" )
285
290
286
- indices , err := s .GetIndicesEligableForReindexing ()
291
+ indices , err := s .GetIndicesEligableForReindexing (ctx )
287
292
288
293
if err != nil {
289
294
return nil , status .Errorf (codes .Internal , "failed to fetch indices: %s" , err )
0 commit comments