Skip to content

Commit

Permalink
integrate pmmlserver rock for 0.11.2 (#218)
Browse files Browse the repository at this point in the history
* integrate pmmlserver rock for 0.11.2

* Update charms/kserve-controller/src/default-custom-images.json

* add logging to make test failures easier to debug
  • Loading branch information
ca-scribner authored and kimwnasptd committed Mar 8, 2024
1 parent ea24a28 commit 827cd3e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charms/kserve-controller/src/default-custom-images.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"serving_runtimes__lgbserver": "kserve/lgbserver:v0.11.1",
"serving_runtimes__kserve_mlserver": "docker.io/seldonio/mlserver:1.3.2",
"serving_runtimes__paddleserver": "charmedkubeflow/paddleserver:0.11.2-ee9909a",
"serving_runtimes__pmmlserver": "kserve/pmmlserver:v0.11.1",
"serving_runtimes__pmmlserver": "charmedkubeflow/pmmlserver:0.11.2-0a784c4",
"serving_runtimes__sklearnserver": "charmedkubeflow/sklearnserver:0.11.2-e54c69e",
"serving_runtimes__tensorflow_serving": "tensorflow/serving:2.6.2",
"serving_runtimes__torchserve": "pytorch/torchserve-kfs:0.8.2",
Expand Down
56 changes: 54 additions & 2 deletions charms/kserve-controller/tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
from charmed_kubeflow_chisme.kubernetes import KubernetesResourceHandler
from lightkube.core.exceptions import ApiError
from lightkube.models.meta_v1 import ObjectMeta
from lightkube.resources.core_v1 import ConfigMap, Namespace, Secret, ServiceAccount
from lightkube.resources.core_v1 import (
ConfigMap,
Namespace,
Pod,
Secret,
ServiceAccount,
)
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -51,6 +57,7 @@
"kubeflow.org", "v1alpha1", "PodDefault", "poddefaults"
)
TESTING_NAMESPACE_NAME = "raw-deployment"
KSERVE_WORKLOAD_CONTAINER = "kserve-container"


def deploy_k8s_resources(template_files: str):
Expand Down Expand Up @@ -89,6 +96,44 @@ def _safe_load_file_to_text(filename: str) -> str:
return text


def print_inf_svc_logs(lightkube_client: lightkube.Client, inf_svc, tail_lines: int = 50):
"""Prints the logs for kserve serving container in the Pod backing an InferenceService.
Args:
lightkube_client: Client to connect to kubernetes
inf_svc: An InferenceService generic resource
tail_lines: Integer number of lines to print when printing pod logs for debugging
"""
logger.info(
f"Printing logs for InferenceService {inf_svc.metadata.name} in namespace {inf_svc.metadata.namespace}"
)
pods = list(
lightkube_client.list(
Pod,
labels={"serving.kserve.io/inferenceservice": inf_svc.metadata.name},
namespace=inf_svc.metadata.namespace,
)
)
if len(pods) > 0:
printed_logs = False
pod = pods[0]
try:
for line in lightkube_client.log(
name=pod.metadata.name,
namespace=pod.metadata.namespace,
container=KSERVE_WORKLOAD_CONTAINER,
tail_lines=tail_lines,
):
printed_logs = True
logger.info(line.strip())
if not printed_logs:
logger.info("No logs found - the pod might still be starting up")
except ApiError:
logger.info("Failed to retrieve logs - the pod might still be starting up")
else:
logger.info("No Pods found - the pod might not be launched yet")


@pytest.fixture(scope="session")
def namespace(lightkube_client: lightkube.Client):
"""Create user namespace with testing label"""
Expand Down Expand Up @@ -238,11 +283,18 @@ def assert_inf_svc_state():
inference_service_resource, inf_svc_name, namespace=TESTING_NAMESPACE_NAME
)
conditions = inf_svc.get("status", {}).get("conditions")
logger.info(
f"INFO: Inspecting InferenceService {inf_svc.metadata.name} in namespace {inf_svc.metadata.namespace}"
)

for condition in conditions:
if condition.get("status") == "False":
if condition.get("status") in ["False", "Unknown"]:
logger.info(f"Inference service is not ready according to condition: {condition}")
status_overall = False
print_inf_svc_logs(lightkube_client=lightkube_client, inf_svc=inf_svc)
break
status_overall = True
logger.info("Service is ready")
assert status_overall is True

create_inf_svc()
Expand Down

0 comments on commit 827cd3e

Please sign in to comment.