Skip to content

Commit e8accdc

Browse files
committed
fix: git connectors and reading logs (#518)
1 parent 54fe97b commit e8accdc

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

components/renku_data_services/message_queue/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ async def send_pending_events(self) -> None:
6767
except Exception as e:
6868
logger.warning(f"couldn't send event {event.payload} on queue {event.queue}: {e}")
6969

70-
logger.info(f"sent {n_total_events} events")
70+
if n_total_events > 0:
71+
logger.info(f"sent {n_total_events} events to the message queue")
7172

7273
async def store_event(self, session: AsyncSession | Session, event: Event) -> int:
7374
"""Store an event."""

components/renku_data_services/notebooks/api/classes/k8s_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ async def get_pod_logs(self, name: str, max_log_lines: Optional[int] = None) ->
8383
try:
8484
# NOTE: calling pod.logs without a container name set crashes the library
8585
clogs: list[str] = [clog async for clog in pod.logs(container=container, tail_lines=max_log_lines)]
86+
except httpx.ResponseNotRead:
87+
# NOTE: This occurs when the container is still starting but we try to read its logs
88+
continue
8689
except NotFoundError:
8790
raise errors.MissingResourceError(message=f"The session pod {name} does not exist.")
8891
except ServerError as err:

components/renku_data_services/notebooks/blueprints.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,15 @@ async def _handler(
330330
if csr.target_path is not None and not PurePosixPath(csr.target_path).is_absolute():
331331
csr.target_path = (work_dir / csr.target_path).as_posix()
332332
dcs[csr_id] = dcs[csr_id].with_override(csr)
333-
repositories = [Repository(url=i) for i in project.repositories]
333+
git_providers = await self.nb_config.git_provider_helper.get_providers(user=user)
334+
repositories: list[Repository] = []
335+
for repo in project.repositories:
336+
found_provider_id: str | None = None
337+
for provider in git_providers:
338+
if urlparse(provider.url).netloc == urlparse(repo).netloc:
339+
found_provider_id = provider.id
340+
break
341+
repositories.append(Repository(url=repo, provider=found_provider_id))
334342
secrets_to_create: list[V1Secret] = []
335343
# Generate the cloud starge secrets
336344
data_sources: list[DataSource] = []
@@ -359,7 +367,6 @@ async def _handler(
359367
),
360368
)
361369
)
362-
git_providers = await self.nb_config.git_provider_helper.get_providers(user=user)
363370
git_clone = await init_containers.git_clone_container_v2(
364371
user=user,
365372
config=self.nb_config,

test/bases/renku_data_services/data_api/test_notebooks.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def jupyter_server(renku_image: str, server_name: str, pod_name: str) -> A
8080
await pod.wait("condition=Ready")
8181
yield server
8282
# NOTE: This is used also in tests that check if the server was properly stopped
83-
# in this case the server will already gone when we try to delete it in the cleanup here.
83+
# in this case the server will already be gone when we try to delete it in the cleanup here.
8484
with suppress(NotFoundError):
8585
await server.delete("Foreground")
8686

@@ -109,7 +109,10 @@ async def practice_jupyter_server(renku_image: str, server_name: str) -> AsyncIt
109109

110110
await server.create()
111111
yield server
112-
await server.delete("Foreground")
112+
# NOTE: This is used also in tests that check if the server was properly stopped
113+
# in this case the server will already be gone when we try to delete it in the cleanup here.
114+
with suppress(NotFoundError):
115+
await server.delete("Foreground")
113116

114117

115118
@pytest.fixture()

0 commit comments

Comments
 (0)