Skip to content

Add file_descriptor_exhaustion problem - #832

Merged
Saadmrp1038 merged 6 commits into
SREGym:mainfrom
TejasShukla2007:fd_exhaustion
Jun 12, 2026
Merged

Saadmrp1038 merged 6 commits into
SREGym:mainfrom
TejasShukla2007:fd_exhaustion

Conversation

@TejasShukla2007

@TejasShukla2007 TejasShukla2007 commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Adds a new problem simulating file descriptor exhaustion.

In Unix-like systems, a file descriptor (FD) is a handle to access files, sockets, pipes, or any I/O resource. Each process is allowed only a limited number of these. The default soft limit is 1024 in containers. When the limit is hit, the app does not crash but rather starts dropping connections or logging mysterious I/O errors.

More details on this topic have been mentioned in the following blog - https://medium.com/@badrikmodi/the-silent-killer-file-descriptor-exhaustion-in-modern-services-9144bf795b6f

1. Real World Failure Story

  1. Moving the Entire Stack to K8s Within a Year – Lessons Learned - ThredUP - DevOpsStage 2018

In this case, every time new containers are run, new file descriptors are allocated without deleting the already existing file descriptors. Consequently, this causes a "Too many open files" error.

  1. Millions of open file descriptors for /usr/bin causing downtime

It describes how the number of file descriptors grew to millions within a few days, causing containers within the pods to crash/restart continually.

2. How the failure is simulated on SREGym

In real world systems, this failure builds up gradually and it takes days for its symptoms to show. So, the new problem class at sregym/conductor/problems/file_descriptor_exhaustion.py simulates the problem by spinning up a background thread that opens 1100 connections to the frontend on port 5000, holds them, sleeps for some time, releases current connections, and creates new ones. This exhausts the file descriptor limit fast. To open connections to port 5000 of the frontend, kubectl port-forward is used.

The frontend's file descriptor limit is kept at the standard Linux default, i.e., a value of 1024.

The frontend successfully accepts the connections till it hits the limit, and then begins rejecting the traffic with too many open files error.

A custom oracle FDMitigationOracle is used that inherits from the generic MitigationOracle to run the generic tests. Additionally, it checks the logs of the faulty service pod for the too many open files error. If it does not see this error for a sustained period, the mitigation passed verdict is given. The oracle checks the log for a sustained period so that the agent cannot cheat the test by simply restarting the pod and immediately submitting.

The problem is registered as "file_descriptor_exhaustion" under registry.py.

3. Problem Runtime Behaviour

Once the fault is injected, the cluster has the following observable state:

Pod health:

kubectl get pods -n hotel-reservation

On running the above command, the frontend pod shows 1/1 Running with 0 restarts. A naive agent might get misled by this observation assuming everything to be fine.

Application logs:

kubectl logs frontend-7574f495f8-fm46j -n hotel-reservation

Only after checking the application logs would an agent be able to diagnose the problem. The above command results in an output of the following kind:

2026-05-31T07:10:13Z INF services/frontend/server.go:140 > srv-reservation.
2026-05-31T07:10:13Z INF services/frontend/server.go:65 > Successfull
2026-05-31T07:10:13Z INF services/frontend/server.go:87 > Serving http
2026/05/31 07:10:15 http: Accept error: accept tcp [::]:5000: accept4: too many open files; retrying in 5ms
2026/05/31 07:10:15 http: Accept error: accept tcp [::]:5000: accept4: too many open files; retrying in 10ms

The too many open files error helps in determining that this is a file descriptor exhaustion issue.

One way for the AI agent to successfully diagnose and mitigate the issue is to check the pod logs, identify the file descriptor exhaustion, and elevate the limit to a suitable value, preferably to the hard limit (ulimit -n $(ulimit -Hn)).

4. Fault recovery

The fault is recovered by stopping the background flooder thread and closing the port-forward tunnel. Moreover, the ulimit patch on the frontend deployment is reverted to cleanly restore its original entrypoint configuration.

5. Problem Validation

The problem passed uv run python tests/integration/validate_problem.py --problem file_descriptor_exhaustion on my system.

/validate-problem file_descriptor_exhaustion

@Saadmrp1038
Saadmrp1038 self-requested a review May 31, 2026 13:38
@Saadmrp1038 Saadmrp1038 added the problem Adding a new problem to the benchmark label May 31, 2026
@Saadmrp1038

Saadmrp1038 commented May 31, 2026 •

Copy link
Copy Markdown
Collaborator

@TejasShukla2007 Thanks for the PR!

The file descriptor value of 30 feels too unrealistic and could have unintended consequences. Is it possible to use a normal limit value like 1024/4096, then do something that requires a higher limit (check the file descriptor limit and then intentionally put load that exceeds that value)? I actually faced this similar issue while testing another fault #768. Check the review comments. I ran into the error OSError: [Errno 24] No file descriptors available because the default file descriptor limit was too low for the amount of connections we were creating.

Add fault injection by flooding connections
@TejasShukla2007

Copy link
Copy Markdown
Contributor Author

@TejasShukla2007 Thanks for the PR!

The file descriptor value of 30 feels too unrealistic and could have unintended consequences. Is it possible to use a normal limit value like 1024/4096, then do something that requires a higher limit (check the file descriptor limit and then intentionally put load that exceeds that value)? I actually faced this similar issue while testing another fault #768. Check the review comments. I ran into the error OSError: [Errno 24] No file descriptors available because the default file descriptor limit was too low for the amount of connections we were creating.

I have changed the fault injection method. Now, the problem is simulated by creating a pod that puts a load on the frontend beyond its file descriptor limit. The file descriptor limit for the frontend pod is set at 1024.

This is much closer to the real world case scenario of ThredUp where the error was caused due to an internal component creating too many file descriptors.

@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.

@TejasShukla2007 Thanks for the effort! I left some inline comments below. Please ping me when you've addressed them.

@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.

The agent tried to delete the flooder pod to fix the fault, which is not what we want. The thing with how it is currently set up is that the agent can see the TCP holding script and decide that it is not needed, and deletes it. Another approach to this could be a continuous flooding system. During injection, we would spin up a background thread that will continuously create a connections, sleep for some time, release the current connections, and create a new ones.

@TejasShukla2007

Copy link
Copy Markdown
Contributor Author

@Saadmrp1038 I have changed the fault injection method. Now, the fault is injected by spinning up a background thread. Moreover, I have updated the root cause description and added a custom oracle FDMitigationOracle to check the logs for too many open files error. Note that it checks the logs for some time before giving the verdict so that an agent cannot cheat by simply restarting the faulty service pod and immediately submitting.

@Saadmrp1038

Copy link
Copy Markdown
Collaborator

@TejasShukla2007 The changes look good! I ran and tested the problem multiple times. Everything seems to be working correctly now.

Run Diagnosis Mitigation Agent Behaviour
1 89% ✅ ❌ Timeout Wasted ~15 min on app noises before finding frontend logs. Found correct fix (ulimit -n 65536) but ran out of time.
2 100% ✅ ✅ Faster diagnosis (~2 min). Hit same trap (removing ulimit still fails), but quickly realized default soft=1024 and applied explicit raise.
3 100% ✅ ❌ Again perfect diagnosis. Removed ulimit wrapper -> saw errors briefly stop (flooder reconnecting) -> submitted too early. Flooder came back, oracle caught it.

The injection sets ulimit -n 1024 which is the same as the Docker default soft limit for containers (1024 soft / 524288 hard). So when agents "fix" it by just removing the ulimit wrapper, the container still starts with soft limit of 1024 and the flooder still exhausts it. The only real fix is explicitly raising the limit (ulimit -n 65536). This makes the problem harder than it looks. 2/3 agents fell into this trap.

On some machines the Docker default soft limit might be higher than 1024 (if manually changed). In that case, just removing the wrapper would actually fix it. I guess that's fine. Unless manually changed, Docker defaults to 1024 soft limit.

@Saadmrp1038

Copy link
Copy Markdown
Collaborator

@TejasShukla2007 Congrats on your first PR merged here 🎉

@Saadmrp1038
Saadmrp1038 merged commit 0fb49c5 into SREGym:main Jun 12, 2026
4 of 5 checks passed
vsmart-06 pushed a commit to vsmart-06/SREGym that referenced this pull request Jul 12, 2026
* 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]>
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.

2 participants