Skip to content

Commit 6c4468d

Browse files
committed
chore: resolve changes from conflict resolution
1 parent 72e0824 commit 6c4468d

File tree

26 files changed

+443
-155
lines changed

26 files changed

+443
-155
lines changed

.github/workflows/acceptance-tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
extra-values: ${{ steps.deploy-comment.outputs.extra-values}}
3434
steps:
3535
- id: deploy-comment
36-
uses: SwissDataScienceCenter/renku-actions/[email protected].1
36+
uses: SwissDataScienceCenter/renku-actions/[email protected].2
3737
with:
3838
string: /deploy
3939
pr_ref: ${{ github.event.number }}
@@ -63,7 +63,7 @@ jobs:
6363
body: |
6464
You can access the deployment of this PR at https://renku-ci-ds-${{ github.event.number }}.dev.renku.ch
6565
- name: Build and deploy
66-
uses: SwissDataScienceCenter/renku-actions/[email protected].1
66+
uses: SwissDataScienceCenter/renku-actions/[email protected].2
6767
env:
6868
RANCHER_PROJECT_ID: ${{ secrets.CI_RANCHER_PROJECT }}
6969
DOCKER_PASSWORD: ${{ secrets.RENKU_DOCKER_PASSWORD }}
@@ -87,15 +87,15 @@ jobs:
8787
renku_notebooks: "${{ needs.check-deploy.outputs.renku-notebooks }}"
8888
renku_data_services: "@${{ github.head_ref }}"
8989
amalthea: "${{ needs.check-deploy.outputs.amalthea }}"
90-
amalthea-sessions: "${{ needs.check-deploy.outputs.amalthea-sessions }}"
90+
amalthea_sessions: "${{ needs.check-deploy.outputs.amalthea-sessions }}"
9191
extra_values: "${{ needs.check-deploy.outputs.extra-values }}"
9292

9393
selenium-acceptance-tests:
9494
needs: [check-deploy, deploy-pr]
9595
if: github.event.action != 'closed' && needs.check-deploy.outputs.pr-contains-string == 'true' && needs.check-deploy.outputs.test-enabled == 'true'
9696
runs-on: ubuntu-22.04
9797
steps:
98-
- uses: SwissDataScienceCenter/renku-actions/[email protected].1
98+
- uses: SwissDataScienceCenter/renku-actions/[email protected].2
9999
with:
100100
kubeconfig: ${{ secrets.RENKUBOT_DEV_KUBECONFIG }}
101101
renku-release: renku-ci-ds-${{ github.event.number }}
@@ -122,7 +122,7 @@ jobs:
122122
steps:
123123
- name: Extract Renku repository reference
124124
run: echo "RENKU_REFERENCE=`echo '${{ needs.check-deploy.outputs.renku }}' | cut -d'@' -f2`" >> $GITHUB_ENV
125-
- uses: SwissDataScienceCenter/renku-actions/[email protected].1
125+
- uses: SwissDataScienceCenter/renku-actions/[email protected].2
126126
with:
127127
e2e-target: ${{ matrix.tests }}
128128
renku-reference: ${{ env.RENKU_REFERENCE }}
@@ -150,7 +150,7 @@ jobs:
150150
body: |
151151
Tearing down the temporary RenkuLab deplyoment for this PR.
152152
- name: renku teardown
153-
uses: SwissDataScienceCenter/renku-actions/[email protected].1
153+
uses: SwissDataScienceCenter/renku-actions/[email protected].2
154154
env:
155155
HELM_RELEASE_REGEX: "^renku-ci-ds-${{ github.event.number }}$"
156156
GITLAB_TOKEN: ${{ secrets.DEV_GITLAB_TOKEN }}

.github/workflows/test_publish.yml

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -63,53 +63,6 @@ jobs:
6363
${{ steps.docker_image.outputs.image_repository }}:${{ steps.docker_image.outputs.image_tag }}
6464
${{ steps.docker_image.outputs.image_repository }}:${{ env.DEVCONTAINER_IMAGE_TAG_MAIN }}
6565
66-
style-checks:
67-
runs-on: ubuntu-latest
68-
needs:
69-
- build-devcontainer
70-
steps:
71-
- uses: actions/checkout@v4
72-
with:
73-
fetch-depth: 0
74-
- name: Docker image metadata
75-
id: meta
76-
uses: docker/metadata-action@v5
77-
with:
78-
images: ${{ env.DEVCONTAINER_REGISTRY }}/${{ env.DEVCONTAINER_IMAGE_NAME }}
79-
tags: |
80-
type=ref,event=pr,prefix=cache-pr-,priority=600
81-
type=ref,event=branch,prefix=cache-,priority=500
82-
type=ref,event=tag,prefix=cache-,priority=500
83-
flavor: |
84-
latest=false
85-
- name: Extract Docker image name
86-
id: docker_image
87-
env:
88-
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
89-
run: |
90-
IMAGE=$(echo "$IMAGE_TAGS" | cut -d" " -f1)
91-
IMAGE_REPOSITORY=$(echo "$IMAGE" | cut -d":" -f1)
92-
IMAGE_TAG=$(echo "$IMAGE" | cut -d":" -f2)
93-
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
94-
echo "image_repository=$IMAGE_REPOSITORY" >> "$GITHUB_OUTPUT"
95-
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
96-
- uses: docker/login-action@v3
97-
with:
98-
registry: ghcr.io
99-
username: ${{ github.actor }}
100-
password: ${{ secrets.GITHUB_TOKEN }}
101-
- name: Pre-build devcontainer
102-
uses: devcontainers/[email protected]
103-
continue-on-error: true
104-
with:
105-
push: always
106-
skipContainerUserIdUpdate: false
107-
imageName: ${{ steps.docker_image.outputs.image_repository }}
108-
imageTag: ${{ steps.docker_image.outputs.image_tag }}
109-
cacheFrom: |
110-
${{ steps.docker_image.outputs.image_repository }}:${{ steps.docker_image.outputs.image_tag }}
111-
${{ steps.docker_image.outputs.image_repository }}:${{ env.DEVCONTAINER_IMAGE_TAG_MAIN }}
112-
11366
style-checks:
11467
runs-on: ubuntu-latest
11568
needs:
@@ -142,6 +95,7 @@ jobs:
14295
push: never
14396
skipContainerUserIdUpdate: false
14497
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
98+
14599
test-main:
146100
runs-on: ubuntu-latest
147101
needs:

components/renku_data_services/crc/db.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
from functools import wraps
1313
from typing import Any, Concatenate, Optional, ParamSpec, TypeVar, cast
1414

15-
from sqlalchemy import NullPool, create_engine, delete, select, true
15+
from sqlalchemy import NullPool, create_engine, delete, false, select, true
1616
from sqlalchemy.ext.asyncio import AsyncSession
1717
from sqlalchemy.orm import Session, selectinload, sessionmaker
1818
from sqlalchemy.sql import Select, and_, not_, or_
19-
from sqlalchemy.sql.expression import false, true
2019

2120
import renku_data_services.base_models as base_models
2221
from renku_data_services import errors

components/renku_data_services/notebooks/api/amalthea_patches/init_containers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# NOTE: If these are directly imported then you get circular imports.
1616
from renku_data_services.notebooks.api.classes.server import UserServer
1717

18+
1819
async def git_clone_container_v2(server: "UserServer") -> dict[str, Any] | None:
1920
"""Returns the specification for the container that clones the user's repositories for new operator."""
2021
amalthea_session_work_volume: str = "amalthea-volume"
@@ -104,7 +105,6 @@ async def git_clone_container_v2(server: "UserServer") -> dict[str, Any] | None:
104105
},
105106
)
106107

107-
108108
# Set up git repositories
109109
for idx, repo in enumerate(repositories):
110110
obj_env = f"{prefix}REPOSITORIES_{idx}_"
@@ -153,6 +153,7 @@ async def git_clone_container_v2(server: "UserServer") -> dict[str, Any] | None:
153153
"env": env,
154154
}
155155

156+
156157
async def git_clone_container(server: "UserServer") -> dict[str, Any] | None:
157158
"""Returns the specification for the container that clones the user's repositories."""
158159
repositories = await server.repositories()
@@ -241,7 +242,6 @@ async def git_clone_container(server: "UserServer") -> dict[str, Any] | None:
241242
},
242243
)
243244

244-
245245
# Set up git repositories
246246
for idx, repo in enumerate(repositories):
247247
obj_env = f"{prefix}REPOSITORIES_{idx}_"

components/renku_data_services/notebooks/api/schemas/server_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
from marshmallow import Schema, fields
88

9+
from renku_data_services.crc.models import ResourceClass
910
from renku_data_services.notebooks.api.schemas.custom_fields import ByteSizeField, CpuField, GpuField
1011
from renku_data_services.notebooks.config.dynamic import CPUEnforcement
1112
from renku_data_services.notebooks.errors.programming import ProgrammingError
12-
from renku_data_services.crc.models import ResourceClass
1313

1414

1515
@dataclass

components/renku_data_services/notebooks/api/schemas/servers_get.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from enum import Enum
77
from typing import Any, Union, cast
88

9-
from kubernetes.utils.quantity import parse_quantity
109
from marshmallow import EXCLUDE, Schema, fields, pre_load, validate
1110

1211
from renku_data_services.notebooks.api.classes.server_manifest import UserServerManifest
@@ -403,9 +402,7 @@ def get_status(server: UserServerManifest, started: datetime) -> dict[str, dict[
403402

404403
hibernation_date_str = annotations.get("renku.io/hibernationDate")
405404

406-
hibernated_seconds_threshold = (
407-
server.manifest.spec.culling.hibernatedSecondsThreshold
408-
)
405+
hibernated_seconds_threshold = server.manifest.spec.culling.hibernatedSecondsThreshold
409406

410407
if hibernation_date_str and hibernated_seconds_threshold > 0 and not is_user_anonymous(server):
411408
hibernation_date = datetime.fromisoformat(hibernation_date_str)

components/renku_data_services/notebooks/apispec.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: api.spec.yaml
3-
# timestamp: 2024-08-28T09:26:11+00:00
3+
# timestamp: 2024-08-28T11:41:22+00:00
44

55
from __future__ import annotations
66

@@ -341,35 +341,6 @@ class ServerStatus(BaseAPISpec):
341341
warnings: Optional[List[ServerStatusWarning]] = None
342342

343343

344-
class SessionPostRequest(BaseAPISpec):
345-
project_id: str = Field(
346-
...,
347-
description="ULID identifier",
348-
max_length=26,
349-
min_length=26,
350-
pattern="^[A-Z0-9]{26}$",
351-
)
352-
launcher_id: str = Field(
353-
...,
354-
description="ULID identifier",
355-
max_length=26,
356-
min_length=26,
357-
pattern="^[A-Z0-9]{26}$",
358-
)
359-
storage: int = Field(
360-
1, description="The size of disk storage for the session, in gigabytes"
361-
)
362-
resource_class_id: Optional[int] = None
363-
364-
365-
class SessionStatus(BaseAPISpec):
366-
details: Optional[List[SessionStatusDetail]] = None
367-
message: Optional[str] = None
368-
state: State3
369-
will_hibernate_at: Optional[datetime] = None
370-
will_delete_at: Optional[datetime] = None
371-
372-
373344
class SessionResources(BaseAPISpec):
374345
requests: Optional[SessionResourcesRequests] = None
375346

components/renku_data_services/notebooks/blueprints.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import base64
44
import json as json_lib
55
import logging
6-
from math import floor
76
import os
87
from dataclasses import dataclass
98
from datetime import UTC, datetime
9+
from math import floor
1010
from pathlib import Path
1111
from typing import Any
1212
from urllib.parse import urljoin, urlparse
@@ -784,23 +784,23 @@ async def _handler(
784784
internal_gitlab_user: APIUser,
785785
body: apispec.SessionPostRequest,
786786
) -> JSONResponse:
787+
# gitlab_client = NotebooksGitlabClient(self.nb_config.git.url, internal_gitlab_user.access_token)
788+
launcher = await self.session_repo.get_launcher(user, ULID.from_str(body.launcher_id))
789+
project = await self.project_repo.get_project(user=user, project_id=launcher.project_id)
787790
server_name = renku_2_make_server_name(
788-
safe_username=user.id, project_id=body.project_id, launcher_id=body.launcher_id
791+
safe_username=user.id, project_id=str(launcher.project_id), launcher_id=body.launcher_id
789792
)
790793
existing_session = await self.nb_config.k8s_v2_client.get_server(server_name, user.id)
791794
if existing_session is not None and existing_session.spec is not None:
792795
return json(existing_session.as_apispec().model_dump(exclude_none=True, mode="json"))
793-
gitlab_client = NotebooksGitlabClient(self.nb_config.git.url, internal_gitlab_user.access_token)
794-
project = await self.project_repo.get_project(user=user, project_id=ULID.from_str(body.project_id))
795-
launcher = await self.session_repo.get_launcher(user, ULID.from_str(body.launcher_id))
796796
environment = launcher.environment
797797
image = environment.container_image
798798
default_resource_class = await self.rp_repo.get_default_resource_class()
799799
if default_resource_class.id is None:
800800
raise errors.ProgrammingError(message="The default reosurce class has to have an ID", quiet=True)
801801
resource_class_id = body.resource_class_id or default_resource_class.id
802802
parsed_server_options = await self.nb_config.crc_validator.validate_class_storage(
803-
user, resource_class_id, body.storage
803+
user, resource_class_id, body.disk_storage
804804
)
805805
work_dir = Path("/home/jovyan/work")
806806
user_secrets: K8sUserSecrets | None = None
@@ -816,7 +816,7 @@ async def _handler(
816816
server = Renku2UserServer(
817817
user=user,
818818
image=image,
819-
project_id=body.project_id,
819+
project_id=str(launcher.project_id),
820820
launcher_id=body.launcher_id,
821821
server_name=server_name,
822822
server_options=parsed_server_options,
@@ -857,7 +857,7 @@ async def _handler(
857857

858858
parsed_server_url = urlparse(server.server_url)
859859
annotations: dict[str, str] = {
860-
"renku.io/project_id": body.project_id,
860+
"renku.io/project_id": str(launcher.project_id),
861861
"renku.io/launcher_id": body.launcher_id,
862862
"renku.io/resource_class_id": str(body.resource_class_id or default_resource_class.id),
863863
}
@@ -874,7 +874,7 @@ async def _handler(
874874
port=environment.port,
875875
storage=Storage(
876876
className=self.nb_config.sessions.storage.pvs_storage_class,
877-
size=str(body.storage) + "Gi",
877+
size=str(body.disk_storage) + "G",
878878
mountPath=environment.mount_directory.as_posix(),
879879
),
880880
workingDir=environment.working_directory.as_posix(),

components/renku_data_services/notebooks/config/dynamic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
latest_version: str = "1.25.3"
1515

16+
1617
def _parse_str_as_bool(val: Union[str, bool]) -> bool:
1718
if isinstance(val, str):
1819
return val.lower() == "true"
@@ -409,14 +410,14 @@ def from_env(cls) -> Self:
409410
def _for_testing(cls) -> Self:
410411
return cls(
411412
culling=_SessionCullingConfig.from_env(),
412-
git_proxy=_GitProxyConfig(renku_client_secret="not-defined"),
413+
git_proxy=_GitProxyConfig(renku_client_secret="not-defined"), # nosec B106
413414
git_rpc_server=_GitRpcServerConfig.from_env(),
414415
git_clone=_GitCloneConfig.from_env(),
415416
ingress=_SessionIngress(host="localhost"),
416417
ca_certs=_CustomCaCertsConfig.from_env(),
417418
oidc=_SessionOidcConfig(
418419
client_id="not-defined",
419-
client_secret="not-defined",
420+
client_secret="not-defined", # nosec B106
420421
token_url="http://not.defined",
421422
auth_url="http://not.defined",
422423
issuer_url="http://not.defined",
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""Base models for K8s CRD specifications."""
22

3-
from pydantic import BaseModel, Field
4-
5-
3+
from pydantic import BaseModel
64

75

86
class BaseCRD(BaseModel):
@@ -12,4 +10,3 @@ class Config:
1210
"""Do not exclude unknown properties."""
1311

1412
extra = "allow"
15-

components/renku_data_services/notebooks/crs.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ def as_apispec(self) -> apispec.SessionResponse:
171171
url = urljoin(f"{scheme}://{self.spec.ingress.host}", self.spec.session.urlPath)
172172
else:
173173
url = self.status.url
174+
ready_containers = 0
175+
total_containers = 0
176+
if self.status.initContainerCounts is not None:
177+
ready_containers += self.status.initContainerCounts.ready or 0
178+
total_containers += self.status.initContainerCounts.total or 0
179+
if self.status.containerCounts is not None:
180+
ready_containers += self.status.containerCounts.ready or 0
181+
total_containers += self.status.containerCounts.total or 0
174182
return apispec.SessionResponse(
175183
image=self.spec.session.image,
176184
name=self.metadata.name,
@@ -183,8 +191,9 @@ def as_apispec(self) -> apispec.SessionResponse:
183191
),
184192
started=self.metadata.creationTimestamp,
185193
status=apispec.SessionStatus(
186-
details=[],
187194
state=apispec.State3.running,
195+
ready_containers=ready_containers,
196+
total_containers=total_containers,
188197
),
189198
url=url,
190199
project_id=str(self.project_id),

0 commit comments

Comments
 (0)