Skip to content

feat(disk): add IOPS limiters.#1087

Merged
aymericDD merged 5 commits into
mainfrom
zenithar/disruption/disk-iops-bottleneck
Jun 19, 2026
Merged

feat(disk): add IOPS limiters.#1087
aymericDD merged 5 commits into
mainfrom
zenithar/disruption/disk-iops-bottleneck

Conversation

@Zenithar

@Zenithar Zenithar commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Adds new functionality
  • Alters existing functionality
  • Fixes a bug
  • Improves documentation or testing

Extends the DiskPressure disruption with IOPS throttling support alongside the existing bandwidth (bytes/sec) throttling.

Changes

API (api/v1beta1/disk_pressure.go)

  • Add readIOPSPerSec and writeIOPSPerSec fields to DiskPressureThrottlingSpec
  • Validate all throttle fields are non-negative (zero = remove limit; negative = rejected at admission)
  • Extend GenerateArgs() to emit --read-iops-per-sec / --write-iops-per-sec flags
  • Extend Explain() with IOPS descriptions

Injector (injector/disk_pressure.go)

  • Rename diskPressureThrottleModeRead/WritediskPressureThrottleModeReadBps/WriteBps to disambiguate from new IOPS modes
  • Add diskPressureThrottleModeReadIops / diskPressureThrottleModeWriteIops enum values
  • cgroups v1: write to blkio.throttle.read_iops_device / blkio.throttle.write_iops_device
  • cgroups v2: write riops= / wiops= key-value pairs to the unified io.max file
  • Inject() and Clean() handle all four throttle modes
  • Add IopsKey observability tag for structured logging

CLI (cli/injector/disk_pressure.go)

  • Wire --read-iops-per-sec / --write-iops-per-sec flags

Docs & Examples

  • Update docs/disk_pressure.md and docs/disruption_catalogue.md
  • Add examples/disk_pressure_read_iops.yaml example manifest
  • Update examples/complete.yaml

CRDs

  • Regenerated chaos.datadoghq.com_disruptions.yaml, _disruptioncrons.yaml, _disruptionrollouts.yaml

Code Quality Checklist

  • The documentation is up to date.
  • My code is sufficiently commented and passes continuous integration checks.
  • I have signed my commit (see Contributing Docs).

Testing

  • I leveraged continuous integration testing
    • by depending on existing unit tests or end-to-end tests.
    • by adding new unit tests or end-to-end tests.
  • I manually tested the following steps:
    • Inject readIOPSPerSec on a cgroups v1 node → verify blkio.throttle.read_iops_device written
    • Inject writeIOPSPerSec on a cgroups v2 node → verify io.max contains wiops=
    • Cleanup path resets all four throttle files to 0
    • locally.
    • as a canary deployment to a cluster.

@Zenithar Zenithar self-assigned this Jun 5, 2026
@Zenithar Zenithar marked this pull request as ready for review June 5, 2026 07:27
@Zenithar Zenithar requested a review from a team as a code owner June 5, 2026 07:27
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 5, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 65.52%
Overall Coverage: 45.84% (+0.20%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c5d64ad | Docs | Datadog PR Page | Give us feedback!

@aymericDD

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@aymericDD

Copy link
Copy Markdown
Contributor

I'm deploying the PR and testing it 🚧

Comment thread examples/disk_pressure_read_iops.yaml Outdated
Comment thread examples/complete.yaml
Comment thread api/v1beta1/disk_pressure.go Outdated
cgroup rejects IOPS values of 1 at the kernel level. Separate IOPS
validation from BPS: allow 0 (remove limit) or >= 2, reject only 1.
Update kubebuilder Minimum=2 annotations and regenerate CRDs.

Lower readIOPSPerSec example from 50 to 10 for measurable demo impact.
Add disk_pressure_write_iops.yaml example with writeIOPSPerSec: 2.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Zenithar Zenithar requested a review from aymericDD June 9, 2026 16:46
Zenithar added 2 commits June 11, 2026 18:33
- Update readBytesPerSec and writeBytesPerSec kubebuilder validation minimum from 0 to 2
- Update Validate() to reject value 1 (kernel rejects cgroup BPS of exactly 1)
- Allow 0 to mean "remove limit" as before
- Regenerate CRD manifests to reflect new minimums

Rationale: the Linux kernel rejects cgroup blkio BPS throttle values of 1; valid values are 0 (no limit) or >= 2. Enforcing this at the API level fails fast before the kernel write.

This commit made by [/dd:git:commit:quick](https://github.com/DataDog/claude-marketplace/tree/main/dd/commands/git/commit/quick.md)
…elds

- Changed kubebuilder minimum annotations for readBytesPerSec, writeBytesPerSec, readIOPSPerSec, writeIOPSPerSec from 2 to 0
- Regenerated CRD manifests for Disruption, DisruptionCron, and DisruptionRollout

Rationale: API-level validation was too strict; cgroup IOPS minimum enforcement (>=2) belongs at the injector layer, not the CRD schema. Allowing 0 lets users express "no throttling" or disable a limit explicitly.

This commit made by [/dd:git:commit:quick](https://github.com/DataDog/claude-marketplace/tree/main/dd/commands/git/commit/quick.md)
@aymericDD

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1210dc8f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread injector/disk_pressure.go
// clean read iops throttle
i.config.Log.Infow("cleaning disk read iops throttle", tags.DeviceKey, i.config.Informer.Source())

if err := i.config.Cgroup.Write(diskPressureBlkioControllerName, i.getThrottleFilename(diskPressureThrottleModeReadIops), i.formatThrottle(0, diskPressureThrottleModeReadIops)); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard IOPS cleanup by the spec

When a disk-pressure disruption only sets byte throttles, Inject never writes the IOPS files because the IOPS fields are nil, but Clean now always resets both IOPS limits to 0/max. On nodes where an IOPS cgroup limit already existed outside this disruption, deleting any bandwidth-only disk-pressure will clear that unrelated limit; reset these modes only when the corresponding IOPS throttle was part of the disruption, or restore the prior value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is true, but as a first version it's enough.

@aymericDD aymericDD merged commit e34388b into main Jun 19, 2026
13 checks passed
@aymericDD aymericDD deleted the zenithar/disruption/disk-iops-bottleneck branch June 19, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants