Repository navigation
[serve][deploy refactor][4/X] Reconcile build app task - #37180
Conversation
7bc721e to
ee2287d
Compare
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
edoakes
left a comment
There was a problem hiding this comment.
Looks great overall.
One question about resetting the _build_app_task_info, otherwise small comments.
| @property | ||
| def deploy_args_list(self) -> List[Dict]: |
There was a problem hiding this comment.
BuiltApplication is marked as a public API. To avoid maintaining this utility as a public API, can you make it a separate utility or a private method?
There was a problem hiding this comment.
I've separated it out into a utility function!
| ) | ||
| elif check_obj_ref_ready_nowait(self._build_app_task_info.obj_ref): | ||
| build_app_obj_ref = self._build_app_task_info.obj_ref | ||
| self._build_app_task_info = None |
There was a problem hiding this comment.
If we are resetting this to None immediately, won't the following iteration always kick off a new build app task (because of the condition on line 427)? Or is that gated somewhere else?
There was a problem hiding this comment.
That's gated by line 524 - once the task finishes and the deploy args are fetched, the deploy args + the code version are applied to the target state through apply_deployment_args. Then in the next iteration, even though _build_app_task_info is None, since the current code version matches that of the target config, _start_or_reconcile_build_app_task isn't called.
It is a bit confusing, because we need to handle the target config being out of sync with the rest of the target state, and correctly detect that to bring the rest of the target state up to date. Resetting _build_app_task_info to None, coupled with the code version stored in _build_app_task_info, is one way I found that works for this.
There was a problem hiding this comment.
Got it. Without being as deep in the code as you I think it would be slightly preferable to make this function itself handle the case where the build task has already been run, but if this structure makes more sense to you then I'm OK with it.
Regardless, please add a comment about this assumption to the docstring of _start_or_reconcile_build_app_task and a short comment to the callsite saying that we should skip calling it when the code version already matches.
There was a problem hiding this comment.
Ah I see! I've changed it so that the function is always called but will return a NO_TASK_STARTED status if there is no in progress task (nor does one need to be started).
| build task (resets self._build_app_task_info when task finishes, | ||
| regardless of whether it finished successfully) |
There was a problem hiding this comment.
Related to my comment below: what's the purpose of resetting self._build_app_task_info? Couldn't we instead mark it done and then short-circuit this method if the version matches the target version?
Might be missing this being handled at a higher layer somewhere.
| # Error is raised when this task is canceled with ray.cancel(), which | ||
| # happens when deploy_apps() is called. | ||
| logger.debug("Existing config deployment request terminated.") | ||
| return None, None |
There was a problem hiding this comment.
this seems a little sketchy, in a corner case it might cause application state to pick up None as the deploy args list
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
…7180) This PR improves how the application state manager kicks off the task to import and build application code, and how the results are reconciled and then deployed. - When deploying from a config, the task should only import + build application then return the deploy arguments. The task should not call deploy API on the controller. The results will be fetched and reconciled by the application state manager. - If the "code version" inferred from the new config matches the old config, the task is not started - instead, only the updated config options will be applied to the deployment target states. - Note: this is not too different from how it worked before. What was happening before is that the application code is re-loaded every time the config is updated. Existing replicas would not be restarted because the deployment version is the same; but if (autoscaling is used and) new replicas are started, they are started with the new application code, meaning different replicas will have different versions of the application code! This change removes this inconsistency.
…7180) This PR improves how the application state manager kicks off the task to import and build application code, and how the results are reconciled and then deployed. - When deploying from a config, the task should only import + build application then return the deploy arguments. The task should not call deploy API on the controller. The results will be fetched and reconciled by the application state manager. - If the "code version" inferred from the new config matches the old config, the task is not started - instead, only the updated config options will be applied to the deployment target states. - Note: this is not too different from how it worked before. What was happening before is that the application code is re-loaded every time the config is updated. Existing replicas would not be restarted because the deployment version is the same; but if (autoscaling is used and) new replicas are started, they are started with the new application code, meaning different replicas will have different versions of the application code! This change removes this inconsistency. Signed-off-by: NripeshN <[email protected]>
…7180) This PR improves how the application state manager kicks off the task to import and build application code, and how the results are reconciled and then deployed. - When deploying from a config, the task should only import + build application then return the deploy arguments. The task should not call deploy API on the controller. The results will be fetched and reconciled by the application state manager. - If the "code version" inferred from the new config matches the old config, the task is not started - instead, only the updated config options will be applied to the deployment target states. - Note: this is not too different from how it worked before. What was happening before is that the application code is re-loaded every time the config is updated. Existing replicas would not be restarted because the deployment version is the same; but if (autoscaling is used and) new replicas are started, they are started with the new application code, meaning different replicas will have different versions of the application code! This change removes this inconsistency. Signed-off-by: e428265 <[email protected]>
Why are these changes needed?
This PR improves how the application state manager kicks off the task to import and build application code, and how the results are reconciled and then deployed.
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.