Skip to content
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

Add script to wait for the model to appear when using KServe Modelcar #356

Closed
wants to merge 1 commit into from

Conversation

israel-hdez
Copy link

@israel-hdez israel-hdez commented Sep 3, 2024

When using OCI containers for model storage in KServe (modelcar), there is the possibility that the model server starts before the model has been fully downloaded. When this happens, the model server would terminate with error because the model path is empty.

This adds a small script to wait for the cluster to fully download the model container before invoking the model server. The waiting is triggered when the MODEL_INIT_MODE environment variable is set to "async".

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link
Contributor

openshift-ci bot commented Sep 3, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

openshift-ci bot commented Sep 3, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: israel-hdez

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Sep 3, 2024
When using OCI containers for model storage in KServe (modelcar), there
is the possibility that the model server starts before the model has
been fully downloaded. When this happens, the model server would
terminate with error because the model path is empty.

This adds a small script to wait for the cluster to fully download the
model container before invoking the model server. The waiting is
triggered when the MODEL_INIT_MODE environment variable is set to "async".

Signed-off-by: Edgar Hernández <[email protected]>
Comment on lines +42 to 43
ENTRYPOINT ["/caikit/wait-modelcar.sh"]
CMD ["python", "-m", "caikit.runtime"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the semantics here of changing the entrypoint? Does CMD run afterwards? I was under the impression that the entrypoint is what's run when the container starts up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an ENTRYPOINT is specified, then the CMD becomes its arguments (the separation comes from the early Docker days, so that the image author could specify a command with ENTRYPOINT that could not be overwritten with docker run). In the Kubernetes world, ENTRYPOINT correspond to the command: field and CMD correspond to the args: field in a Pod container's spec.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this additional script really necessary? Shouldn't the storage initializer handle this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the storage initializer runs as an init-container which runs before the modelcar sidecar starts in parallel with the runtime container.

The proper solution is to add the modelcar as a proper K8s sidecar as described in kserve/kserve#3646, but this requires K8s >= 1.29 + this feature needs to be enabled.


if [ "${MODEL_INIT_MODE}" = "async" ] ; then
echo "Waiting for model files (modelcar) to be present..."
until test -e /mnt/models; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth to also add a timeout, as there can be also error case when the modelcar can't be started. Of course, the overall Pod will be in an error state if the modelcar can't be fired up (e.g. when specifying a non-existing image as storageUrl) and then the question also would be, how large this timeout should be (really depends also on the size of the model to run, as the most likely cast when you have to wait for a model is when it is pulled from a registry).

@rhuss
Copy link
Contributor

rhuss commented Sep 6, 2024

@israel-hdez
Copy link
Author

We discussed in a call, and this won't be needed. We are changing kserve-controller to reduce the race condition.
Closing.

@israel-hdez israel-hdez closed this Sep 6, 2024
@israel-hdez israel-hdez deleted the modelcars-fix branch September 6, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants