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 615731c commit 768098f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
43 changes: 32 additions & 11 deletions performance_measurement/measure_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,25 +228,48 @@ def run(self,
condition_1 = None
condition_2 = None
if sts_name_f:
last_revision = event_list[-1][0]["object"].status.update_revision
for sts_event, timestamp in event_list:
last_spec = input["spec"]["template"]["spec"]
last_spec_hash = hashlib.sha256(json.dumps(
last_spec, sort_keys=True).encode()).hexdigest()
for event, timestamp in event_list:
dt_object = datetime.fromtimestamp(timestamp)
logger.info(
f"{sts_event['type']} {sts_event['object'].metadata.name} at {timestamp} - {dt_object}")

f"{event['type']} {event['object'].metadata.name} at {timestamp} - {dt_object}")

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

if condition_2 is None:
if (sts_event["object"].status.ready_replicas == input["spec"]["replicas"]
and sts_event["object"].status.current_revision == last_revision):
if (event["object"].status.number_ready == input["spec"]["replicas"]
and current_spec_hash == last_spec_hash):
condition_2 = timestamp
break
else:
continue
# last_revision = event_list[-1][0]["object"].status.update_revision
# for sts_event, timestamp in event_list:
# dt_object = datetime.fromtimestamp(timestamp)
# logger.info(
# f"{sts_event['type']} {sts_event['object'].metadata.name} at {timestamp} - {dt_object}")

# if condition_1 is None:
# if sts_event["object"].status.update_revision == last_revision:
# condition_1 = timestamp
# else:
# continue

# if condition_2 is None:
# if (sts_event["object"].status.ready_replicas == input["spec"]["replicas"]
# and sts_event["object"].status.current_revision == last_revision):
# condition_2 = timestamp
# break
# else:
# continue
elif daemon_set_name_f:
last_spec = input["spec"]["template"]["spec"]
last_spec_hash = hashlib.sha256(json.dumps(
Expand Down Expand Up @@ -288,10 +311,8 @@ def run(self,
logging.info('Condition 2 took %f seconds' % duration_2)

with open("%s/sts-events-%03d.json" % (self.trial_dir, generation), 'w') as system_state_file:
json.dump([{"ts": ts, "statefulset": sts["object"].to_dict()} for sts, ts in event_list],
system_state_file,
cls=ActoEncoder,
indent=4)
json.dump([{"ts": ts, "statefulset": sts["object"].to_dict()}
for sts, ts in event_list], system_state_file, cls=ActoEncoder, indent=4)

self.collect_system_state()

Expand Down
32 changes: 32 additions & 0 deletions performance_measurement/rabbitmq_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,38 @@ def serialize(self, output_dir: str):
input["input"]["spec"]["replicas"] = 3
if "claims" in input["input"]["spec"]:
del input["input"]["spec"]["claims"]
if "resources" not in input["input"]["spec"] or input["input"]["spec"]["resources"] is None:
input["input"]["spec"]["resources"] = {
"limits": {
"cpu": "2",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
}
else:
if "limits" not in input["input"]["spec"]["resources"]:
input["input"]["spec"]["resources"]["limits"] = {
"cpu": "2",
"memory": "2Gi"
}
elif "cpu" not in input["input"]["spec"]["resources"]["limits"]:
input["input"]["spec"]["resources"]["limits"]["cpu"] = "2"
elif "memory" not in input["input"]["spec"]["resources"]["limits"]:
input["input"]["spec"]["resources"]["limits"]["memory"] = "2Gi"

if "requests" not in input["input"]["spec"]["resources"]:
input["input"]["spec"]["resources"]["requests"] = {
"cpu": "1",
"memory": "2Gi"
}
elif "cpu" not in input["input"]["spec"]["resources"]["requests"]:
input["input"]["spec"]["resources"]["requests"]["cpu"] = "1"
elif "memory" not in input["input"]["spec"]["resources"]["requests"]:
input["input"]["spec"]["resources"]["requests"]["memory"] = "2Gi"

patch = jsonpatch.JsonPatch.from_diff(previous_input, input["input"])
if patch:
print(patch)
Expand Down

0 comments on commit 768098f

Please sign in to comment.