Skip to content

Commit

Permalink
Merge branch 'main' into ibm_shut_down
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaenr authored Nov 1, 2024
2 parents c751ff7 + 34a676a commit f95fdef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 43 deletions.
4 changes: 2 additions & 2 deletions docs/SLOs_validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ A couple of [alert profiles](https://github.com/redhat-chaos/krkn/tree/main/conf
severity: critical
```

Kube-burner supports setting the severity for the alerts with each one having different effects:
Krkn supports setting the severity for the alerts with each one having different effects:

```
info: Prints an info message with the alarm description to stdout. By default all expressions have this severity.
warning: Prints a warning message with the alarm description to stdout.
error: Prints a error message with the alarm description to stdout and makes kube-burner rc = 1
error: Prints a error message with the alarm description to stdout and sets Krkn rc = 1
critical: Prints a fatal message with the alarm description to stdout and exits execution inmediatly with rc != 0
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* [Scenarios](#scenarios)
* [Test Environment Recommendations - how and where to run chaos tests](#test-environment-recommendations---how-and-where-to-run-chaos-tests)
* [Chaos testing in Practice](#chaos-testing-in-practice)
* [OpenShift oraganization](#openshift-organization)
* [OpenShift organization](#openshift-organization)
* [startx-lab](#startx-lab)


Expand Down
46 changes: 6 additions & 40 deletions krkn/scenario_plugins/pvc/pvc_scenario_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions scenarios/openshift/pvc_scenario.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pvc_scenario:
namespace: <namespace_name> # 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

0 comments on commit f95fdef

Please sign in to comment.