Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Nov 19, 2023
1 parent 980da48 commit d0f12be
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions performance_measurement/measure_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import kubernetes
import kubernetes.client.models as k8s_models
import jsonpatch
import yaml
from check_utils import (check_affinity,
check_persistent_volume_claim_retention_policy,
Expand Down Expand Up @@ -228,24 +229,30 @@ def run(self,
condition_1 = None
condition_2 = None
if sts_name_f:
last_spec = input["spec"]["template"]["spec"]
last_spec = event_list[-1][0].to_dict()["spec"]
last_spec_hash = hashlib.sha256(json.dumps(
last_spec, sort_keys=True).encode()).hexdigest()

prev_spec = None
for event, timestamp in event_list:
obj_dict = event['object'].to_dict()
dt_object = datetime.fromtimestamp(timestamp)
logger.info(
f"{event['type']} {event['object'].metadata.name} at {timestamp} - {dt_object}")
patch = jsonpatch.JsonPatch.from_diff(prev_spec, obj_dict["spec"])
logger.info(f"Patch: {patch}")

prev_spec = obj_dict["spec"]
current_spec_hash = hashlib.sha256(json.dumps(
event["object"].spec.template.spec, sort_keys=True).encode()).hexdigest()
obj_dict["spec"], sort_keys=True).encode()).hexdigest()
if condition_1 is None:
if current_spec_hash == last_spec_hash:
condition_1 = timestamp
else:
continue

if condition_2 is None:
if (event["object"].status.number_ready == input["spec"]["replicas"]
if (obj_dict["status"]["number_ready"] == input["spec"]["replicas"]
and current_spec_hash == last_spec_hash):
condition_2 = timestamp
break
Expand All @@ -271,16 +278,22 @@ def run(self,
# else:
# continue
elif daemon_set_name_f:
last_spec = input["spec"]["template"]["spec"]
last_spec = event_list[-1][0].to_dict()["spec"]
last_spec_hash = hashlib.sha256(json.dumps(
last_spec, sort_keys=True).encode()).hexdigest()
prev_spec = None

for ds_event, timestamp in event_list:
obj_dict = event['object'].to_dict()
dt_object = datetime.fromtimestamp(timestamp)
logger.info(f"{ds_event['type']} {ds_event['object'].metadata.name} at {timestamp} - {dt_object}")
logger.info(
f"{ds_event['type']} {obj_dict['metadata']['name']} at {timestamp} - {dt_object}")
patch = jsonpatch.JsonPatch.from_diff(prev_spec, obj_dict["spec"])
logger.info(f"Patch: {patch}")

prev_spec = obj_dict["spec"]
current_spec_hash = hashlib.sha256(json.dumps(
ds_event["object"].spec.template.spec, sort_keys=True).encode()).hexdigest()
obj_dict["spec"], sort_keys=True).encode()).hexdigest()
if condition_1 is None:
if current_spec_hash == last_spec_hash:
condition_1 = timestamp
Expand Down

0 comments on commit d0f12be

Please sign in to comment.