Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to specify a cpu pressure usage value #609

Merged
merged 2 commits into from
Oct 27, 2022

Conversation

taihuynh167
Copy link
Contributor

What does this PR do?

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

Please briefly describe your changes as well as the motivation behind them:

  • CPU pressure disruption currently does not take any parameter, and always uses as much CPU as possible.
  • This PR enables users to specify a specific value, which will only fill a certain amount of the CPU.
  • This amount would be specified as a percentage (of CPU to fill) or as an integer (number of cores to fill).

Code Quality Checklist

  • The documentation is up to date.
    • To be updated
  • 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 plan to separately unit test the StresserManager. The cpu_pressure.go now delegates most of the stuff to StresserManager.
  • I manually tested the following steps:
    • locally.
{"level":"info","ts":1666618997157.501,"caller":"cgroup/cgroup.go:59","message":"reading from cgroup file","disruptionName":"cpu-pressure","disruptionNamespace":"chaos-demo","targetName":"demo-curl-79bf7b74c9-4m54c","targetNodeName":"colima","path":"/mnt/cgroup/cpuset//kubepods/burstable/pod31634024-44d6-4da8-b549-b4c8cb624f59/529ff60ee9eec61fe3d5edaca93c6ac8b84c3dc08ef214666da62dc59e77ae51/cpuset.cpus"}
{"level":"info","ts":1666618997157.7095,"caller":"stress/cpuset_manager.go:87","message":"retrieved coresToBeStressed after applying userRequestCount 50%: 0-1","disruptionName":"cpu-pressure","disruptionNamespace":"chaos-demo","targetName":"demo-curl-79bf7b74c9-4m54c","targetNodeName":"colima"}
{"level":"info","ts":1666618997158.0562,"caller":"stress/cpuset_manager.go:49","message":"changed GOMAXPROCS value from 4 to 2","disruptionName":"cpu-pressure","disruptionNamespace":"chaos-demo","targetName":"demo-curl-79bf7b74c9-4m54c","targetNodeName":"colima"}
{"level":"info","ts":1666618997158.147,"caller":"injector/cpu_pressure.go:124","message":"joining target CPU cgroup","disruptionName":"cpu-pressure","disruptionNamespace":"chaos-demo","targetName":"demo-curl-79bf7b74c9-4m54c","targetNodeName":"colima","core":3,"pid":31299}
- [ ] as a canary deployment to a cluster.

@taihuynh167 taihuynh167 requested a review from a team as a code owner October 24, 2022 15:05
Copy link
Contributor

@luphaz luphaz left a comment

Choose a reason for hiding this comment

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

The implementation suggest for every container we'll stress half the assigned CPU

It seems OK from my POV, I would still appreciate more reviews from people having broadest knowledge here

Maybe updating the doc:

Or FAQ to explain the behaviour could help users of this feature

examples/cpu_pressure.yaml Outdated Show resolved Hide resolved
stress/cpuset_manager.go Outdated Show resolved Hide resolved
stress/cpuset_manager.go Outdated Show resolved Hide resolved
injector/cpu_pressure_test.go Outdated Show resolved Hide resolved
@taihuynh167 taihuynh167 force-pushed the tai.huynh/fix-bug-cpu-pressure branch 2 times, most recently from 3bf6968 to 74bf4b2 Compare October 25, 2022 10:55
Base automatically changed from tai.huynh/fix-bug-cpu-pressure to main October 25, 2022 11:13
@taihuynh167 taihuynh167 force-pushed the tai.huynh/specific-cpu-pressure branch from 81d7f40 to 4adf3f1 Compare October 26, 2022 08:15
@taihuynh167 taihuynh167 requested review from luphaz and a team October 26, 2022 10:38
Copy link
Contributor

@aymericDD aymericDD left a comment

Choose a reason for hiding this comment

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

LGTM 👍

injector/cpu_pressure_test.go Outdated Show resolved Hide resolved
Co-authored-by: Matthieu Bono <luphaz@users.noreply.github.com>
@taihuynh167 taihuynh167 merged commit 6e32add into main Oct 27, 2022
@taihuynh167 taihuynh167 deleted the tai.huynh/specific-cpu-pressure branch October 27, 2022 08:36
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.

None yet

3 participants