|
22 | 22 | using BuildXL.Cache.ContentStore.Interfaces.Stores;
|
23 | 23 | using BuildXL.Cache.ContentStore.Interfaces.Time;
|
24 | 24 | using BuildXL.Cache.ContentStore.Interfaces.Tracing;
|
| 25 | +using BuildXL.Cache.ContentStore.Service.Grpc; |
25 | 26 | using BuildXL.Cache.ContentStore.Stores;
|
26 | 27 | using BuildXL.Cache.ContentStore.Tracing;
|
27 | 28 | using BuildXL.Cache.ContentStore.Tracing.Internal;
|
@@ -399,7 +400,7 @@ IEnumerable<ContentEvictionInfo> getReplicableHashes()
|
399 | 400 | reason: CopyReason.ProactiveBackground);
|
400 | 401 |
|
401 | 402 | wasPreviousCopyNeeded = true;
|
402 |
| - switch (GetProactiveReplicationStatus(result)) |
| 403 | + switch (GetProactiveBackgroundReplicationStatus(result)) |
403 | 404 | {
|
404 | 405 | case ProactivePushStatus.Success:
|
405 | 406 | CounterCollection[Counters.ProactiveReplication_Succeeded].Increment();
|
@@ -437,28 +438,30 @@ IEnumerable<ContentEvictionInfo> getReplicableHashes()
|
437 | 438 | counter: CounterCollection[Counters.ProactiveReplication]);
|
438 | 439 | }
|
439 | 440 |
|
440 |
| - private ProactivePushStatus GetProactiveReplicationStatus(ProactiveCopyResult result) |
| 441 | + private static ProactivePushStatus GetProactiveBackgroundReplicationStatus(ProactiveCopyResult result) |
441 | 442 | {
|
442 |
| - // When both Inside and Outside Copy fails, that is considered as failure |
443 |
| - if (result.InsideRingCopyResult?.Succeeded != true && result.OutsideRingCopyResult?.Succeeded != true) |
444 |
| - { |
445 |
| - return ProactivePushStatus.Error; |
446 |
| - } |
| 443 | + // For background replication, we only attempt outside-ring replication, so we only examine the outside ring result |
| 444 | + ProactivePushResult? outsideResult = result.OutsideRingCopyResult; |
447 | 445 |
|
448 |
| - // Status is skipped when both Inside and Outside Copy was disabled or when Copy wasn't required in either ring |
449 |
| - if (result.Skipped) |
| 446 | + // Outside result being null indicates the that no push was attempted, ususally because content appears already sufficiently replicated |
| 447 | + if (outsideResult is null) |
450 | 448 | {
|
451 | 449 | return ProactivePushStatus.Skipped;
|
452 | 450 | }
|
453 | 451 |
|
454 |
| - // Status is Rejected when both Inside and Outside Copy was rejected |
455 |
| - if (result.InsideRingCopyResult?.Rejected == true || result.OutsideRingCopyResult?.Rejected == true) |
| 452 | + // Test for rejected explicitly first, otherwise it will appear as success or error |
| 453 | + if (outsideResult.Rejected) |
456 | 454 | {
|
457 | 455 | return ProactivePushStatus.Rejected;
|
458 | 456 | }
|
459 | 457 |
|
460 |
| - // All other cases are considered success |
461 |
| - return ProactivePushStatus.Success; |
| 458 | + if (outsideResult.Succeeded) |
| 459 | + { |
| 460 | + return ProactivePushStatus.Success; |
| 461 | + } |
| 462 | + |
| 463 | + return ProactivePushStatus.Error; |
| 464 | + |
462 | 465 | }
|
463 | 466 |
|
464 | 467 | /// <inheritdoc />
|
|
0 commit comments