@@ -365,27 +365,32 @@ func (s *GRPC) UpdateScheduler(ctx context.Context, req *manager.UpdateScheduler
365
365
}
366
366
367
367
func (s * GRPC ) ListSchedulers (ctx context.Context , req * manager.ListSchedulersRequest ) (* manager.ListSchedulersResponse , error ) {
368
+ log := logger .WithHostnameAndIP (req .HostName , req .Ip )
369
+
368
370
var pbListSchedulersResponse manager.ListSchedulersResponse
369
371
cacheKey := cache .MakeSchedulersCacheKey (req .HostName , req .Ip )
370
372
371
373
// Cache Hit
372
374
if err := s .cache .Get (ctx , cacheKey , & pbListSchedulersResponse ); err == nil {
373
- logger .Infof ("%s cache hit" , cacheKey )
375
+ log .Infof ("%s cache hit" , cacheKey )
374
376
return & pbListSchedulersResponse , nil
375
377
}
376
378
377
379
// Cache Miss
378
- logger .Infof ("%s cache miss" , cacheKey )
380
+ log .Infof ("%s cache miss" , cacheKey )
379
381
var schedulerClusters []model.SchedulerCluster
380
382
if err := s .db .WithContext (ctx ).Preload ("SecurityGroup.SecurityRules" ).Preload ("Schedulers" , "state = ?" , "active" ).Find (& schedulerClusters ).Error ; err != nil {
381
383
return nil , status .Error (codes .Unknown , err .Error ())
382
384
}
383
385
384
386
// Search optimal scheduler cluster
387
+ log .Infof ("list scheduler clusters %+v with hostInfo %+v" , schedulerClusters , req .HostInfo )
385
388
schedulerCluster , ok := s .searcher .FindSchedulerCluster (ctx , schedulerClusters , req )
386
389
if ! ok {
390
+ log .Errorf ("can not matching scheduler cluster" )
387
391
return nil , status .Error (codes .NotFound , "scheduler cluster not found" )
388
392
}
393
+ log .Infof ("find matching scheduler cluster %v" , schedulerCluster )
389
394
390
395
schedulers := []model.Scheduler {}
391
396
if err := s .db .WithContext (ctx ).Find (& schedulers , & model.Scheduler {
@@ -421,7 +426,7 @@ func (s *GRPC) ListSchedulers(ctx context.Context, req *manager.ListSchedulersRe
421
426
Value : & pbListSchedulersResponse ,
422
427
TTL : s .cache .TTL ,
423
428
}); err != nil {
424
- logger .Warnf ("storage cache failed: %v" , err )
429
+ log .Warnf ("storage cache failed: %v" , err )
425
430
}
426
431
427
432
return & pbListSchedulersResponse , nil
0 commit comments