Skip to content

Commit

Permalink
Implement (un)stage/(un)publish volume according csi spec for mount m…
Browse files Browse the repository at this point in the history
…ode (#2195)
  • Loading branch information
antonmyagkov authored Oct 16, 2024
1 parent 6e1b371 commit 080c2ce
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 56 deletions.
57 changes: 55 additions & 2 deletions cloud/blockstore/tests/csi_driver/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,9 @@ def test_node_volume_expand(fs_type):
cleanup_after_test(env)


def test_publish_volume_twice_on_the_same_node():
env, run = init(vm_mode=True)
@pytest.mark.parametrize('vm_mode', [True, False])
def test_publish_volume_twice_on_the_same_node(vm_mode):
env, run = init(vm_mode=vm_mode)
try:
volume_name = "example-disk"
volume_size = 1024 ** 3
Expand All @@ -491,3 +492,55 @@ def test_publish_volume_twice_on_the_same_node():
with called_process_error_logged():
env.csi.delete_volume(volume_name)
cleanup_after_test(env)


def test_restart_kubelet_with_old_format_endpoint():
env, run = init()
try:
volume_name = "example-disk"
volume_size = 1024 ** 3
pod_name1 = "example-pod-1"
pod_id1 = "deadbeef1"
env.csi.create_volume(name=volume_name, size=volume_size)
# skip stage to create endpoint with old format
env.csi.publish_volume(pod_id1, volume_name, pod_name1)
# run stage/publish again to simulate kubelet restart
env.csi.stage_volume(volume_name)
env.csi.publish_volume(pod_id1, volume_name, pod_name1)
except subprocess.CalledProcessError as e:
log_called_process_error(e)
raise
finally:
with called_process_error_logged():
env.csi.unpublish_volume(pod_id1, volume_name)
with called_process_error_logged():
env.csi.unstage_volume(volume_name)
with called_process_error_logged():
env.csi.delete_volume(volume_name)
cleanup_after_test(env)


def test_restart_kubelet_with_new_format_endpoint():
env, run = init()
try:
volume_name = "example-disk"
volume_size = 1024 ** 3
pod_name1 = "example-pod-1"
pod_id1 = "deadbeef1"
env.csi.create_volume(name=volume_name, size=volume_size)
env.csi.stage_volume(volume_name)
env.csi.publish_volume(pod_id1, volume_name, pod_name1)
# run stage/publish again to simulate kubelet restart
env.csi.stage_volume(volume_name)
env.csi.publish_volume(pod_id1, volume_name, pod_name1)
except subprocess.CalledProcessError as e:
log_called_process_error(e)
raise
finally:
with called_process_error_logged():
env.csi.unpublish_volume(pod_id1, volume_name)
with called_process_error_logged():
env.csi.unstage_volume(volume_name)
with called_process_error_logged():
env.csi.delete_volume(volume_name)
cleanup_after_test(env)
Loading

0 comments on commit 080c2ce

Please sign in to comment.