Skip to content

Commit 1cf534f

Browse files
committed
✨ Make CoW Support dynamic
Signed-off-by: Muhammed Hussain Karimi <[email protected]>
1 parent 6fae849 commit 1cf534f

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

rawfile/bd2fs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def CreateSnapshot(self, request: csi_pb2.CreateSnapshotRequest, context):
300300
copy_on_write = (
301301
copy_on_write_param
302302
if copy_on_write_param is not None
303-
else consts.COW_SUPPORTED
303+
else consts.COW_SUPPORT_MAP.get(volume_meta["storage_pool"], False)
304304
)
305305

306306
def _get_current_snapshot():

rawfile/consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
CSI_K8S_PVC_NAME_KEY = "csi.storage.k8s.io/pvc/name"
1515
GA_ID = "Ry1UWkdQNDY2MThX"
1616
GA_KEY = "OTFKR2RUZzlRd0duN1ktdnZ1TTR6QQ=="
17+
COW_SUPPORT_MAP = {}

rawfile/rawfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import consts
1818
from analytics.ga4 import run_ping, shutdown_event_worker, run_event_worker
1919
from orchestrator.k8s import node_ip_mapping
20+
from utils.rawfile import is_cow_supported
2021
from utils.volume_manager import manager as volume_manager
2122
from setproctitle import setproctitle
2223
import os
@@ -47,7 +48,10 @@ def node_driver_preflight_checks(task_manager: task_manager.TaskManager):
4748
volume_manager.migrate_metadata_dir()
4849
volume_manager.migrate_all_volume_schemas()
4950
task_manager.migrate_tasks_file_path()
50-
# consts.COW_SUPPORTED = is_cow_supported(data_dir)
51+
consts.COW_SUPPORT_MAP = {
52+
name: is_cow_supported(pool.path)
53+
for name, pool in config.csi_driver.storage_pools.items()
54+
}
5155

5256

5357
def csi_driver(driver_config: CSIDriverCmd):

rawfile/utils/volume_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ def create_volume(
9292
temporary=True,
9393
copy_on_write=source_meta.get("copy_on_write", None)
9494
if source_meta.get("copy_on_write", None) is not None
95-
else (consts.COW_SUPPORTED or False),
95+
else (
96+
consts.COW_SUPPORT_MAP.get(
97+
source_meta["storage_pool"], False
98+
)
99+
),
96100
freeze_fs=source_meta.get("freezefs", False),
97101
)
98102
with VolLock(volume_id):

0 commit comments

Comments
 (0)