diff --git a/include/triton/core/tritonserver.h b/include/triton/core/tritonserver.h index 09ff58126..78b60cc76 100644 --- a/include/triton/core/tritonserver.h +++ b/include/triton/core/tritonserver.h @@ -1,4 +1,4 @@ -// Copyright 2020-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// Copyright 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions @@ -2377,7 +2377,10 @@ TRITONSERVER_DECLSPEC struct TRITONSERVER_Error* TRITONSERVER_ServerIsReady( /// \param model_version The version of the model to get readiness /// for. If -1 then the server will choose a version based on the /// model's policy. -/// \param ready Returns true if server is ready, false otherwise. +/// \param ready Returns true if the model is ready, false otherwise. A model +/// that cannot be found, or that is unavailable because the server is not +/// ready, is reported as not ready (false) rather than as an error; any other +/// lookup failure is returned as an error. /// \return a TRITONSERVER_Error indicating success or failure. TRITONSERVER_DECLSPEC struct TRITONSERVER_Error* TRITONSERVER_ServerModelIsReady( diff --git a/src/tritonserver.cc b/src/tritonserver.cc index 46ffc931f..f1c6e48d9 100644 --- a/src/tritonserver.cc +++ b/src/tritonserver.cc @@ -2730,14 +2730,20 @@ TRITONSERVER_ServerModelIsReady( { tc::InferenceServer* lserver = reinterpret_cast(server); - // A model that cannot be resolved (never loaded, unloaded, or unregistered) - // is simply not ready. Before the ModelIdentifier readiness refactor the - // lookup failure was swallowed and this returned ready=false; preserve that - // public contract instead of surfacing the lookup error to the caller. std::shared_ptr model; - if (!lserver->GetModel(model_name, model_version, &model).IsOk()) { - *ready = false; - return nullptr; // Success -- not ready, not an error + tc::Status get_model_status = + lserver->GetModel(model_name, model_version, &model); + if (!get_model_status.IsOk()) { + // When the server is not ready or the model cannot be found, the model + // cannot be ready either, so report ready=false without treating it as an + // error. Any other lookup failure is a real error and is surfaced to the + // caller. + if (get_model_status.StatusCode() == tc::Status::Code::UNAVAILABLE || + get_model_status.StatusCode() == tc::Status::Code::NOT_FOUND) { + *ready = false; + return nullptr; + } + RETURN_IF_STATUS_ERROR(get_model_status); } RETURN_IF_STATUS_ERROR(lserver->ModelIsReady(*model, ready)); return nullptr; // Success