diff options
author | alexvru <alexvru@ydb.tech> | 2023-08-23 18:19:55 +0300 |
---|---|---|
committer | alexvru <alexvru@ydb.tech> | 2023-08-23 19:46:59 +0300 |
commit | b06817ec9c498e9c30197f4b15f1afbeb398d4d6 (patch) | |
tree | 2540ddd7ad63ace07c155851d336f9e06cc6afc8 | |
parent | f78e40f7a3577213069c307eef50ced4b1461619 (diff) | |
download | ydb-b06817ec9c498e9c30197f4b15f1afbeb398d4d6.tar.gz |
Support readonly mode switching in dstool cluster workload run KIKIMR-17274
-rw-r--r-- | ydb/apps/dstool/lib/common.py | 15 | ||||
-rw-r--r-- | ydb/apps/dstool/lib/dstool_cmd_cluster_workload_run.py | 23 |
2 files changed, 36 insertions, 2 deletions
diff --git a/ydb/apps/dstool/lib/common.py b/ydb/apps/dstool/lib/common.py index 3c7f657ef3..cdc64a6a7b 100644 --- a/ydb/apps/dstool/lib/common.py +++ b/ydb/apps/dstool/lib/common.py @@ -399,6 +399,21 @@ def create_wipe_request(args, vslot): return request +def create_readonly_request(args, vslot, value): + request = create_bsc_request(args) + cmd = request.Command.add().SetVDiskReadOnly + cmd.VSlotId.NodeId = vslot.VSlotId.NodeId + cmd.VSlotId.PDiskId = vslot.VSlotId.PDiskId + cmd.VSlotId.VSlotId = vslot.VSlotId.VSlotId + cmd.VDiskId.GroupID = vslot.GroupId + cmd.VDiskId.GroupGeneration = vslot.GroupGeneration + cmd.VDiskId.Ring = vslot.FailRealmIdx + cmd.VDiskId.Domain = vslot.FailDomainIdx + cmd.VDiskId.VDisk = vslot.VDiskIdx + cmd.Value = value + return request + + def invoke_wipe_request(request): return invoke_bsc_request(request) diff --git a/ydb/apps/dstool/lib/dstool_cmd_cluster_workload_run.py b/ydb/apps/dstool/lib/dstool_cmd_cluster_workload_run.py index 3b48145db8..0a7a6810d0 100644 --- a/ydb/apps/dstool/lib/dstool_cmd_cluster_workload_run.py +++ b/ydb/apps/dstool/lib/dstool_cmd_cluster_workload_run.py @@ -12,6 +12,7 @@ description = 'Create workload to stress failure model' def add_options(p): p.add_argument('--disable-wipes', action='store_true', help='Disable VDisk wipes') + p.add_argument('--disable-readonly', action='store_true', help='Disable VDisk SetVDiskReadOnly requests') p.add_argument('--disable-evicts', action='store_true', help='Disable VDisk evicts') p.add_argument('--disable-restarts', action='store_true', help='Disable node restarts') p.add_argument('--enable-pdisk-encryption-keys-changes', action='store_true', help='Enable changes of PDisk encryption keys') @@ -88,6 +89,12 @@ def do(args): for vslot in base_config.VSlot: assert not vslot.Ready or vslot.Status == 'READY' + vslot_readonly = { + common.get_vslot_id(vslot.VSlotId) + for vslot in base_config.VSlot + if vslot.ReadOnly + } + if (len(pdisk_keys) == 0): # initialize pdisk_keys and pdisk_key_versions for node_id in {pdisk.NodeId for pdisk in base_config.PDisk}: @@ -157,10 +164,18 @@ def do(args): assert can_act_on_vslot(*common.get_vslot_id(vslot.VSlotId)) try: request = common.create_wipe_request(args, vslot) - common.invoke_wipe_request(request) + common.invoke_bsc_request(request) except Exception as e: raise Exception('Failed to perform wipe request: %s' % e) + def do_readonly(vslot, value): + assert not value or can_act_on_vslot(*common.get_vslot_id(vslot.VSlotId)) + try: + request = common.create_readonly_request(args, vslot, value) + common.invoke_bsc_request(request) + except Exception as e: + raise Exception('Failed to perform readonly request: %s' % e) + def do_add_pdisk_key(node_id): pdisk_key_versions[node_id] += 1 v = pdisk_key_versions[node_id] @@ -181,12 +196,16 @@ def do(args): for vslot in base_config.VSlot: if common.is_dynamic_group(vslot.GroupId): vslot_id = common.get_vslot_id(vslot.VSlotId) + vdisk_id = '[%08x:%d:%d:%d]' % (vslot.GroupId, vslot.FailRealmIdx, vslot.FailDomainIdx, vslot.VDiskIdx) + if vslot_id in vslot_readonly and not args.disable_readonly: + possible_actions.append(('un-readonly vslot id: %s, vdisk id: %s' % (vslot_id, vdisk_id), (do_readonly, vslot, False))) if can_act_on_vslot(*vslot_id) and (recent_restarts or args.disable_restarts): - vdisk_id = '[%08x:%d:%d:%d]' % (vslot.GroupId, vslot.FailRealmIdx, vslot.FailDomainIdx, vslot.VDiskIdx) if not args.disable_evicts: possible_actions.append(('evict vslot id: %s, vdisk id: %s' % (vslot_id, vdisk_id), (do_evict, vslot_id))) if not args.disable_wipes: possible_actions.append(('wipe vslot id: %s, vdisk id: %s' % (vslot_id, vdisk_id), (do_wipe, vslot))) + if not args.disable_readonly: + possible_actions.append(('readonly vslot id: %s, vdisk id: %s' % (vslot_id, vdisk_id), (do_readonly, vslot, True))) if start_time_map and len(recent_restarts) < 3: # sort so that the latest restarts come first |