@@ -370,6 +370,7 @@ static void validateAllSearchableSnapshotActionsUseSameRepository(Collection<Pha
370370 */
371371 public static String validateMonotonicallyIncreasingPhaseTimings (Collection <Phase > phases ) {
372372 List <String > errors = new ArrayList <>();
373+ Set <String > invalidPhases = new HashSet <>();
373374
374375 // Loop through all phases in order, for each phase with a min_age
375376 // configured, look at all the future phases to see if their ages are
@@ -385,6 +386,12 @@ public static String validateMonotonicallyIncreasingPhaseTimings(Collection<Phas
385386
386387 if (maybePhase .isPresent ()) {
387388 Phase phase = maybePhase .get ();
389+ // We only consider a phase bad once, otherwise we can duplicate
390+ // errors, so we keep track of the invalid phases we've seen and
391+ // ignore them if they come around again.
392+ if (invalidPhases .contains (phase .getName ())) {
393+ continue ;
394+ }
388395 TimeValue phaseMinAge = phase .getMinimumAge ();
389396 Set <String > followingPhases = new HashSet <>(ORDERED_VALID_PHASES .subList (i + 1 , ORDERED_VALID_PHASES .size ()));
390397 Set <Phase > phasesWithBadAges = phases .stream ()
@@ -393,6 +400,7 @@ public static String validateMonotonicallyIncreasingPhaseTimings(Collection<Phas
393400 .filter (p -> p .getMinimumAge ().compareTo (phaseMinAge ) < 0 )
394401 .collect (Collectors .toSet ());
395402 if (phasesWithBadAges .size () > 0 ) {
403+ phasesWithBadAges .forEach (p -> invalidPhases .add (p .getName ()));
396404 errors .add ("phases [" + phasesWithBadAges .stream ().map (Phase ::getName ).collect (Collectors .joining ("," )) +
397405 "] configure a [min_age] value less than the [min_age] of [" + phase .getMinimumAge () +
398406 "] for the [" + phaseName + "] phase, configuration: " +
0 commit comments