Skip to content

Commit

Permalink
[Application] Validate the version of Nuclio before deploying (#5618)
Browse files Browse the repository at this point in the history
  • Loading branch information
moranbental committed May 26, 2024
1 parent 5185add commit f1f1b8f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mlrun/runtimes/nuclio/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(
class ApplicationRuntime(RemoteRuntime):
kind = "application"

@min_nuclio_versions("1.12.7")
@min_nuclio_versions("1.13.1")
def __init__(self, spec=None, metadata=None):
super().__init__(spec=spec, metadata=metadata)

Expand Down
5 changes: 1 addition & 4 deletions mlrun/runtimes/nuclio/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ def wrapper(*args, **kwargs):
if validate_nuclio_version_compatibility(*versions):
return function(*args, **kwargs)

message = (
f"{function.__name__} is supported since nuclio {' or '.join(versions)}, currently using "
f"nuclio {mlconf.nuclio_version}, please upgrade."
)
message = f"'{function.__qualname__}' function requires Nuclio v{' or v'.join(versions)} or higher"
raise mlrun.errors.MLRunIncompatibleVersionError(message)

return wrapper
Expand Down
13 changes: 13 additions & 0 deletions tests/api/runtimes/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
import typing

import pytest
from fastapi.testclient import TestClient
from sqlalchemy.orm import Session

Expand Down Expand Up @@ -63,6 +64,18 @@ def test_compile_function_config_skipped_spec(
"spec.build.baseImage",
)

def test_create_function_validate_min_nuclio_version(
self, db: Session, client: TestClient
):
"""Verify that the nuclio min version is validated by the ApplicationRuntime constructor"""
mlrun.mlconf.nuclio_version = "1.12.14"
with pytest.raises(mlrun.errors.MLRunIncompatibleVersionError) as exc:
self._generate_runtime(self.runtime_kind)
assert (
str(exc.value)
== "'ApplicationRuntime.__init__' function requires Nuclio v1.13.1 or higher"
)

def _execute_run(self, runtime, **kwargs):
# deploy_nuclio_function doesn't accept watch, so we need to remove it
kwargs.pop("watch", None)
Expand Down

0 comments on commit f1f1b8f

Please sign in to comment.