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

Add a new StressChaos to generate plenty of stresses #332

Merged
merged 64 commits into from
Apr 26, 2020

Conversation

AngleNet
Copy link
Contributor

@AngleNet AngleNet commented Mar 11, 2020

What problem does this PR solve?

Add a new StressChaos to generate plenty of stresses over a collection of pods. We can burn cpus #144 , eat memory #145 and so on.

What is changed and how does it work?

Inject stresses into container's cgroup

Check List

Tests

  • Manul tests

Code changes

  • Has CI related scripts change

Side effects

  • NO

Related changes

  • Need to update the documentation

Does this PR introduce a user-facing change?:

Add a new `StressChaos` to generate plenty of stresses

@AngleNet AngleNet changed the title Add a new StressChaos to generate plenty of stresses [WIP] Add a new StressChaos to generate plenty of stresses Mar 11, 2020
@zhouqiang-cl
Copy link
Contributor

well done

@codecov-io
Copy link

codecov-io commented Mar 14, 2020

Codecov Report

Merging #332 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #332   +/-   ##
=======================================
  Coverage   59.02%   59.02%           
=======================================
  Files          68       68           
  Lines        4369     4369           
=======================================
  Hits         2579     2579           
  Misses       1598     1598           
  Partials      192      192           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d82eb6...2d82eb6. Read the comment docs.

@AngleNet AngleNet changed the title [WIP] Add a new StressChaos to generate plenty of stresses [PTAL] Add a new StressChaos to generate plenty of stresses Mar 14, 2020
@AngleNet
Copy link
Contributor Author

AngleNet commented Mar 14, 2020

I'm very pleased to say that it's ready to be reviewed now ! Please help me to take a look. @zhouqiang-cl @ethercflow ❤️

@AngleNet
Copy link
Contributor Author

Still missing unit tests for it since I'm not familiar with the current testing framework. Maybe I could add them later in another PR ?

@cwen0
Copy link
Member

cwen0 commented Mar 14, 2020

@AngleNet Good job!

@zhouqiang-cl zhouqiang-cl changed the title [PTAL] Add a new StressChaos to generate plenty of stresses Add a new StressChaos to generate plenty of stresses Mar 14, 2020
@yeya24
Copy link
Contributor

yeya24 commented Apr 25, 2020

Have you ever tested this feature in contained environment, such as Kind? Seems it doesn't work, both CPU stress and Memory stress.

➜  examples git:(feature/stress) ✗ kubectl top pods -l app=etcd
NAME                    CPU(cores)   MEMORY(bytes)
etcd-7db9d6f6f9-2tt6m   6m           4Mi

➜  examples git:(feature/stress) ✗ cat burn-memory.yaml
apiVersion: pingcap.com/v1alpha1
kind: StressChaos
metadata:
  name: burn-memory
  namespace: chaos-testing
spec:
  mode: one
  selector:
    labelSelectors:
      app: etcd
  stressors:
    memory:
      workers: 1
      size: 100MB
  duration: "20m"
  scheduler:
    cron: "@every 30m"

➜  examples git:(feature/stress) ✗ klo chaos-daemon-ht9st
Chaos-daemon Version: version.Info{GitVersion:"v0.0.0-master+$Format:%h$", GitCommit:"d893703a7602ebbf8a5bc3dba0aab0de3b7e8cea", GitTreeState:"dirty", BuildDate:"2020-04-24T21:35:38Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
2020-04-25T14:24:04.132Z	INFO	chaos-daemon-server	Starting http endpoint	{"address": "0.0.0.0:31766"}
2020-04-25T14:24:04.134Z	INFO	chaos-daemon-server	Starting grpc endpoint	{"address": "0.0.0.0:31767", "runtime": "containerd"}
2020-04-25T14:31:13.881Z	INFO	chaos-daemon-server	Executing stressors	{"request": "scope:POD target:\"containerd://236bb108ef4070579b843562b3999d4dea188cce86a17233b3fb7bf9d322a4aa\" stressors:\" --vm 1 --vm-keep --vm-bytes 100000000\" "}

@AngleNet
Copy link
Contributor Author

What did you mean it didn’t work? I see the stressors are injected

@yeya24
Copy link
Contributor

yeya24 commented Apr 25, 2020

Yes, it is injected. But the memory/CPU is not increasing at all. They remain the same. Is it the expected behavior? I guess no?

Or maybe the measuring method is not correct. kubectl top pods cannot get the correct result. So is there any other ways to validate there is a CPU/memory load. How did you do that? It would be helpful if you could provide some guides in the document.

@cwen0
Copy link
Member

cwen0 commented Apr 26, 2020

Yes, it is injected. But the memory/CPU is not increasing at all. They remain the same. Is it the expected behavior? I guess no?

Or maybe the measuring method is not correct. kubectl top pods cannot get the correct result. So is there any other ways to validate there is a CPU/memory load. How did you do that? It would be helpful if you could provide some guides in the document.

I also run stressChaos in my environment, this is work for me, but we can't find this stress process in containers, I guess that we should run this stress-ng in the target namespace.

}

// Validate validates whether the Stressors are all well defined
func (in *Stressors) Validate(parent *field.Path, errs field.ErrorList) field.ErrorList {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (in *Stressors) Validate(parent *field.Path, errs field.ErrorList) field.ErrorList {
func (in *Stressors) Validate(parent *field.Path) field.ErrorList {

keep the same style

}

// Validate validates whether the Stressor is well defined
func (in *Stressor) Validate(parent *field.Path, errs field.ErrorList) field.ErrorList {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (in *Stressor) Validate(parent *field.Path, errs field.ErrorList) field.ErrorList {
func (in *Stressor) Validate(parent *field.Path) field.ErrorList {

}

// Validate validates whether the MemoryStressor is well defined
func (in *MemoryStressor) Validate(parent *field.Path, errs field.ErrorList) field.ErrorList {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (in *MemoryStressor) Validate(parent *field.Path, errs field.ErrorList) field.ErrorList {
func (in *MemoryStressor) Validate(parent *field.Path) field.ErrorList {

api/v1alpha1/stresschaos_webhook.go Outdated Show resolved Hide resolved
cwen0
cwen0 previously approved these changes Apr 26, 2020
@AngleNet
Copy link
Contributor Author

/run-e2e-test

cwen0
cwen0 previously approved these changes Apr 26, 2020
stressors += fmt.Sprintf(" --vm %d --vm-keep", in.MemoryStressor.Workers)
if len(in.MemoryStressor.Size) != 0 {
if in.MemoryStressor.Size[len(in.MemoryStressor.Size)-1] != '%' {
size, _ := units.FromHumanSize(in.MemoryStressor.Size)
Copy link
Member

Choose a reason for hiding this comment

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

Handle this error

pkg/chaosdaemon/stress_server.go Outdated Show resolved Hide resolved
@cwen0
Copy link
Member

cwen0 commented Apr 26, 2020

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Apr 26, 2020

/run-all-tests

@zhouqiang-cl zhouqiang-cl dismissed stale reviews from Gallardot, yeya24, and YangKeao April 26, 2020 10:53

dismiss

@zhouqiang-cl zhouqiang-cl merged commit 9753087 into chaos-mesh:master Apr 26, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Apr 26, 2020

cherry pick to release-0.8 failed

cwen0 pushed a commit to cwen0/chaos-mesh that referenced this pull request Apr 26, 2020
cwen0 added a commit that referenced this pull request Apr 26, 2020
sjwsl pushed a commit to sjwsl/chaos-mesh that referenced this pull request May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UCP: Add memory chaos UCP: Add CPU chaos
9 participants