Skip to content

Commit

Permalink
utils: set correct namespace for CVMFS deployment
Browse files Browse the repository at this point in the history
Set the correct namespace for CVMFS's PersistentVolumeClaim.

Closes reanahub#412
  • Loading branch information
mdonadoni committed Oct 27, 2023
1 parent 3729df2 commit 7e03f0a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changes
=======

Version 0.9.4 (UNRELEASED)
--------------------------

- Fixes the mounting of CVMFS volumes for the REANA deployments that use non-default Kubernetes namespace.

Version 0.9.3 (2023-09-26)
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion reana_commons/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def kubernetes_node_label_to_dict(node_label):
"""CVMFS repositories available for mounting."""

REANA_CVMFS_PVC_TEMPLATE = {
"metadata": {"name": ""},
"metadata": {"name": "", "namespace": ""},
"spec": {
"accessModes": ["ReadOnlyMany"],
"storageClassName": "",
Expand Down
17 changes: 10 additions & 7 deletions reana_commons/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""REANA-Commons utils."""


import copy
import datetime
import json
import logging
Expand All @@ -20,7 +21,7 @@
import uuid
from hashlib import md5
from pathlib import Path
from typing import Dict, Tuple, Optional
from typing import Dict, Optional, Tuple

import click
import requests
Expand All @@ -33,6 +34,7 @@
REANA_CVMFS_PVC_TEMPLATE,
REANA_CVMFS_SC_TEMPLATE,
REANA_JOB_CONTROLLER_CONNECTION_CHECK_SLEEP,
REANA_RUNTIME_KUBERNETES_NAMESPACE,
)
from reana_commons.errors import REANAMissingWorkspaceError

Expand Down Expand Up @@ -360,17 +362,18 @@ def get_disk_usage(
def render_cvmfs_pvc(cvmfs_volume):
"""Render REANA_CVMFS_PVC_TEMPLATE."""
name = CVMFS_REPOSITORIES[cvmfs_volume]
rendered_template = dict(REANA_CVMFS_PVC_TEMPLATE)
rendered_template["metadata"]["name"] = "csi-cvmfs-{}-pvc".format(name)
rendered_template["spec"]["storageClassName"] = "csi-cvmfs-{}".format(name)
rendered_template = copy.deepcopy(REANA_CVMFS_PVC_TEMPLATE)
rendered_template["metadata"]["name"] = f"csi-cvmfs-{name}-pvc"
rendered_template["metadata"]["namespace"] = REANA_RUNTIME_KUBERNETES_NAMESPACE
rendered_template["spec"]["storageClassName"] = f"csi-cvmfs-{name}"
return rendered_template


def render_cvmfs_sc(cvmfs_volume):
"""Render REANA_CVMFS_SC_TEMPLATE."""
name = CVMFS_REPOSITORIES[cvmfs_volume]
rendered_template = dict(REANA_CVMFS_SC_TEMPLATE)
rendered_template["metadata"]["name"] = "csi-cvmfs-{}".format(name)
rendered_template = copy.deepcopy(REANA_CVMFS_SC_TEMPLATE)
rendered_template["metadata"]["name"] = f"csi-cvmfs-{name}"
rendered_template["parameters"]["repository"] = cvmfs_volume
return rendered_template

Expand All @@ -396,7 +399,7 @@ def create_cvmfs_persistent_volume_claim(cvmfs_volume):

try:
current_k8s_corev1_api_client.create_namespaced_persistent_volume_claim(
"default", render_cvmfs_pvc(cvmfs_volume)
REANA_RUNTIME_KUBERNETES_NAMESPACE, render_cvmfs_pvc(cvmfs_volume)
)
except ApiException as e:
if e.status != 409:
Expand Down

0 comments on commit 7e03f0a

Please sign in to comment.