4141import java .util .List ;
4242import java .util .Map ;
4343import java .util .Set ;
44+ import java .util .concurrent .ConcurrentHashMap ;
4445import java .util .concurrent .ConcurrentSkipListSet ;
4546import java .util .concurrent .atomic .AtomicBoolean ;
4647import java .util .function .Function ;
@@ -205,13 +206,11 @@ Collection<DoubleWithAttributes> observeDouble(Function<AdaptiveAllocationsScale
205206 private Long lastInferenceStatsTimestampMillis ;
206207 private final Map <String , AdaptiveAllocationsScaler > scalers ;
207208 private final Map <String , Long > lastScaleUpTimesMillis ;
208-
209209 private volatile Scheduler .Cancellable cancellable ;
210210 private final AtomicBoolean busy ;
211-
212211 private final long scaleToZeroAfterNoRequestsSeconds ;
213-
214212 private final Set <String > deploymentIdsWithInFlightScaleFromZeroRequests = new ConcurrentSkipListSet <>();
213+ private final Map <String , String > lastWarningMessages = new ConcurrentHashMap <>();
215214
216215 public AdaptiveAllocationsScalerService (
217216 ThreadPool threadPool ,
@@ -475,7 +474,8 @@ private ActionListener<CreateTrainedModelAssignmentAction.Response> updateAssigm
475474 int numberOfAllocations
476475 ) {
477476 return ActionListener .wrap (updateResponse -> {
478- logger .debug ("adaptive allocations scaler: scaled [{}] to [{}] allocations." , deploymentId , numberOfAllocations );
477+ lastWarningMessages .remove (deploymentId );
478+ logger .info ("adaptive allocations scaler: scaled [{}] to [{}] allocations." , deploymentId , numberOfAllocations );
479479 threadPool .executor (MachineLearning .UTILITY_THREAD_POOL_NAME )
480480 .execute (
481481 () -> inferenceAuditor .info (
@@ -484,20 +484,24 @@ private ActionListener<CreateTrainedModelAssignmentAction.Response> updateAssigm
484484 )
485485 );
486486 }, e -> {
487- logger .atLevel (Level .WARN )
487+ Level level = e .getMessage ().equals (lastWarningMessages .get (deploymentId )) ? Level .DEBUG : Level .WARN ;
488+ lastWarningMessages .put (deploymentId , e .getMessage ());
489+ logger .atLevel (level )
488490 .withThrowable (e )
489491 .log ("adaptive allocations scaler: scaling [{}] to [{}] allocations failed." , deploymentId , numberOfAllocations );
490- threadPool .executor (MachineLearning .UTILITY_THREAD_POOL_NAME )
491- .execute (
492- () -> inferenceAuditor .warning (
493- deploymentId ,
494- Strings .format (
495- "adaptive allocations scaler: scaling [%s] to [%s] allocations failed." ,
492+ if (level == Level .WARN ) {
493+ threadPool .executor (MachineLearning .UTILITY_THREAD_POOL_NAME )
494+ .execute (
495+ () -> inferenceAuditor .warning (
496496 deploymentId ,
497- numberOfAllocations
497+ Strings .format (
498+ "adaptive allocations scaler: scaling [%s] to [%s] allocations failed." ,
499+ deploymentId ,
500+ numberOfAllocations
501+ )
498502 )
499- )
500- );
503+ );
504+ }
501505 });
502506 }
503507}
0 commit comments