Fix Kubernetes readiness probe to wait for user code containers#492
Draft
Copilot wants to merge 3 commits intouser-code-startup-probefrom
Draft
Fix Kubernetes readiness probe to wait for user code containers#492Copilot wants to merge 3 commits intouser-code-startup-probefrom
Copilot wants to merge 3 commits intouser-code-startup-probefrom
Conversation
Co-authored-by: simeoncarstens <9200049+simeoncarstens@users.noreply.github.com>
Co-authored-by: simeoncarstens <9200049+simeoncarstens@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] This branch contains an attempt of implementing a Kubernetes readiness probe. The problem is that the user code container sometimes installs dependencies, e.g. via
Fix Kubernetes readiness probe to wait for user code containers
Sep 1, 2025
pip, that take a while, but the controller container sometimes sends out sampling requ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The controller container was reporting as ready before user code containers finished installing dependencies, causing sampling requests to be sent too early. This happened because:
pipduring startup, which can take several minutesThis resulted in failed sampling requests and degraded system performance.
Solution
Modified the controller's health check callback to wait for all user code containers to be ready before reporting the controller as ready.
Changes Made
Added
check_user_code_server_ready()function:localhost:50052(same pod)Truewhen server responds withSERVINGstatusUpdated
controller_state()callback:SERVINGwhen both controller process AND user code server are readyNOT_SERVINGwhile user code is still installing dependenciesBehavior
Before: Controller reports ready immediately → Kubernetes routes traffic → Sampling requests fail during pip install
After: Controller waits for user code → Reports ready only when log prob evaluations can complete in ~1s → No failed requests
Testing
Comprehensive testing confirms:
NOT_SERVINGduring dependency installation phaseSERVINGonly after user code containers are readyThis ensures the controller only starts receiving sampling requests when all user code containers can reliably respond within the expected timeframe.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.