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

fix: don't fail session launch when gitlab couldn't be reached #3727

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
Changes
=======

`2.9.3 <https://github.com/SwissDataScienceCenter/renku-python/compare/v2.9.2...v2.9.3>`__ (2024-04-08)
-------------------------------------------------------------------------------------------------------

Bug Fixes
~~~~~~~~~

- make doctor fix for workflow ids also update oid and derived_from
(`#3723 <https://github.com/SwissDataScienceCenter/renku-python/issues/3723>`__)
(`050ed61 <https://github.com/SwissDataScienceCenter/renku-python/commit/050ed61bf13264b2b446e054e6071a5932280290>`__)

`2.9.2 <https://github.com/SwissDataScienceCenter/renku-python/compare/v2.9.1...v2.9.2>`__ (2024-02-06)
-------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion helm-chart/renku-core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ appVersion: "1.0"
description: A Helm chart for Kubernetes
name: renku-core
icon: https://avatars0.githubusercontent.com/u/53332360?s=400&u=a4311d22842343604ef61a8c8a1e5793209a67e9&v=4
version: 2.9.2
version: 2.9.3
2 changes: 1 addition & 1 deletion helm-chart/renku-core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ global:
versions:
latest:
image:
tag: v2.9.2
tag: v2.9.3
18 changes: 16 additions & 2 deletions renku/command/checks/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Checks needed to determine integrity of workflows."""

from datetime import timedelta
from typing import List, Optional, Tuple, cast

Expand Down Expand Up @@ -145,14 +146,17 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt
plans: List[AbstractPlan] = plan_gateway.get_all_plans()

to_be_processed = []
to_be_processed_derived = []
for plan in plans:
if isinstance(plan.id, str) and plan.id.startswith("/plans//plans"):
to_be_processed.append(plan)
if isinstance(plan.derived_from, str) and plan.derived_from.startswith("/plans//plans"):
to_be_processed_derived.append(plan)

if not to_be_processed:
if not to_be_processed and not to_be_processed_derived:
return True, False, None
if not fix:
ids = [plan.id for plan in to_be_processed]
ids = [plan.id for plan in to_be_processed + to_be_processed_derived]
message = (
WARNING
+ "The following workflows have incorrect IDs (use 'renku doctor --fix' to fix them):\n\t"
Expand All @@ -163,7 +167,17 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt
for plan in to_be_processed:
plan.unfreeze()
plan.id = plan.id.replace("//plans/", "/")
plan.reassign_oid()
plan._p_changed = True
plan.freeze()

for plan in to_be_processed_derived:
if plan.derived_from is not None:
plan.unfreeze()
plan.derived_from = plan.derived_from.replace("//plans/", "/")
plan._p_changed = True
plan.freeze()

project_context.database.commit()
communication.info("Workflow IDs were fixed")

Expand Down
14 changes: 13 additions & 1 deletion renku/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import configparser
import os
from io import StringIO
from pathlib import Path

from renku.core.constant import DATA_DIR_CONFIG_KEY
from renku.domain_model.enums import ConfigFilter
Expand All @@ -28,13 +29,21 @@ def global_config_read_lock():
"""Create a user-level config read lock."""
from renku.core.util.contexts import Lock

lock_path = os.environ.get("RENKU_LOCK_PATH")
if lock_path is not None:
return Lock(Path(lock_path))

return Lock(project_context.global_config_path)


def global_config_write_lock():
"""Create a user-level config write lock."""
from renku.core.util.contexts import Lock

lock_path = os.environ.get("RENKU_LOCK_PATH")
if lock_path is not None:
return Lock(Path(lock_path), mode="exclusive")

return Lock(project_context.global_config_path, mode="exclusive")


Expand Down Expand Up @@ -112,7 +121,10 @@ def load_config(config_filter=ConfigFilter.ALL):
elif config_filter == ConfigFilter.GLOBAL_ONLY:
config_files += [project_context.global_config_path]
elif config_filter == ConfigFilter.ALL:
config_files += [project_context.global_config_path, project_context.local_config_path]
config_files += [
project_context.global_config_path,
project_context.local_config_path,
]

if config_filter != ConfigFilter.LOCAL_ONLY:
with global_config_read_lock():
Expand Down
42 changes: 33 additions & 9 deletions renku/core/session/renkulab.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def _wait_for_session_status(
start = monotonic()
while monotonic() - start < self.DEFAULT_TIMEOUT_SECONDS:
res = self._send_renku_request(
"get", f"{self._notebooks_url()}/servers/{name}", headers=self._auth_header()
"get",
f"{self._notebooks_url()}/servers/{name}",
headers=self._auth_header(),
)
if res.status_code == 404 and status == "stopping":
return
Expand Down Expand Up @@ -266,10 +268,15 @@ def find_image(self, image_name: str, config: Optional[Dict[str, Any]]) -> bool:
def get_cloudstorage(self):
"""Get cloudstorage configured for the project."""
storage_service = cast(IStorageService, inject.instance(IStorageService))
project_id = storage_service.project_id

try:
project_id = storage_service.project_id
except errors.ProjectNotFound:
project_id = None

if project_id is None:
communication.warn("Couldn't get project ID from Gitlab, skipping mounting cloudstorage")
return
communication.warn("Skipping cloud storage mounting as project couldn't be loaded from gitlab.")
return []

storages = storage_service.list(project_id)

Expand All @@ -291,7 +298,12 @@ def get_cloudstorage(self):
secret = communication.prompt(f"{field['help']}\nPlease provide a value for secret '{name}'")
storage.configuration[name] = secret

storages_to_mount.append({"storage_id": storage.storage_id, "configuration": storage.configuration})
storages_to_mount.append(
{
"storage_id": storage.storage_id,
"configuration": storage.configuration,
}
)

return storages_to_mount

Expand Down Expand Up @@ -447,21 +459,27 @@ def session_stop(self, project_name: str, session_name: Optional[str], stop_all:
for session in sessions:
responses.append(
self._send_renku_request(
"delete", f"{self._notebooks_url()}/servers/{session.id}", headers=self._auth_header()
"delete",
f"{self._notebooks_url()}/servers/{session.id}",
headers=self._auth_header(),
)
)
self._wait_for_session_status(session.id, "stopping")
elif session_name:
responses.append(
self._send_renku_request(
"delete", f"{self._notebooks_url()}/servers/{session_name}", headers=self._auth_header()
"delete",
f"{self._notebooks_url()}/servers/{session_name}",
headers=self._auth_header(),
)
)
self._wait_for_session_status(session_name, "stopping")
elif n_sessions == 1:
responses.append(
self._send_renku_request(
"delete", f"{self._notebooks_url()}/servers/{sessions[0].id}", headers=self._auth_header()
"delete",
f"{self._notebooks_url()}/servers/{sessions[0].id}",
headers=self._auth_header(),
)
)
self._wait_for_session_status(sessions[0].id, "stopping")
Expand All @@ -474,7 +492,13 @@ def session_stop(self, project_name: str, session_name: Optional[str], stop_all:

return SessionStopStatus.SUCCESSFUL if n_successfully_stopped == n_sessions else SessionStopStatus.FAILED

def session_open(self, project_name: str, session_name: Optional[str], ssh: bool = False, **kwargs) -> bool:
def session_open(
self,
project_name: str,
session_name: Optional[str],
ssh: bool = False,
**kwargs,
) -> bool:
"""Open a given interactive session.

Args:
Expand Down
Loading