Skip to content

Fixed key error when moving SF while flow is processed #80

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

Merged
merged 2 commits into from
Aug 22, 2019
Merged
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
15 changes: 11 additions & 4 deletions src/coordsim/simulation/flowsimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
from coordsim.network.flow import Flow
from coordsim.metrics import metrics
log = logging.getLogger(__name__)

log = logging.getLogger(__name__)

"""
Flow Simulator class
Expand Down Expand Up @@ -238,9 +238,16 @@ def process_flow(self, flow, sfc):
metrics.remove_active_flow(flow, current_node_id, current_sf)

# Remove load from sf
self.params.network.nodes[current_node_id]['available_sf'][sf]['load'] -= flow.dr
assert self.params.network.nodes[current_node_id]['available_sf'][sf][
'load'] >= 0, 'SF load cannot be less than 0!'
if sf in self.params.network.nodes[current_node_id]['available_sf']:
self.params.network.nodes[current_node_id]['available_sf'][sf]['load'] -= flow.dr
assert self.params.network.nodes[current_node_id]['available_sf'][sf]['load'] >= 0, \
'SF load cannot be less than 0!'
else:
log.debug(f"SF {sf} was removed from {current_node_id}, while flow {flow.flow_id} was being "
f"processed. Still assume the flow could finish processing successfully.")
# TODO: drop the flow instead? or at least account for sf resources?
# see https://github.com/RealVNF/coordination-simulation/pull/78#issuecomment-523921483

# Recalculation is necessary because other flows could have already arrived or departed at the node
used_total_capacity = 0.0
for sf_i, sf_data in self.params.network.nodes[current_node_id]['available_sf'].items():
Expand Down