use of org.openkilda.messaging.info.reroute.error.SpeakerRequestError in project open-kilda by telstra.
the class SetValidateRuleErrorAction method execute.
@Override
public void execute(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
Set<SwitchId> switches = Stream.concat(stateMachine.getPendingCommands().values().stream(), stateMachine.getFailedValidationResponses().values().stream().map(SpeakerResponse::getSwitchId)).collect(Collectors.toSet());
stateMachine.setRerouteError(new SpeakerRequestError("Failed to validate rules", switches));
log.debug("Abandoning all pending commands: {}", stateMachine.getPendingCommands());
stateMachine.clearPendingCommands();
}
use of org.openkilda.messaging.info.reroute.error.SpeakerRequestError in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldNotInjectRetryWhenReceivedFailedRuleInstallResponseOnTerminatingSwitch.
@Test
public void shouldNotInjectRetryWhenReceivedFailedRuleInstallResponseOnTerminatingSwitch() {
FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_B.getSwitchId()))).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
assertNull(rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
}
use of org.openkilda.messaging.info.reroute.error.SpeakerRequestError in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch.
@Test
public void shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch() {
FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
FlowThrottlingData pending = FlowThrottlingData.builder().correlationId("pending").priority(7).timeCreate(flow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(false).effectivelyDown(true).reason("another reason").build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_C.getSwitchId()))).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
String retryCorrelationId = CORRELATION_ID + " : retry #1 ignore_bw false";
FlowThrottlingData expected = getFlowThrottlingData(flow, retryCorrelationId).build();
expected.setPriority(pending.getPriority());
expected.setReason(pending.getReason());
assertEquals(expected, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
FlowRerouteRequest expectedRequest = getFlowRerouteRequest(FLOW_ID, expected);
verify(carrier).sendRerouteRequest(eq(retryCorrelationId), eq(expectedRequest));
}
use of org.openkilda.messaging.info.reroute.error.SpeakerRequestError in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitchYFlow.
@Test
public void shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitchYFlow() {
FlowThrottlingData inProgress = getFlowThrottlingData(yFlow, CORRELATION_ID).build();
FlowThrottlingData pending = FlowThrottlingData.builder().correlationId("pending").priority(7).timeCreate(yFlow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(false).effectivelyDown(true).reason("another reason").yFlow(true).build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).build();
rerouteQueueService.getReroutes().put(YFLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(YFLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_C.getSwitchId()))).yFlow(true).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
String retryCorrelationId = CORRELATION_ID + " : retry #1 ignore_bw false";
FlowThrottlingData expected = getFlowThrottlingData(yFlow, retryCorrelationId).build();
expected.setPriority(pending.getPriority());
expected.setReason(pending.getReason());
assertEquals(expected, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
YFlowRerouteRequest expectedRequest = getYFlowRerouteRequest(YFLOW_ID, expected);
verify(carrier).sendRerouteRequest(eq(retryCorrelationId), eq(expectedRequest));
}
use of org.openkilda.messaging.info.reroute.error.SpeakerRequestError in project open-kilda by telstra.
the class RerouteQueueService method isRetryRequired.
private boolean isRetryRequired(String flowId, RerouteError rerouteError, boolean isYFlow) {
if (rerouteError instanceof NoPathFoundError) {
log.info("Received no path found error for flow {}", flowId);
return true;
} else if (rerouteError instanceof RerouteInProgressError) {
log.info("Received reroute in progress error for flow {}", flowId);
return true;
} else if (rerouteError instanceof SpeakerRequestError) {
if (isYFlow) {
log.info("Received speaker request error for y-flow {}", flowId);
YFlow yFlow = yFlowRepository.findById(flowId).orElse(null);
if (yFlow == null) {
log.error("Y-flow {} not found", flowId);
return false;
}
Set<SwitchId> yFlowSwitchIds = yFlow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
yFlowSwitchIds.add(yFlow.getSharedEndpoint().getSwitchId());
boolean isRetryRequired = true;
SpeakerRequestError ruleFailedError = (SpeakerRequestError) rerouteError;
for (SwitchId switchId : yFlowSwitchIds) {
isRetryRequired &= !ruleFailedError.getSwitches().contains(switchId);
}
return isRetryRequired;
} else {
log.info("Received speaker request error for flow {}", flowId);
Flow flow = flowRepository.findById(flowId).orElse(null);
if (flow == null) {
log.error("Flow {} not found", flowId);
return false;
}
SpeakerRequestError ruleFailedError = (SpeakerRequestError) rerouteError;
return !ruleFailedError.getSwitches().contains(flow.getSrcSwitchId()) && !ruleFailedError.getSwitches().contains(flow.getDestSwitchId());
}
}
return false;
}
Aggregations