Skip to content

Add node_clock_drift Problem - #894

Merged
Saadmrp1038 merged 25 commits into
SREGym:mainfrom
haani-maybe:clock-drift
Jul 6, 2026
Merged

Saadmrp1038 merged 25 commits into
SREGym:mainfrom
haani-maybe:clock-drift

Conversation

@haani-maybe

Copy link
Copy Markdown
Contributor

Node Clock Drift Causing TLS Handshake Failures on Hotel Reservation

This PR adds a new SREGym problem, node_clock_drift_hotel_reservation, as part of my evaluation task for UIUC++ SRSE.

It models a worker node's system clock drifting significantly forward after its time-sync service is disabled. All pods on that node fail outbound TLS connections with certificate has expired or is not yet valid, even though the certificate itself is completely healthy. The interesting part for an agent is that kubectl get pods looks completely normal (Running/Ready), and the certificate, inspected on its own, is valid; the broken state only becomes visible once the agent connects the node's clock to the TLS validation failures.

NOTE for test environment: this problem can't be simulated on kind. Containers on the same Docker host share the host kernel's clock; drifting one "node" (container) would drift the system clock for all of them. A 3 node CloudLab cluster running Ubuntu 22.04 was used instead.

Related RFC: #826

/validate-problem node_clock_drift_hotel_reservation

1. Real-world failure story

TLS validation checks a certificate's notBefore/notAfter window against the local system clock, not against any external source of truth. If a node's clock is wrong, even a perfectly valid certificate appears expired or not-yet-valid from that node's perspective.

This pattern recurs across unrelated stacks once time-sync stops running: kubernetes/kubernetes#76714 (kubelet TLS failures from clock skew), hashicorp/vault#11150 (Vault cert renewal failing the same way), and a D2iQ support article documenting an etcd cluster rejecting connections with the identical x509 error while kubectl get pods reported a fully healthy cluster. The Cloudflare leap-second postmortem was additional inspiration for how small, time-sync-driven clock steps can cascade into TLS failures cluster-wide.

References:

2. How the failure is simulated on SREGym

The problem targets the Hotel Reservation app in the hotel-reservation namespace, specifically the frontend deployment and whichever worker node it's scheduled on.

hotel_reservation doesn't have a native TLS surface (services talk to each other over plain HTTP, no ingress controller deployed), so fault injection first builds a minimal one to break:

  1. Generates a self-signed certificate with a 1-day validity window, short enough to guarantee it's expired well within the 30-day clock-drift window used later.
  2. Stores it as a kubernetes.io/tls Secret (hotel-frontend-tls).
  3. Stores the same cert as a plain ConfigMap (hotel-frontend-ca), mounted into a sidecar as the CA bundle.
  4. Patches the frontend deployment to add a tls-health-check sidecar that runs openssl verify against the mounted cert every 30 seconds — simulating a service performing routine outbound TLS validation. This is the only way to surface a TLS-shaped log signal, since the app itself has no real TLS surface to break. apt-get install openssl runs once at sidecar startup, before the clock is touched, so it isn't blocked by the drift that follows.
  5. Waits for the sidecar rollout to fully land (new pod Running, all containers ready, sidecar present) before selecting a target node.
  6. Selects the node currently running the frontend pod that has the sidecar.
  7. Deploys a privileged pod (hostPID/hostNetwork/hostIPC) that uses nsenter to dynamically discover whichever time-sync service is currently active (queries systemctl list-units --state=running for any unit matching ntp|chrony|timesync), stops and masks it, then advances the system clock 30 days forward via date -s.

The injector pod stays alive for the duration of the fault so the clock change persists. Recovery deletes all clock-drift injector pods; it does not automatically restore the time-sync service or roll back the clock, since reversing the fault yourself isn't a valid mitigation strategy.

Bugs found and fixed during testing

Rollout race condition. The deployment patch that adds the sidecar triggers a rolling update. During testing, the old frontend pod (no sidecar) could still be Running on its original node at the exact moment node selection ran, while the new pod (with sidecar) was being scheduled to a different node, causing the clock drift to target a node the sidecar never ran on. Fixed by adding _wait_for_sidecar_rollout(), which polls until a frontend pod is Running with the sidecar container present and ready, and tightening node selection to only match pods that actually have the tls-health-check container.

Hardcoded time-sync service name. The original injector tried to mask systemd-timesyncd, chrony, and ntpd by fixed name. On the actual CloudLab test cluster, none of those three matched; the real service was running as legacy ntpd under the systemd unit name ntp.service (no "d"). This silently failed to disable time-sync at all, since systemctl stop ntpd doesn't match a unit literally named ntp. Fixed by querying systemctl list-units for any currently running service matching ntp|chrony|timesync and acting on whatever is actually found, rather than guessing names. This makes the fault portable across environments without needing to maintain an exhaustive daemon name list.

3. Problem runtime behavior and mitigation oracle

After injection, pod health looks normal:

kubectl get pods -n hotel-reservation

frontend shows 2/2 Running, no restarts. The diagnostic signal isn't in pod status — it's in the sidecar's behavior and the node's own clock:

kubectl logs <frontend-pod> -c tls-health-check

Expected output (recurring every 30s once drift hits):

error 10 at 0 depth lookup: certificate has expired

Cross-checking the node directly confirms the root cause:

kubectl debug node/<node> --profile=sysadmin -it --image=ubuntu:22.04 -- bash
nsenter --target 1 --mount --pid -- date
nsenter --target 1 --mount --pid -- systemctl list-units --type=service --state=running | grep -iE 'ntp|chrony|timesync'

date reports a timestamp ~30 days ahead of the rest of the cluster. The second command reveals which time-sync service is actually masked; on the CloudLab test cluster this was ntp.service; the specific service name is environment-dependent, which is why the oracle (below) doesn't check for any specific daemon by name.

A correct diagnosis identifies the actual cause: the certificate is healthy, the node's clock is wrong, and that skew is what makes TLS validation fail.

The canonical mitigation, from a privileged pod on the affected node (substituting whatever service name was found above ntp as an example):

nsenter --target 1 --mount --uts --ipc --net --pid -- systemctl unmask ntp
nsenter --target 1 --mount --uts --ipc --net --pid -- systemctl start ntp

Restarting the frontend pod alone should not pass as the node's clock is still skewed, so a new pod scheduled on the same node would immediately hit the same TLS failure once the sidecar runs again.

Oracle behavior

The default pod-health oracle can't grade this either, since pods stay Running/Ready throughout, so this PR adds NodeClockDriftMitigationOracle.

It passes only when:

  1. The node's clock is within 60 seconds of the conductor's own clock.
  2. No pod on the affected node is in a non-Running/Succeeded phase, or shows a waiting/terminated container state referencing certificate or tls.

4. Agent behavior and validation

Manual testing (kubectl/cli.py): confirmed the fault injects correctly (clock confirmed skewed via kubectl debug node, x509 errors confirmed appearing in sidecar logs), and the oracle correctly returns False while the clock remains skewed and True once the time-sync service is unmasked, restarted, and the clock resyncs.

Stratus, three runs (judge matching model):

Run Model Diagnosis
1 gpt-4o-mini Failed; attributed restarts to a PVC delay on the geo pod
2 gpt-4o Failed; attributed restarts to a Jaeger tracing config issue
3 gpt-4o Failed; attributed restarts to a Jaeger tracing misconfiguration/connectivity issue

gpt-4o-mini was expected to underperform; testing with gpt-4o was included as a stronger baseline but produced similarly unsuccessful diagnoses, plan to test against a more capable model as well if this approach for the problem is okay.

In all runs the agent noticed several pods had nonzero restart counts and investigated logs, events, the Jaeger dependency graph, and Prometheus CPU/memory metrics (all of which were clean) and never inspected the frontend pod specifically (despite it being the only pod with 2/2 containers instead of 1/1), nor checked node clocks, time-sync status or any time related detail on any node. This matches the intended difficulty: the certificate itself is valid, so log-level and metric-level investigation alone doesn't surface the fault, and the agent has to connect node clock state to the TLS symptom.

@haani-maybe

haani-maybe commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Quick note: I'll run a few more agent runs for further testing purposes on different models if this solution approach is okay, for now I've only tested on gpt 4o with Stratus.

I'd appreciate any feedback or any type of suggestions for the code, for both the mitigation oracle as well as the injection

@Saadmrp1038
Saadmrp1038 self-requested a review June 18, 2026 17:39
@Saadmrp1038 Saadmrp1038 added the problem Adding a new problem to the benchmark label Jun 18, 2026

@Saadmrp1038 Saadmrp1038 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haani-maybe Thanks for the effort!

I ran and tested the problem end-to-end on a 3-node CloudLab cluster. I found some issues. I left inline comments below with details. Please ping me when you've addressed them.

Comment thread sregym/conductor/problems/registry.py Resolved
@haani-maybe

haani-maybe commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@Saadmrp1038 hii, updated! sorry for the delay

the changed code is all the fixes you mentioned (elaborated in the replies to your code review comments) + one tiny thing more, i added a guard to ensure the node we're injecting on is one of the worker nodes (not control node)
this wasn't necessary since control node's are tainted so pods arent scheduled on them, but while I was running it I saw it happen on 2 runs out of around 10, which i assume was an issue on cloudlab setup end, so i added that just incase.

although once again the control node IS tainted within standard setup so this wouldn't be a problem, but just incase someone else is running the problem and there's an issue in setup due to which the taint isn't present or misconfigured, the guard might help clarify
(_WORKER_ONLY_AFFINITY in node_clock_drift.py, line 40 onwards as well as is_control_plane_node, same file, line 98 and onwards)

please let me know if the fixes are fine and if there's anything else to add/edit :)

@Saadmrp1038 Saadmrp1038 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haani-maybe Sorry for the delayed review.
I tested the fault thoroughly and did not find any major bugs. Only found some minor things. Can you please address them. Meanwhile I will do some agent runs.

@haani-maybe

Copy link
Copy Markdown
Contributor Author

@haani-maybe Sorry for the delayed review. I tested the fault thoroughly and did not find any major bugs. Only found some minor things. Can you please address them. Meanwhile I will do some agent runs.

@Saadmrp1038 No worries! I added in all the required changes, let me know if there's anything else

@Saadmrp1038 Saadmrp1038 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haani-maybe Working great now!

I did 5 agent runs on this (claudecode+sonnet-5). 4 times the agent failed both diagnosis and mitigation. The only time it succeeded was when I added a hint ("Check node clock") in the prompt. Without the hint, agents get stuck investigating the sidecar's cert expiry or startup restarts and never make the leap to checking the node's system clock.

So, seems like it's quite a hard problem which is exactly what we want for the benchmark. Also, thanks for taking the time. It took quite a while for me to review this PR.

Congrats on the first PR merged here 🎉

@Saadmrp1038
Saadmrp1038 merged commit e62c696 into SREGym:main Jul 6, 2026
@tianyin

tianyin commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

WoW This is incredible persistence!

@haani-maybe

Copy link
Copy Markdown
Contributor Author

@haani-maybe Working great now!

I did 5 agent runs on this (claudecode+sonnet-5). 4 times the agent failed both diagnosis and mitigation. The only time it succeeded was when I added a hint ("Check node clock") in the prompt. Without the hint, agents get stuck investigating the sidecar's cert expiry or startup restarts and never make the leap to checking the node's system clock.

So, seems like it's quite a hard problem which is exactly what we want for the benchmark. Also, thanks for taking the time. It took quite a while for me to review this PR.

Congrats on the first PR merged here 🎉

No worries at all! Glad I could start contributing here :)

@tianyin

tianyin commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@haani-maybe I'm not sure if you are already in the Slack or are here for the UIUC+ program. If so, let me know so I can add you into the channels.

@haani-maybe

haani-maybe commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor Author

@haani-maybe I'm not sure if you are already in the Slack or are here for the UIUC+ program. If so, let me know so I can add you into the channels.

@tianyin I joined the Slack (reu-2026-general and benchmark channel) when I got the evaluation task email for the UIUC+ program, are there any other channels I have to join for the program?

@tianyin

tianyin commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Can you DM me on the Slack? I can't find you... (and I'm guessing you don't want to reveal your name/ID on GitHub)

vsmart-06 pushed a commit to vsmart-06/SREGym that referenced this pull request Jul 12, 2026
* adding clock drift problem

* fixing race condition causing sidecar log delay

* fixing recover_fault to reverse time sync removal applied, improve cleanup

* global cleanup added + fixed restoration for node_clock_drift problem

* fixing mitigation oracle to ensure correct node checked

* adding problem to non emulated cluster problems list

* extending wait

* indentation error fix

* fixing time restoration in global cleanup

* adding in check to make sure it picks worker node

* adding another control plane filter, fixing clock step-back in global recovery

* increase sidecar rollout timeout, make podnames/labels generic, idempotancy check

* formatting fixes

* format fix

* fix

* fix ruff check/format issues

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>
Saadmrp1038 added a commit that referenced this pull request Jul 22, 2026
* Updated default mitigation oracle

* Stop timeout for 0 replicas

* TBC in CloudLab

* Pushing all attempts at the problem

* Enable idempotence

* Add mutating_webhook_resource_limits problem (#847)

* Add mutating_webhook_resource_limits problem

* Add mutating_webhook_resource_limits to Problem List

* mutating_webhook_resource_limits problem docstring fix

Removed incorrect information about mitigation options.

* Additions to mutating_webhook_limits_resource_limits problem

 - Memory limit/request patching before activating the webhook
 - Decoy pods for increased complexity

* More additions to mutating_webhook problem

 - Make decoys realisticly named
 - Similar minor changes

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Derive the default problem namespace from the application (#876)

* add the the probem redundency

* base.

* the fixed and dynamic app name are fixed. hte namespace are also fixed.

* unessessry formating is reverted.

* unessessry formating is reverted.

* formating correction.

* formating correction.

* formating correction.

* add fault injection decorator markers to test_problem_bsae.py

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Confluent kafka attempt

* Custom image attempt

* Threaded producer and added consumer

* Syntax error

* Added some imports

* fix edge cases

* run ruff check adn format

* New OOM attempt

* Force crash on OOM

* Add file_descriptor_exhaustion problem (#832)

* add file_descriptor_exhaustion problem

* Modify fault injection and recovery methods

* Fix fault recovery

* Change fault injection method
Add fault injection by flooding connections

* Update fault injection method and add custom oracle

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Finalizer deadlock controller clean (#873)

* finalizzer code is reaoslve dadlock benchmark.

* yaml file corrected.

* reverting hte comments back to their place.

* read only rbac

* controller log is generalized and avoiding any sregym related name exposing.

* applied ruff linter formatter accordingly.

* replace metadata naming and includding all the oprations on mitigation side.

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Add: secret_rotation_stale_env_credentials_astronomy_shop problem (#851)

* Add secret rotation stale env credentials problem

* Simplify secret rotation mitigation oracle checks

* Require rotated PostgreSQL in oracle

* Fix stale DB credential rotation shortcuts

  - Remove old password from postgresql-init ConfigMap
  - Keep PostgreSQL password rotation durable after pod restart
  - Reject mitigations that revert otelu to the old password
  - Remove old password leaks from unrelated pods

* Fix fault recovery to satisfy the oracle

* Fix problem registry import ordering

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Add cumulative_admission_webhook_timeout_hotel_reservation problem (#886)

* Add cumulative_admission_webhook_timeout_hotel_reservation problem

* Pin webhook backends to worker nodes via nodeAffinity

* Make webhook backends realistic admission services

Replace the dummy webhook backends with HTTPS admission servers that terminate TLS using Secret-mounted certificates, validate AdmissionReview

requests, and return proper admission responses. Certificates are signed by the same CA referenced in each webhook's `caBundle`, with SANs

covering the backend Service DNS names.

The admission logic enforces a trusted image registry allowlist and a

per-container CPU limit. All Hotel Reservation workloads satisfy these

policies, so the webhooks remain transparent during normal operation and

recovery.

Also:
* Vary webhook `timeoutSeconds` (12, 8, 11, 9) to make the cumulative
  timeout less obvious.

* Rename the CA CN from `sregym-webhook-ca` to
  `compliance-webhook-ca`.

* Remove a duplicate `rule.from_` check in the oracle.

* Fix create-or-replace handling for webhooks, NetworkPolicies,
  Deployments, and Services so re-injection updates existing resources
  instead of failing or silently skipping changes.

* Model the fault as a missing apiserver NetworkPolicy allow

* Model the fault as a missing apiserver allow with a near-miss policy

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Add psa_restricted_blocks_recreation problem (#891)

Labelling a namespace pod-security.kubernetes.io/enforce=restricted leaves
running pods untouched but makes the apiserver reject recreated pods that run
as root / set no seccomp profile, so a deployment silently goes
under-replicated. Unlike the existing webhook problems, the policy is enforced
by the apiserver via a namespace label, not a webhook config.

* Add copilot cli agent (#893)

* add copilot cli agent

* remove -s flag

* Fix MCP retry error handling and CRLF parsing in CI (#896)

* fix(mcp): broaden MCP retry exceptions and return error instead of raising

* fix(ci): strip CRLF from PR description before parsing problem ID

* Fix kind cluster detection (#897)

* Fix custom kind cluster detection

* Handle failed kind detection output

* fix edge cases

* run ruff check adn format

* Shell state persistence (#903)

* Include shell persistence

* Include shell persistence

* Isolate problem IDs from agent runtime artifacts

* update SREGym-applications (18620ed) (#910)

* Add Calico route-reflector label drift problem (#828)

* Add Calico route-reflector label drift problem

* Address Calico route-reflector review comments

* Harden Calico cleanup ownership tracking

* Fix Codex agent install verification

* Tighten Codex platform package detection

* Restore kubelet eviction reset cleanup

* Neutralize Calico ownership metadata

---------

Co-authored-by: Munim Thahmid <[email protected]>
Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Fail alert oracle on Prometheus query errors (#912)

* Decouple failure configmaps from mongo pods in `hotel-reservation` (#899)

* decouple failure configmaps from mongo pods

* remove empty failure configmaps creation

* Support local LLM endpoints for Stratus and OpenCode (#917)

* Support local LLM endpoints for Stratus

* Prefer env vars for local LLM endpoints

* Support local LLM endpoints for OpenCode

* Route local endpoints into agent containers

* Normalize OpenCode local judge models

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Preflight check the judge model (#924)

* Add support for uniform agent trajectory (ATIF format) (#918)

* add support for ATIF trajectory conversion and normalization, add claudecode adapter

* fix: make _finish_problem idempotent

* isolate .codex mount in container runner

* better temp dir cleanup

* add codex adapter

* add opencode adapter

* add copilot adapter

* add stratus adapter

* fix antropic caching for stratus

* add gemini adapter

* store normalized ATIF trajectories in SQLite indexed by problem type

* edge tests

* bump litellm, tikoken

* update docker lib versions

* Add node_clock_drift Problem  (#894)

* adding clock drift problem

* fixing race condition causing sidecar log delay

* fixing recover_fault to reverse time sync removal applied, improve cleanup

* global cleanup added + fixed restoration for node_clock_drift problem

* fixing mitigation oracle to ensure correct node checked

* adding problem to non emulated cluster problems list

* extending wait

* indentation error fix

* fixing time restoration in global cleanup

* adding in check to make sure it picks worker node

* adding another control plane filter, fixing clock step-back in global recovery

* increase sidecar rollout timeout, make podnames/labels generic, idempotancy check

* formatting fixes

* format fix

* fix

* fix ruff check/format issues

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>

* Minimum viable python version

* Changed diagnosis oracle

* Cleaned up fault recovery

* Edit tasklist.yml

* Removed old Java artifacts

* Updated mitigation oracle to be more robust

* Added polling

* Fail Kafka producer leak injection on timeout

---------

Co-authored-by: Saad Mohammad Rafid Pial <[email protected]>
Co-authored-by: Kerem Akcalioglu <[email protected]>
Co-authored-by: ermias mulugeta <[email protected]>
Co-authored-by: Tejas Shukla <[email protected]>
Co-authored-by: Petr Myagkov <[email protected]>
Co-authored-by: Omar Faruqe Riyad <[email protected]>
Co-authored-by: Mohammad Tamimul Ehsan <[email protected]>
Co-authored-by: Munim Thahmid <[email protected]>
Co-authored-by: Om Kumar <[email protected]>
Co-authored-by: Munim Thahmid <[email protected]>
Co-authored-by: Tanzim Hossain Romel <[email protected]>
Co-authored-by: haani-maybe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

problem Adding a new problem to the benchmark

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants