feat(csi): improve CSI logging (#1540)
* feat(csi): improve CSI logging Signed-off-by: Matteo Mortari <matteo.mortari@gmail.com> * improve log line, ensure cleanups in test script Signed-off-by: Matteo Mortari <matteo.mortari@gmail.com> --------- Signed-off-by: Matteo Mortari <matteo.mortari@gmail.com>
This commit is contained in:
parent
10cbc8fbfd
commit
e8325381e1
|
|
@ -27,6 +27,16 @@ func StrPtr(notEmpty string) *string {
|
|||
return ¬Empty
|
||||
}
|
||||
|
||||
// SafeString returns a string representation of a string pointer.
|
||||
// Useful for logging or printing values that may be nil. For Zero values, you can refer to ZeroIfNil instead.
|
||||
// Returns "<nil>" if the input is nil
|
||||
func SafeString(s *string) string {
|
||||
if s == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return *s
|
||||
}
|
||||
|
||||
// ValidateIDAsInt32 validates and converts a string ID to int32
|
||||
// Returns an error with api.ErrBadRequest if the ID is invalid
|
||||
func ValidateIDAsInt32(id string, entityName string) (int32, error) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
kserve "github.com/kserve/kserve/pkg/agent/storage"
|
||||
"github.com/kubeflow/model-registry/internal/apiutils"
|
||||
"github.com/kubeflow/model-registry/internal/csi/constants"
|
||||
"github.com/kubeflow/model-registry/pkg/openapi"
|
||||
)
|
||||
|
|
@ -56,10 +57,10 @@ func (p *ModelRegistryProvider) DownloadModel(modelDir string, modelName string,
|
|||
storageUri,
|
||||
p.Client.GetConfig().Host,
|
||||
registeredModelName,
|
||||
versionName,
|
||||
apiutils.SafeString(versionName),
|
||||
)
|
||||
|
||||
log.Printf("Fetching model: registeredModelName=%s, versionName=%v", registeredModelName, versionName)
|
||||
log.Printf("Fetching model: registeredModelName=%s, versionName=%v", registeredModelName, apiutils.SafeString(versionName))
|
||||
|
||||
// Fetch the registered model
|
||||
model, _, err := p.Client.ModelRegistryServiceAPI.FindRegisteredModel(context.Background()).Name(registeredModelName).Execute()
|
||||
|
|
@ -99,16 +100,19 @@ func (p *ModelRegistryProvider) DownloadModel(modelDir string, modelName string,
|
|||
return fmt.Errorf("%w %s", ErrModelArtifactEmptyURI, *modelArtifact.Id)
|
||||
}
|
||||
|
||||
log.Printf("Extracting protocol from model artifact URI: %s", apiutils.SafeString(modelArtifact.Uri))
|
||||
protocol, err := p.extractProtocol(*modelArtifact.Uri)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("Getting KServe provider for protocol: %s", protocol)
|
||||
provider, err := kserve.GetProvider(p.Providers, protocol)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("Delegating to KServe provider to download model with: modelDir=%s, storageUri=%s", modelDir, apiutils.SafeString(modelArtifact.Uri))
|
||||
return provider.DownloadModel(modelDir, "", *modelArtifact.Uri)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,12 +184,19 @@ if [ ! "$res_one" = "{\"predictions\":[1,1]}" ]; then
|
|||
exit 1
|
||||
else
|
||||
echo "Scenario 1 - Test succeeded!"
|
||||
kubectl logs pod/$predictor_one -n $KSERVE_TEST_NAMESPACE -c storage-initializer
|
||||
kubectl logs pod/$predictor_one -n $KSERVE_TEST_NAMESPACE -c kserve-container
|
||||
fi
|
||||
|
||||
echo "Cleaning up inferenceservice sklearn-iris-scenario-one ..."
|
||||
|
||||
kubectl delete inferenceservice sklearn-iris-scenario-one -n $KSERVE_TEST_NAMESPACE
|
||||
|
||||
sleep 5
|
||||
kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor'
|
||||
echo "Checking that no predictor pods remain after cleanup..."
|
||||
repeat_cmd_until "kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor' --output jsonpath='{.items[*].metadata.name}' | wc -w" "= 0" 60
|
||||
echo "No predictor pods remaining - cleanup successful"
|
||||
|
||||
echo "======== Finished Scenario 1 ========"
|
||||
|
||||
echo "======== Scenario 2 - Testing with default model registry service without model version ========"
|
||||
|
|
@ -211,7 +218,7 @@ EOF
|
|||
|
||||
# wait for pod predictor to be initialized
|
||||
repeat_cmd_until "kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor' --output jsonpath='{.items[*].metadata.name}' | grep sklearn-iris-scenario-two | wc -l" "-gt 0" 60
|
||||
predictor_two=$(kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector="component=predictor" --output jsonpath='{.items[1].metadata.name}')
|
||||
predictor_two=$(kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector="component=predictor" --output jsonpath='{.items[0].metadata.name}')
|
||||
|
||||
kubectl wait --for=condition=Ready pod/$predictor_two -n $KSERVE_TEST_NAMESPACE --timeout=5m
|
||||
|
||||
|
|
@ -230,12 +237,19 @@ if [ ! "$res_two" = "{\"predictions\":[1,1]}" ]; then
|
|||
exit 1
|
||||
else
|
||||
echo "Scenario 2 - Test succeeded!"
|
||||
kubectl logs pod/$predictor_two -n $KSERVE_TEST_NAMESPACE -c storage-initializer
|
||||
kubectl logs pod/$predictor_two -n $KSERVE_TEST_NAMESPACE -c kserve-container
|
||||
fi
|
||||
|
||||
echo "Cleaning up inferenceservice sklearn-iris-scenario-two ..."
|
||||
|
||||
kubectl delete inferenceservice sklearn-iris-scenario-two -n $KSERVE_TEST_NAMESPACE
|
||||
|
||||
sleep 5
|
||||
kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor'
|
||||
echo "Checking that no predictor pods remain after cleanup..."
|
||||
repeat_cmd_until "kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor' --output jsonpath='{.items[*].metadata.name}' | wc -w" "= 0" 60
|
||||
echo "No predictor pods remaining - cleanup successful"
|
||||
|
||||
echo "======== Finished Scenario 2 ========"
|
||||
|
||||
echo "======== Scenario 3 - Testing with custom model registry service ========"
|
||||
|
|
@ -297,7 +311,7 @@ EOF
|
|||
|
||||
# wait for pod predictor to be initialized
|
||||
repeat_cmd_until "kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor' --output jsonpath='{.items[*].metadata.name}' | grep sklearn-iris-scenario-three-predictor | wc -l" "-gt 0" 60
|
||||
predictor_three=$(kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector="component=predictor" --output jsonpath='{.items[1].metadata.name}')
|
||||
predictor_three=$(kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector="component=predictor" --output jsonpath='{.items[0].metadata.name}')
|
||||
|
||||
kubectl wait --for=condition=Ready pod/$predictor_three -n $KSERVE_TEST_NAMESPACE --timeout=5m
|
||||
|
||||
|
|
@ -316,12 +330,19 @@ if [ ! "$res_three" = "{\"predictions\":[1,1]}" ]; then
|
|||
exit 1
|
||||
else
|
||||
echo "Scenario 3 - Test succeeded!"
|
||||
kubectl logs pod/$predictor_three -n $KSERVE_TEST_NAMESPACE -c storage-initializer
|
||||
kubectl logs pod/$predictor_three -n $KSERVE_TEST_NAMESPACE -c kserve-container
|
||||
fi
|
||||
|
||||
echo "Cleaning up inferenceservice sklearn-iris-scenario-three ..."
|
||||
|
||||
kubectl delete inferenceservice sklearn-iris-scenario-three -n $KSERVE_TEST_NAMESPACE
|
||||
|
||||
sleep 5
|
||||
kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor'
|
||||
echo "Checking that no predictor pods remain after cleanup..."
|
||||
repeat_cmd_until "kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor' --output jsonpath='{.items[*].metadata.name}' | wc -w" "= 0" 60
|
||||
echo "No predictor pods remaining - cleanup successful"
|
||||
|
||||
echo "======== Finished Scenario 3 ========"
|
||||
|
||||
echo "======== Scenario 4 - Testing with custom model registry service without model version ========"
|
||||
|
|
@ -343,7 +364,7 @@ EOF
|
|||
|
||||
# wait for pod predictor to be initialized
|
||||
repeat_cmd_until "kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor' --output jsonpath='{.items[*].metadata.name}' | grep sklearn-iris-scenario-four-predictor | wc -l" "-gt 0" 60
|
||||
predictor_four=$(kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector="component=predictor" --output jsonpath='{.items[1].metadata.name}')
|
||||
predictor_four=$(kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector="component=predictor" --output jsonpath='{.items[0].metadata.name}')
|
||||
|
||||
kubectl wait --for=condition=Ready pod/$predictor_four -n $KSERVE_TEST_NAMESPACE --timeout=5m
|
||||
|
||||
|
|
@ -362,12 +383,19 @@ if [ ! "$res_four" = "{\"predictions\":[1,1]}" ]; then
|
|||
exit 1
|
||||
else
|
||||
echo "Scenario 4 - Test succeeded!"
|
||||
kubectl logs pod/$predictor_four -n $KSERVE_TEST_NAMESPACE -c storage-initializer
|
||||
kubectl logs pod/$predictor_four -n $KSERVE_TEST_NAMESPACE -c kserve-container
|
||||
fi
|
||||
|
||||
echo "Cleaning up inferenceservice sklearn-iris-scenario-four ..."
|
||||
|
||||
kubectl delete inferenceservice sklearn-iris-scenario-four -n $KSERVE_TEST_NAMESPACE
|
||||
|
||||
sleep 5
|
||||
kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor'
|
||||
echo "Checking that no predictor pods remain after cleanup..."
|
||||
repeat_cmd_until "kubectl get pod -n $KSERVE_TEST_NAMESPACE --selector='component=predictor' --output jsonpath='{.items[*].metadata.name}' | wc -w" "= 0" 60
|
||||
echo "No predictor pods remaining - cleanup successful"
|
||||
|
||||
echo "======== Finished Scenario 4 ========"
|
||||
|
||||
echo "All tests passed!"
|
||||
|
|
|
|||
Loading…
Reference in New Issue