Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new workflow path in rerouting FSMs to skip rerouting #5526

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ public Factory(@NonNull HaFlowRerouteHubCarrier carrier, @NonNull Config config,
builder.transition().from(State.PROTECTED_RESOURCES_ALLOCATED).to(State.MARKED_FLOW_DOWN_OR_DEGRADED)
.on(Event.NO_PATH_FOUND)
.perform(new OnNoPathFoundAction(persistenceManager, dashboardLogger, false));
builder.transition().from(State.MARKED_FLOW_DOWN_OR_DEGRADED).to(State.RESOURCE_ALLOCATION_COMPLETED)
.on(Event.NEXT)
builder.transitions().from(State.MARKED_FLOW_DOWN_OR_DEGRADED)
.toAmong(State.RESOURCE_ALLOCATION_COMPLETED, State.RESOURCE_ALLOCATION_COMPLETED)
.onEach(Event.NEXT, Event.REROUTE_IS_NOT_REQUIRED)
.perform(new PostResourceAllocationAction(persistenceManager));
builder.transitions().from(State.PROTECTED_RESOURCES_ALLOCATED)
.toAmong(State.REVERTING_ALLOCATED_RESOURCES, State.REVERTING_ALLOCATED_RESOURCES)
Expand All @@ -209,8 +210,10 @@ public Factory(@NonNull HaFlowRerouteHubCarrier carrier, @NonNull Config config,
.on(Event.NEXT)
.perform(new BuildNewRulesAction(persistenceManager, ruleManager));
builder.transition().from(State.RESOURCE_ALLOCATION_COMPLETED).to(State.NOTIFY_FLOW_MONITOR_WITH_ERROR)
.on(Event.REROUTE_IS_SKIPPED)
.on(Event.REROUTE_IS_SKIPPED_ERROR)
.perform(new RevertFlowStatusAction(persistenceManager));
builder.transition().from(State.RESOURCE_ALLOCATION_COMPLETED).to(State.NOTIFY_FLOW_MONITOR)
.on(Event.REROUTE_IS_NOT_REQUIRED);
builder.transitions().from(State.RESOURCE_ALLOCATION_COMPLETED)
.toAmong(State.REVERTING_ALLOCATED_RESOURCES, State.REVERTING_ALLOCATED_RESOURCES)
.onEach(Event.TIMEOUT, Event.ERROR);
Expand Down Expand Up @@ -486,7 +489,8 @@ public enum Event {
NEXT,

NO_PATH_FOUND,
REROUTE_IS_SKIPPED,
REROUTE_IS_SKIPPED_ERROR,
REROUTE_IS_NOT_REQUIRED,

RESPONSE_RECEIVED,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openkilda.wfm.topology.flowhs.service.history.HaFlowHistory;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.Optional;

Expand All @@ -54,7 +55,7 @@ public void perform(
HaFlowHistory haFlowHistory = HaFlowHistory.of(stateMachine.getCommandContext().getCorrelationId())
.withHaFlowId(stateMachine.getHaFlowId());

if (stateMachine.getNewHaFlowStatus() == FlowStatus.UP) {
if (stateMachine.getNewHaFlowStatus() == FlowStatus.UP && StringUtils.isEmpty(stateMachine.getErrorReason())) {
dashboardLogger.onSuccessfulHaFlowReroute(stateMachine.getHaFlowId());
haFlowHistory.withAction("HA-flow has been rerouted successfully");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.openkilda.wfm.topology.flowhs.fsm.haflow.reroute.HaFlowRerouteFsm.Event;
import org.openkilda.wfm.topology.flowhs.fsm.haflow.reroute.HaFlowRerouteFsm.State;
import org.openkilda.wfm.topology.flowhs.model.CrossingPaths;
import org.openkilda.wfm.topology.flowhs.service.history.FlowHistoryService;
import org.openkilda.wfm.topology.flowhs.service.history.HaFlowHistory;

import lombok.extern.slf4j.Slf4j;

Expand All @@ -60,7 +62,17 @@ protected Optional<Message> performWithResponse(State from, State to, Event even
HaFlowPath currentForwardPath = stateMachine.getOriginalHaFlow().getForwardPath();

if (stateMachine.getNewPrimaryPathIds() == null && stateMachine.getNewProtectedPathIds() == null) {
stateMachine.fireError(Event.REROUTE_IS_SKIPPED, "Reroute is unsuccessful. Couldn't find new path(s)");
if (stateMachine.getOriginalFlowStatus() == FlowStatus.UP) {
FlowHistoryService.using(stateMachine.getCarrier()).save(HaFlowHistory
.of(stateMachine.getCommandContext().getCorrelationId())
.withAction(
"Rerouting is skipped because the HA-flow is already in UP status and no new paths found"));
stateMachine.setNewHaFlowStatus(stateMachine.getOriginalFlowStatus());
stateMachine.setErrorReason("No errors. Rerouting is skipped");
stateMachine.fire(Event.REROUTE_IS_NOT_REQUIRED);
} else {
stateMachine.fireError(Event.REROUTE_IS_SKIPPED_ERROR, "Couldn't find new paths");
}
} else {
if (stateMachine.isEffectivelyDown()) {
log.warn("HA-flow {} is mentioned as effectively DOWN, so it will be forced to DOWN state if reroute "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ public void fireNoPathFound(String errorReason) {
fireError(Event.NO_PATH_FOUND, errorReason);
}

public void fireRerouteIsSkipped(String errorReason) {
fireError(Event.REROUTE_IS_SKIPPED, errorReason);
public void fireErrorRerouteIsSkipped(String errorReason) {
fireError(Event.REROUTE_IS_SKIPPED_ERROR, errorReason);
}

public void setRerouteError(RerouteError rerouteError) {
Expand Down Expand Up @@ -214,8 +214,9 @@ public Factory(@NonNull FlowRerouteHubCarrier carrier, @NonNull Config config,
builder.transition().from(State.PROTECTED_RESOURCES_ALLOCATED).to(State.MARKED_FLOW_DOWN_OR_DEGRADED)
.on(Event.NO_PATH_FOUND)
.perform(new OnNoPathFoundAction(persistenceManager, dashboardLogger, false));
builder.transition().from(State.MARKED_FLOW_DOWN_OR_DEGRADED).to(State.RESOURCE_ALLOCATION_COMPLETED)
.on(Event.NEXT)
builder.transitions().from(State.MARKED_FLOW_DOWN_OR_DEGRADED)
.toAmong(State.RESOURCE_ALLOCATION_COMPLETED, State.RESOURCE_ALLOCATION_COMPLETED)
.onEach(Event.NEXT, Event.REROUTE_IS_NOT_REQUIRED)
.perform(new PostResourceAllocationAction(persistenceManager));
builder.transitions().from(State.PROTECTED_RESOURCES_ALLOCATED)
.toAmong(State.REVERTING_ALLOCATED_RESOURCES, State.REVERTING_ALLOCATED_RESOURCES)
Expand All @@ -224,8 +225,11 @@ public Factory(@NonNull FlowRerouteHubCarrier carrier, @NonNull Config config,
builder.transition().from(State.RESOURCE_ALLOCATION_COMPLETED).to(State.INSTALLING_NON_INGRESS_RULES)
.on(Event.NEXT)
.perform(new InstallNonIngressRulesAction(persistenceManager, resourcesManager));
builder.transition().from(State.RESOURCE_ALLOCATION_COMPLETED).to(State.NOTIFY_FLOW_MONITOR)
.on(Event.REROUTE_IS_NOT_REQUIRED)
.perform(new RevertFlowStatusAction(persistenceManager));
builder.transition().from(State.RESOURCE_ALLOCATION_COMPLETED).to(State.NOTIFY_FLOW_MONITOR_WITH_ERROR)
.on(Event.REROUTE_IS_SKIPPED)
.on(Event.REROUTE_IS_SKIPPED_ERROR)
.perform(new RevertFlowStatusAction(persistenceManager));
builder.transitions().from(State.RESOURCE_ALLOCATION_COMPLETED)
.toAmong(State.REVERTING_ALLOCATED_RESOURCES, State.REVERTING_ALLOCATED_RESOURCES)
Expand Down Expand Up @@ -546,7 +550,8 @@ public enum Event {
NEXT,

NO_PATH_FOUND,
REROUTE_IS_SKIPPED,
REROUTE_IS_SKIPPED_ERROR,
REROUTE_IS_NOT_REQUIRED,

RESPONSE_RECEIVED,
ERROR_RECEIVED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package org.openkilda.wfm.topology.flowhs.fsm.reroute.actions;

import static org.openkilda.wfm.topology.flowhs.fsm.reroute.FlowRerouteFsm.Event.REROUTE_IS_NOT_REQUIRED;

import org.openkilda.messaging.Message;
import org.openkilda.messaging.error.ErrorType;
import org.openkilda.messaging.info.InfoMessage;
Expand Down Expand Up @@ -68,7 +70,16 @@ protected Optional<Message> performWithResponse(State from, State to, Event even
&& stateMachine.getNewProtectedForwardPath() == null
&& stateMachine.getNewProtectedReversePath() == null) {
stateMachine.setOperationResultMessage(rerouteResponse);
stateMachine.fireRerouteIsSkipped("Reroute is unsuccessful. Couldn't find new path(s)");

if (stateMachine.getOriginalFlowStatus() == FlowStatus.UP) {
stateMachine.saveActionToHistory(
"Rerouting is skipped because the flow is already in UP status and no new paths found");
stateMachine.setErrorReason("No errors. Rerouting is skipped.");
stateMachine.setNewFlowStatus(stateMachine.getOriginalFlowStatus());
stateMachine.fire(REROUTE_IS_NOT_REQUIRED);
} else {
stateMachine.fireErrorRerouteIsSkipped("Reroute is unsuccessful. Couldn't find new path(s)");
}
} else {
if (stateMachine.isEffectivelyDown()) {
log.warn("Flow {} is mentioned as effectively DOWN, so it will be forced to DOWN state if reroute fail",
Expand Down
Loading