Skip to content

Commit

Permalink
Add slivers only after lease time has been computed
Browse files Browse the repository at this point in the history
  • Loading branch information
kthare10 committed Nov 5, 2024
1 parent 9b40eef commit 9c62d14
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
22 changes: 17 additions & 5 deletions fabric_cf/orchestrator/core/advance_scheduling_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,41 @@ def run(self):

def process_slice(self, *, controller_slice: OrchestratorSliceWrapper):
"""
Determine nearest start time
Determine nearest start time for a slice requested in future and
add to deferred slice thread for further processing
:param controller_slice:
:param lease_start_time: Lease Start Time (UTC)
:param lease_end_time: Lease End Time (UTC)
:param lifetime: Lifetime of the slice in hours
"""
computed_reservations = controller_slice.get_computed_reservations()

try:
controller_slice.lock()

# Determine nearest start time in the time range requested
# If not found, start time specified in the request is used as start resulting in slice failing
# with insufficient resources error
future_start, future_end = self.kernel.determine_future_lease_time(
computed_reservations=computed_reservations,
start=controller_slice.start, end=controller_slice.end,
duration=controller_slice.lifetime)

self.logger.debug(f"Slice: {controller_slice.slice_obj.slice_name}/{controller_slice.slice_obj.get_slice_id()}"
f" Start Time: {future_start} End: {future_end}")

# Update slice start/end time
controller_slice.slice_obj.set_lease_start(lease_start=future_start)
controller_slice.slice_obj.set_lease_end(lease_end=future_end)
self.logger.debug(f"Update Slice {controller_slice.slice_obj.slice_name}")
self.mgmt_actor.update_slice(slice_obj=controller_slice.slice_obj)

# Update the reservations start/end time
for r in computed_reservations:
r.set_start(value=ActorClock.to_milliseconds(when=future_start))
r.set_end(value=ActorClock.to_milliseconds(when=future_end))
self.mgmt_actor.update_reservation(reservation=r)

# Add Reservations to relational database;
controller_slice.add_reservations()

# Queue the slice to be demanded on Slice Defer Thread
self.kernel.get_defer_thread().queue_slice(controller_slice=controller_slice)
except Exception as e:
self.logger.error(traceback.format_exc())
Expand Down
23 changes: 13 additions & 10 deletions fabric_cf/orchestrator/core/orchestrator_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,23 @@ def create_slice(self, *, token: str, slice_name: str, slice_graph: str, ssh_key
r.set_end(value=ActorClock.to_milliseconds(when=future_end))
'''

# Add Reservations to relational database;
new_slice_object.add_reservations()

self.logger.info(f"OC wrapper: TIME= {time.time() - create_ts:.0f}")

# Enqueue the slice on the demand thread
# Demand thread is responsible for demanding the reservations
# Helps improve the create response time
create_ts = time.time()
if lease_start_time and lease_end_time and lifetime:
self.controller_state.get_advance_scheduling_thread().queue_slice(controller_slice=controller)
# Enqueue future slices on Advanced Scheduling Thread to determine possible start time
# Determining start time may take time so this is done asynchronously to avoid increasing response time
# of create slice API
self.controller_state.get_advance_scheduling_thread().queue_slice(controller_slice=new_slice_object)
else:
# Enqueue the slice on the demand thread
# Demand thread is responsible for demanding the reservations
# Helps improve the create response time

# Add Reservations to relational database;
new_slice_object.add_reservations()
self.logger.info(f"OC wrapper: TIME= {time.time() - create_ts:.0f}")
self.controller_state.get_defer_thread().queue_slice(controller_slice=new_slice_object)
self.logger.info(f"QU queue: TIME= {time.time() - create_ts:.0f}")
self.logger.info(f"QU queue: TIME= {time.time() - create_ts:.0f}")

EventLoggerSingleton.get().log_slice_event(slice_object=slice_obj, action=ActionId.create,
topology=topology)

Expand Down

0 comments on commit 9c62d14

Please sign in to comment.