Skip to content

Commit ba7d7e7

Browse files
authored
feat: allow v1 sessions to be disabled (#983)
Closes #982.
1 parent 41e7545 commit ba7d7e7

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

components/renku_data_services/notebooks/config/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class NotebooksConfig:
134134
default_factory=_ServersGetEndpointAnnotations
135135
)
136136
session_id_cookie_name: str = "_renku_session" # NOTE: This cookie name is set and controlled by the gateway
137+
v1_sessions_enabled: bool = False
137138

138139
@classmethod
139140
def from_env(cls, db_config: DBConfig) -> Self:
@@ -148,6 +149,7 @@ def from_env(cls, db_config: DBConfig) -> Self:
148149
git_provider_helper: GitProviderHelperProto
149150
k8s_namespace = os.environ.get("K8S_NAMESPACE", "default")
150151
kube_config_root = os.environ.get("K8S_CONFIGS_ROOT", "/secrets/kube_configs")
152+
v1_sessions_enabled = _parse_str_as_bool(os.environ.get("V1_SESSIONS_ENABLED", False))
151153

152154
if dummy_stores:
153155
quota_repo = QuotaRepository(DummyCoreClient({}, {}), DummySchedulingClient({}), namespace=k8s_namespace)
@@ -220,4 +222,5 @@ def from_env(cls, db_config: DBConfig) -> Self:
220222
k8s_db_cache=k8s_db_cache,
221223
cluster_rp=cluster_rp,
222224
_kr8s_api=kr8s_api,
225+
v1_sessions_enabled=v1_sessions_enabled,
223226
)

components/renku_data_services/notebooks/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ async def launch_notebook_helper(
339339
if server:
340340
return UserServerManifest(server, nb_config.sessions.default_image, nb_config.sessions.storage.pvs_enabled), 200
341341

342+
if not nb_config.v1_sessions_enabled:
343+
raise errors.ForbiddenError(message="Starting v1 sessions is not allowed.")
344+
342345
gl_project_path = gl_project_path if gl_project_path is not None else ""
343346

344347
# Add annotation for old and new notebooks

test/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ async def app_manager(
219219
monkeysession.setenv("MAX_PINNED_PROJECTS", "5")
220220
monkeysession.setenv("NB_SERVER_OPTIONS__DEFAULTS_PATH", "server_defaults.json")
221221
monkeysession.setenv("NB_SERVER_OPTIONS__UI_CHOICES_PATH", "server_options.json")
222+
monkeysession.setenv("V1_SESSIONS_ENABLED", "true")
222223

223224
dm = TestDependencyManager.from_env(dummy_users)
224225

0 commit comments

Comments
 (0)