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

[API] Fix files API to work on non-k8s environments #3916

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mlrun/api/api/endpoints/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import mlrun.api.api.deps
import mlrun.api.crud.secrets
import mlrun.api.utils.auth.verifier
import mlrun.api.utils.singletons.k8s
import mlrun.common.schemas
from mlrun.api.api.utils import get_obj_path, get_secrets, log_and_raise
from mlrun.datastore import store_manager
Expand Down Expand Up @@ -196,13 +197,20 @@ def _get_filestat(


async def _verify_and_get_project_secrets(project, auth_info):
# If running on Docker or locally, we cannot retrieve project secrets, so skip.
if not mlrun.api.utils.singletons.k8s.get_k8s_helper(
silent=True
).is_running_inside_kubernetes_cluster():
return {}

await mlrun.api.utils.auth.verifier.AuthVerifier().query_project_resource_permissions(
mlrun.common.schemas.AuthorizationResourceTypes.secret,
project,
mlrun.common.schemas.SecretProviderName.kubernetes,
mlrun.common.schemas.AuthorizationAction.read,
auth_info,
)

secrets_data = await run_in_threadpool(
mlrun.api.crud.Secrets().list_project_secrets,
project,
Expand Down