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

Support duration chaos for pod failure #175

Merged

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Feb 1, 2020

What problem does this PR solve?

#171
Make Podfailure chaos support duration chaos feature.

What is changed and how does it work?

Adding a new controller interface as duration controller like twophase controller to control the logic of duration chaos. Each kind of chaos would implement both interfaces.

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Code changes

  • Has Go code change

Side effects

  • None

Related changes

  • Need to update the documentation

Does this PR introduce a user-facing change?:

Support duration chaos for pod failure by omitting the scheduler and duration.

@codecov-io
Copy link

codecov-io commented Feb 1, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@97015f9). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #175   +/-   ##
=========================================
  Coverage          ?   39.47%           
=========================================
  Files             ?       17           
  Lines             ?      608           
  Branches          ?        0           
=========================================
  Hits              ?      240           
  Misses            ?      337           
  Partials          ?       31

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 97015f9...9ad11f5. Read the comment docs.

@Yisaer Yisaer changed the title [WIP] Support duration chaos for pod failure Support duration chaos for pod failure Feb 1, 2020
@zhouqiang-cl
Copy link
Contributor

@mahjonp @cwen0 @YangKeao PTAL

@@ -15,7 +15,6 @@ package podfailure

import (
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make a dir named controllers/scheduler/podchaos

return r.Update(ctx, chaos)
})
if updateError != nil {
r.Log.Error(updateError, "unable to update chaos finalizers")
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we need return updateError here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we don't need to, this reconciliation would be re queued in the end.

Client: r.Client,
Log: r.Log,
}
return reconciler.Reconcile(req)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a little redundant, how about merge these two parts into one constructor method?

@mahjonp mahjonp requested review from you06 and mapleFU February 2, 2020 11:57
@cwen0
Copy link
Member

cwen0 commented Feb 3, 2020

@Yisaer I think the name duration chaos is not very accurate to describe this kind of chaos, because we don't have the option of duration to control this kind of chaos, which is easy to cause misunderstanding.

@cwen0
Copy link
Member

cwen0 commented Feb 3, 2020

@Yisaer I think we can rename twophase controller to cheduler controller and rename duration chaos to common chaos. What do you think?

@Yisaer
Copy link
Contributor Author

Yisaer commented Feb 3, 2020

@cwen0 It's ok for me to rename both twophase controller and duration controller. In this request, I would rename duration chaos to common chaos. We could create new request for renaming twophase controller.

@cwen0
Copy link
Member

cwen0 commented Feb 3, 2020

@cwen0 It's ok for me to rename both twophase controller and duration controller. In this request, I would rename duration chaos to common chaos. We could create new request for renaming twophase controller.

Great!

Copy link
Contributor

@mahjonp mahjonp left a comment

Choose a reason for hiding this comment

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

rest lgtm

controllers/podchaos/podfailure/types.go Outdated Show resolved Hide resolved
controllers/podchaos/podfailure/types.go Outdated Show resolved Hide resolved
controllers/podchaos/types.go Outdated Show resolved Hide resolved
controllers/podchaos/types.go Outdated Show resolved Hide resolved
@you06
Copy link
Member

you06 commented Feb 3, 2020

I find both twophase controller and duration controller wrap podfailure in very similar ways and they do only expose some functions from podfailure, what's the purpose for it?

Yisaer and others added 4 commits February 3, 2020 13:33
@Yisaer Yisaer requested a review from mahjonp February 3, 2020 05:38
@Yisaer
Copy link
Contributor Author

Yisaer commented Feb 3, 2020

I find both twophase controller and duration controller wrap podfailure in very similar ways and they do only expose some functions from podfailure, what's the purpose for it?

The wrap here is to implement the interface like InnerReconciler and InnerCommonReconcile which were used to handle the logic of common chaos and scheduler chaos.

Copy link
Contributor

@zhouqiang-cl zhouqiang-cl left a comment

Choose a reason for hiding this comment

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

LGTM

Co-Authored-By: mahjonp <junpeng.man@gmail.com>
mahjonp
mahjonp previously approved these changes Feb 3, 2020
@zhouqiang-cl
Copy link
Contributor

@cwen0 PTAL again

controllers/common/podfailure/types.go Show resolved Hide resolved
controllers/common/types.go Show resolved Hide resolved
controllers/podchaos/podfailure/types.go Outdated Show resolved Hide resolved
controllers/podchaos/podfailure/types.go Outdated Show resolved Hide resolved
r.Log.Error(err, fmt.Sprintf("unable to get podchaos[%s/%s]'s duration", podchaos.Namespace, podchaos.Name))
return ctrl.Result{}, nil
}
if scheduler == nil && duration == nil {
Copy link
Member

Choose a reason for hiding this comment

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

How about pod-kill action? Duration is always empty for pod-kill

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch and updated.

controllers/twophase/podfailure/types.go Show resolved Hide resolved
@zhouqiang-cl
Copy link
Contributor

@cwen0 PTAL

Copy link
Member

@cwen0 cwen0 left a comment

Choose a reason for hiding this comment

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

LGTM

@cwen0 cwen0 merged commit 8b02bd3 into chaos-mesh:master Feb 3, 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
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants