14
14
using BuildXL . Cache . ContentStore . Tracing . Internal ;
15
15
using BuildXL . Cache . Monitor . App . Notifications ;
16
16
using BuildXL . Cache . Monitor . App . Rules ;
17
- using BuildXL . Cache . Monitor . App . Rules . Autoscaling ;
18
17
using BuildXL . Cache . Monitor . App . Rules . Kusto ;
19
18
using BuildXL . Cache . Monitor . App . Scheduling ;
20
- using BuildXL . Cache . Monitor . Library . Az ;
21
19
using BuildXL . Cache . Monitor . Library . IcM ;
22
20
using BuildXL . Cache . Monitor . Library . Notifications ;
23
- using BuildXL . Cache . Monitor . Library . Rules . Autoscaling ;
24
21
using BuildXL . Cache . Monitor . Library . Rules . Kusto ;
25
22
using BuildXL . Cache . Monitor . Library . Scheduling ;
26
23
using Kusto . Cloud . Platform . Utils ;
@@ -67,8 +64,6 @@ public class Configuration
67
64
// Kusto rules always perform some amount of Kusto queries. If we run too many of them at once,
68
65
// we'll overload the cluster and make queries fail.
69
66
{ "Kusto" , 10 } ,
70
- // The autoscaling rules may take arbitrarily long to run, so we keep them on a separate bucket.
71
- { "RedisAutoscaler" , int . MaxValue } ,
72
67
} ,
73
68
} ;
74
69
@@ -174,16 +169,10 @@ private static async Task<EnvironmentResources> CreateEnvironmentResourcesAsync(
174
169
var azure = ExternalDependenciesFactory . CreateAzureClient ( configuration . AzureCredentials ) . ThrowIfFailure ( ) ;
175
170
var monitorManagementClient = await ExternalDependenciesFactory . CreateAzureMetricsClientAsync ( configuration . AzureCredentials ) . ThrowIfFailureAsync ( ) ;
176
171
177
- var redisCaches =
178
- ( await azure
179
- . RedisCaches
180
- . ListAsync ( cancellationToken : context . Token ) )
181
- . ToDictionary ( cache => cache . Name , cache => cache ) ;
182
-
183
172
var kustoClient = ExternalDependenciesFactory . CreateKustoQueryClient ( configuration . KustoCredentials ) . ThrowIfFailure ( ) ;
184
173
185
174
context . Token . ThrowIfCancellationRequested ( ) ;
186
- return new EnvironmentResources ( azure , monitorManagementClient , redisCaches , kustoClient ) ;
175
+ return new EnvironmentResources ( azure , monitorManagementClient , kustoClient ) ;
187
176
}
188
177
189
178
private Monitor ( Configuration configuration , IKustoIngestClient kustoIngestClient , IIcmClient icmClient , IClock clock , IReadOnlyDictionary < MonitorEnvironment , EnvironmentResources > environmentResources , ILogger logger )
@@ -231,16 +220,18 @@ public async Task RunAsync(OperationContext context, Action? onWatchlistChange =
231
220
{
232
221
// This rule takes care of updating the watchlist and triggering the action when it has effectively
233
222
// changed. The action will take care of restarting the entire application.
234
- _scheduler . Add ( new LambdaRule (
235
- identifier : "WatchlistUpdate" ,
236
- concurrencyBucket : "Kusto" ,
237
- lambda : async ( ruleContext ) =>
238
- {
239
- if ( await watchlist . RefreshAsync ( ) )
223
+ _scheduler . Add (
224
+ rule : new LambdaRule (
225
+ identifier : "WatchlistUpdate" ,
226
+ concurrencyBucket : "Kusto" ,
227
+ lambda : async ( ruleContext ) =>
240
228
{
241
- onWatchlistChange ? . Invoke ( ) ;
242
- }
243
- } ) , TimeSpan . FromMinutes ( 30 ) ) ;
229
+ if ( await watchlist . RefreshAsync ( ) )
230
+ {
231
+ onWatchlistChange ? . Invoke ( ) ;
232
+ }
233
+ } ) ,
234
+ pollingPeriod : TimeSpan . FromDays ( 1 ) ) ;
244
235
}
245
236
246
237
Tracer . Info ( context , "Entering scheduler loop" ) ;
@@ -399,16 +390,6 @@ private void CreateSchedule(Watchlist watchlist)
399
390
} ) ;
400
391
} , watchlist ) ;
401
392
402
- OncePerEnvironment ( arguments =>
403
- {
404
- var configuration = new DeploymentsRule . Configuration ( arguments . BaseConfiguration ) ;
405
- return Analysis . Utilities . Yield ( new Instantiation ( )
406
- {
407
- Rule = new DeploymentsRule ( configuration ) ,
408
- PollingPeriod = configuration . AlertPeriod ,
409
- } ) ;
410
- } , watchlist ) ;
411
-
412
393
OncePerEnvironment ( arguments =>
413
394
{
414
395
var configuration = new LongCopyRule . Configuration ( arguments . BaseConfiguration ) ;
@@ -418,85 +399,6 @@ private void CreateSchedule(Watchlist watchlist)
418
399
PollingPeriod = TimeSpan . FromMinutes ( 30 ) ,
419
400
} ) ;
420
401
} , watchlist ) ;
421
-
422
- OncePerEnvironment ( arguments =>
423
- {
424
- var configuration = new MachineReimagesRule . Configuration ( arguments . BaseConfiguration ) ;
425
-
426
- return Analysis . Utilities . Yield ( new Instantiation ( )
427
- {
428
- Rule = new MachineReimagesRule ( configuration ) ,
429
- PollingPeriod = configuration . LookbackPeriod ,
430
- } ) ;
431
- } , watchlist ) ;
432
-
433
- OncePerEnvironment ( arguments =>
434
- {
435
- var configuration = new KeySpaceRule . Configuration ( arguments . BaseConfiguration ) ;
436
-
437
- return Analysis . Utilities . Yield ( new Instantiation ( )
438
- {
439
- Rule = new KeySpaceRule ( configuration ) ,
440
- PollingPeriod = TimeSpan . FromMinutes ( 10 ) ,
441
- } ) ;
442
- } , watchlist ) ;
443
-
444
- OncePerEnvironment ( arguments =>
445
- {
446
- var configuration = new DiskCorruptionRule . Configuration ( arguments . BaseConfiguration ) ;
447
-
448
- return Analysis . Utilities . Yield ( new Instantiation ( )
449
- {
450
- Rule = new DiskCorruptionRule ( configuration ) ,
451
- PollingPeriod = configuration . LookbackPeriod ,
452
- } ) ;
453
- } , watchlist ) ;
454
-
455
- OncePerStamp ( GenerateRedisAutoscalingRules , watchlist ) ;
456
- }
457
-
458
- private IEnumerable < Instantiation > GenerateRedisAutoscalingRules ( SingleStampRuleArguments arguments )
459
- {
460
- if ( ! arguments . DynamicStampProperties . RedisAutoscalingEnabled )
461
- {
462
- yield break ;
463
- }
464
-
465
- if ( ! arguments . EnvironmentResources . RedisCaches . ContainsKey ( arguments . StampId . PrimaryRedisName ) || ! arguments . EnvironmentResources . RedisCaches . ContainsKey ( arguments . StampId . SecondaryRedisName ) )
466
- {
467
- _logger . Error ( $ "Attempt to create Redis autoscaler for stamp `{ arguments . StampId } ` failed due to missing Redis instance. Skipping rule") ;
468
- yield break ;
469
- }
470
-
471
- var autoscalingAgentConfiguration = new RedisAutoscalingAgent . Configuration ( ) ;
472
- if ( arguments . DynamicStampProperties . RedisAutoscalingMaximumClusterMemoryAllowedMb > 0 )
473
- {
474
- autoscalingAgentConfiguration . MaximumClusterMemoryAllowedMb = arguments . DynamicStampProperties . RedisAutoscalingMaximumClusterMemoryAllowedMb ;
475
- }
476
-
477
- var azureMetricsClient = new AzureMetricsClient ( arguments . EnvironmentResources . MonitorManagementClient ) ;
478
- var redisAutoscalingAgent = new RedisAutoscalingAgent ( autoscalingAgentConfiguration , azureMetricsClient ) ;
479
- var configuration = new RedisAutoscalingRule . Configuration ( arguments . BaseConfiguration ) ;
480
-
481
- var primaryRedisInstance = RedisInstance
482
- . FromPreloaded (
483
- arguments . EnvironmentResources . Azure ,
484
- arguments . EnvironmentResources . RedisCaches [ arguments . StampId . PrimaryRedisName ] ,
485
- readOnly : _configuration . ReadOnly )
486
- . ThrowIfFailure ( ) ;
487
-
488
- var secondaryRedisInstance = RedisInstance
489
- . FromPreloaded (
490
- arguments . EnvironmentResources . Azure ,
491
- arguments . EnvironmentResources . RedisCaches [ arguments . StampId . SecondaryRedisName ] ,
492
- readOnly : _configuration . ReadOnly )
493
- . ThrowIfFailure ( ) ;
494
-
495
- yield return new Instantiation
496
- {
497
- Rule = new RedisAutoscalingRule ( configuration , redisAutoscalingAgent , primaryRedisInstance , secondaryRedisInstance ) ,
498
- PollingPeriod = TimeSpan . FromMinutes ( 10 ) ,
499
- } ;
500
402
}
501
403
502
404
/// <summary>
0 commit comments