Skip to content

Commit

Permalink
Randomize usage values for each ros-ocp line item
Browse files Browse the repository at this point in the history
  • Loading branch information
esebesto committed Jun 20, 2024
1 parent 28b07ea commit 5af1540
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "4.5.5"
__version__ = "4.5.6"

VERSION = __version__.split(".")
34 changes: 34 additions & 0 deletions nise/generators/ocp/ocp_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,43 @@ def _update_pod_data(self, row, start, end, **kwargs):
row.update(pod)
return row

def _randomize_ros_ocp_line_values(self, pod_in):
"""Randomize usage values for each line item or ROS report"""
values_to_randomize = [
"cpu_usage_container_avg",
"cpu_usage_container_min",
"cpu_usage_container_max",
"cpu_usage_container_sum",
"cpu_throttle_container_avg",
"cpu_throttle_container_max",
"cpu_throttle_container_sum",
"memory_usage_container_avg",
"memory_usage_container_min",
"memory_usage_container_max",
"memory_usage_container_sum",
"memory_rss_usage_container_avg",
"memory_rss_usage_container_min",
"memory_rss_usage_container_max",
"memory_rss_usage_container_sum",
]
randomization_value = uniform(0.9, 1.1)
pod_out = pod_in.copy()
for pod_key in values_to_randomize:
if pod_key.startswith("cpu"):
pod_out[pod_key] = round(
min(randomization_value * pod_in[pod_key], pod_in["cpu_limit_container_avg"]), 5
)
else:
pod_out[pod_key] = round(
min(randomization_value * pod_in[pod_key], pod_in["memory_limit_container_avg"])
)
return pod_out

def _update_ros_ocp_pod_data(self, row, start, end, **kwargs):
"""Update data with generator specific data."""
pod = kwargs.get("pod")

pod = self._randomize_ros_ocp_line_values(pod)
row.update(pod)
return row

Expand Down

0 comments on commit 5af1540

Please sign in to comment.