async def update_backend_config(self, backend_tag: BackendTag, config_options: BackendConfig) -> None: """Set the config for the specified backend.""" async with self.write_lock: assert (self.current_state.get_backend(backend_tag) ), "Backend {} is not registered.".format(backend_tag) assert isinstance(config_options, BackendConfig) stored_backend_config = self.current_state.get_backend( backend_tag).backend_config backend_config = stored_backend_config.copy( update=config_options.dict(exclude_unset=True)) backend_config._validate_complete() self.current_state.get_backend( backend_tag).backend_config = backend_config # Scale the replicas with the new configuration. self.actor_reconciler._scale_backend_replicas( self.current_state.backends, backend_tag, backend_config.num_replicas) # NOTE(edoakes): we must write a checkpoint before pushing the # update to avoid inconsistent state if we crash after pushing the # update. self._checkpoint() # Inform the router about change in configuration # (particularly for setting max_batch_size). await self.actor_reconciler._start_pending_backend_replicas( self.current_state) await self.actor_reconciler._stop_pending_backend_replicas() self.notify_replica_handles_changed() self.notify_backend_configs_changed()
def update_backend_config(self, backend_tag: BackendTag, config_options: BackendConfig): if backend_tag not in self.backends: raise ValueError(f"Backend {backend_tag} is not registered") stored_backend_config = self.backends[backend_tag].backend_config updated_config = stored_backend_config.copy(update=config_options.dict( exclude_unset=True)) updated_config._validate_complete() self.backends[backend_tag].backend_config = updated_config new_goal, existing_goal = self._set_backend_goal( backend_tag, self.backends[backend_tag]) # Scale the replicas with the new configuration. self.scale_backend_replicas(backend_tag, updated_config.num_replicas) # NOTE(edoakes): we must write a checkpoint before pushing the # update to avoid inconsistent state if we crash after pushing the # update. self._checkpoint() if existing_goal is not None: self._complete_goal(existing_goal) # Inform the routers and backend replicas about config changes. # TODO(edoakes): this should only happen if we change something other # than num_replicas. self._notify_backend_configs_changed() return new_goal
async def update_backend_config(self, backend_tag: BackendTag, config_options: BackendConfig) -> GoalId: """Set the config for the specified backend.""" async with self.write_lock: existing_backend_info = self.backend_state.get_backend(backend_tag) if existing_backend_info is None: raise ValueError(f"Backend {backend_tag} is not registered.") existing_replica_config = existing_backend_info.replica_config new_backend_config = existing_backend_info.backend_config.copy( update=config_options.dict(exclude_unset=True)) return self.backend_state.deploy_backend( backend_tag, new_backend_config, existing_replica_config)
async def update_backend_config(self, backend_tag: BackendTag, config_options: BackendConfig) -> GoalId: """Set the config for the specified backend.""" async with self.write_lock: existing_info = self.backend_state.get_backend(backend_tag) if existing_info is None: raise ValueError(f"Backend {backend_tag} is not registered.") backend_info = BackendInfo( actor_def=existing_info.actor_def, version=existing_info.version, backend_config=existing_info.backend_config.copy( update=config_options.dict(exclude_unset=True)), replica_config=existing_info.replica_config) goal_id, _ = self.backend_state.deploy_backend( backend_tag, backend_info) return goal_id
async def update_backend_config(self, backend_tag: BackendTag, config_options: BackendConfig) -> UUID: """Set the config for the specified backend.""" async with self.write_lock: assert (self.backend_state.get_backend(backend_tag) ), "Backend {} is not registered.".format(backend_tag) assert isinstance(config_options, BackendConfig) stored_backend_config = self.backend_state.get_backend( backend_tag).backend_config backend_config = stored_backend_config.copy( update=config_options.dict(exclude_unset=True)) backend_config._validate_complete() self.backend_state.get_backend( backend_tag).backend_config = backend_config backend_info = self.backend_state.get_backend(backend_tag) # Scale the replicas with the new configuration. # This should be to run the control loop self.actor_reconciler._scale_backend_replicas( self.backend_state.backends, backend_tag, backend_config.num_replicas) return_uuid = self._create_event_with_result({ backend_tag: backend_info }) # NOTE(edoakes): we must write a checkpoint before pushing the # update to avoid inconsistent state if we crash after pushing the # update. self._checkpoint() # Inform the routers about change in configuration # (particularly for setting max_batch_size). await self.actor_reconciler._enqueue_pending_scale_changes_loop( self.backend_state) await self.actor_reconciler.backend_control_loop() self.notify_replica_handles_changed() self.notify_backend_configs_changed() return return_uuid