From 34a676a7954ac4b125e54a73894a51de2315f2db Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Mon, 28 Oct 2024 16:45:33 +0100 Subject: [PATCH] block_size parameter for dd (#719) removed log Signed-off-by: Tullio Sebastiani --- .../pvc/pvc_scenario_plugin.py | 46 +++---------------- scenarios/openshift/pvc_scenario.yaml | 1 + 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/krkn/scenario_plugins/pvc/pvc_scenario_plugin.py b/krkn/scenario_plugins/pvc/pvc_scenario_plugin.py index b252d627..731f02b5 100644 --- a/krkn/scenario_plugins/pvc/pvc_scenario_plugin.py +++ b/krkn/scenario_plugins/pvc/pvc_scenario_plugin.py @@ -29,6 +29,9 @@ def run( pvc_name = get_yaml_item_value(scenario_config, "pvc_name", "") pod_name = get_yaml_item_value(scenario_config, "pod_name", "") namespace = get_yaml_item_value(scenario_config, "namespace", "") + block_size = get_yaml_item_value( + scenario_config, "block_size", "102400" + ) target_fill_percentage = get_yaml_item_value( scenario_config, "fill_percentage", "50" ) @@ -197,10 +200,12 @@ def run( str(full_path), ) elif dd is not None: + block_size = int(block_size) + blocks = int(file_size_kb / int(block_size / 1024)) logging.warning( "fallocate not found, using dd, it may take longer based on the amount of data, please wait..." ) - command = f"dd if=/dev/urandom of={str(full_path)} bs=1024 count={str(file_size_kb)} oflag=direct" + command = f"dd if=/dev/urandom of={str(full_path)} bs={str(block_size)} count={str(blocks)} oflag=direct" else: logging.error( "failed to locate required binaries fallocate or dd to execute the scenario" @@ -241,45 +246,6 @@ def run( ) return 1 - # Calculate file size - file_size_kb = int( - (float(target_fill_percentage / 100) * float(pvc_capacity_kb)) - - float(pvc_used_kb) - ) - logging.debug("File size: %s KB" % file_size_kb) - - file_name = "kraken.tmp" - logging.info( - "Creating %s file, %s KB size, in pod %s at %s (ns %s)" - % ( - str(file_name), - str(file_size_kb), - str(pod_name), - str(mount_path), - str(namespace), - ) - ) - - start_time = int(time.time()) - # Create temp file in the PVC - full_path = "%s/%s" % (str(mount_path), str(file_name)) - command = "fallocate -l $((%s*1024)) %s" % ( - str(file_size_kb), - str(full_path), - ) - logging.debug("Create temp file in the PVC command:\n %s" % command) - lib_telemetry.get_lib_kubernetes().exec_cmd_in_pod( - [command], pod_name, namespace, container_name - ) - - # Check if file is created - command = "ls -lh %s" % (str(mount_path)) - logging.debug("Check file is created command:\n %s" % command) - response = lib_telemetry.get_lib_kubernetes().exec_cmd_in_pod( - [command], pod_name, namespace, container_name - ) - logging.info("\n" + str(response)) - if str(file_name).lower() in str(response).lower(): logging.info( "Waiting for the specified duration in the config: %ss" % duration ) diff --git a/scenarios/openshift/pvc_scenario.yaml b/scenarios/openshift/pvc_scenario.yaml index daa3e297..54bdb93b 100644 --- a/scenarios/openshift/pvc_scenario.yaml +++ b/scenarios/openshift/pvc_scenario.yaml @@ -4,3 +4,4 @@ pvc_scenario: namespace: # Namespace where the PVC is fill_percentage: 50 # Target percentage to fill up the cluster, value must be higher than current percentage, valid values are between 0 and 99 duration: 60 # Duration in seconds for the fault + block_size: 102400 # used only by dd if fallocate not present in the container