Repository: telstra/open-kilda
Issue: flows are not rerouted by flowMonitoring in case main path does not satisfy SLA (shrad_count > 1)

**Steps to reproduce:**

1. update `confd/vars/main.yaml`
```
kilda_flow_sla_check_shard_count: 2
```
2. build and start env with updated value;
3. create 3 the same flows with the `max_latency` strategy;
4. make sure that the path of all 3 flows are the same;
5. update path ( path does not satisfy SLA)

**Expected result:**
All 3 flows are rerouted due to `"details": "Reason: Flow latency become healthy",`


**Actual result:**
sometimes only one flow is rerouted, the rest flows are untouched


**NOTE:**
The issue can be reproduced by autotest `def "Able to detect and reroute a flow with MAX_LATENCY strategy when main path does not satisfy latency SLA"() {` from the `test/repr_issue_with_fl_monitoring_shard_count` branch (pr #4811 )

Changed files:
src-java/flowmonitoring-topology/flowmonitoring-storm-topology/src/main/java/org/openkilda/wfm/topology/flowmonitoring/fsm/FlowLatencyMonitoringFsm.java

diff --git a/src-java/flowmonitoring-topology/flowmonitoring-storm-topology/src/main/java/org/openkilda/wfm/topology/flowmonitoring/fsm/FlowLatencyMonitoringFsm.java b/src-java/flowmonitoring-topology/flowmonitoring-storm-topology/src/main/java/org/openkilda/wfm/topology/flowmonitoring/fsm/FlowLatencyMonitoringFsm.java
index 3157b17b2..0eee8aed5 100644
--- a/src-java/flowmonitoring-topology/flowmonitoring-storm-topology/src/main/java/org/openkilda/wfm/topology/flowmonitoring/fsm/FlowLatencyMonitoringFsm.java
+++ b/src-java/flowmonitoring-topology/flowmonitoring-storm-topology/src/main/java/org/openkilda/wfm/topology/flowmonitoring/fsm/FlowLatencyMonitoringFsm.java
@@ -125,7 +125,19 @@ public class FlowLatencyMonitoringFsm extends AbstractBaseFsm<FlowLatencyMonitor
     }
 
     public void enterUnstable(State from, State to, Event event, Context context) {
-        saveLastEventInfo(lastStableState);
+        switch (event) {
+            case HEALTHY:
+                saveLastEventInfo(HEALTHY);
+                break;
+            case TIER_1_FAILED:
+                saveLastEventInfo(TIER_1_FAILED);
+                break;
+            case TIER_2_FAILED:
+                saveLastEventInfo(TIER_2_FAILED);
+                break;
+            default:
+                throw new IllegalArgumentException(format("Wrong event type '%s' for unstable state.", event));
+        }
     }
 
     public void saveHealthyEventInfo(State from, State to, Event event, Context context) {
@@ -156,13 +168,17 @@ public class FlowLatencyMonitoringFsm extends AbstractBaseFsm<FlowLatencyMonitor
     }
 
     public void sendFlowSyncRequest(State from, State to, Event event, Context context) {
-        log.info("Flow {} {} latency moved to healthy.", flowId, direction);
-        context.getCarrier().sendFlowSyncRequest(flowId);
+        if (lastStableState != HEALTHY) {
+            log.info("Flow {} {} latency moved to healthy.", flowId, direction);
+            context.getCarrier().sendFlowSyncRequest(flowId);
+        }
     }
 
     public void sendFlowRerouteRequest(State from, State to, Event event, Context context) {
-        log.info("Flow {} {} latency moved to unhealthy.", flowId, direction);
-        context.getCarrier().sendFlowRerouteRequest(flowId);
+        if (lastStableState != TIER_1_FAILED && lastStableState != TIER_2_FAILED) {
+            log.info("Flow {} {} latency moved to unhealthy.", flowId, direction);
+            context.getCarrier().sendFlowRerouteRequest(flowId);
+        }
     }
 
     public void saveTier2FailedEventInfo(State from, State to, Event event, Context context) {
@@ -296,10 +312,6 @@ public class FlowLatencyMonitoringFsm extends AbstractBaseFsm<FlowLatencyMonitor
         return maxLatencyTier2;
     }
 
-    public State getLastStableState() {
-        return lastStableState;
-    }
-
     @Value
     @Builder
     public static class Context {