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

Make scheduler and duration optional for apis #172

Merged

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Jan 23, 2020

What problem does this PR solve?

#171
Make scheduler and duration optional for chaos APIs, then we can support this feature for each kind of chaos in parallel.

What is changed and how does it work?

Make scheduler and duration optional for chaos APIs, then we can support this feature for each kind of chaos in parallel. chaos-manager would reject the reconciliation if the scheduler and duration are not both defined currently.

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Code changes

  • Has Go code change

Side effects

  • None

Does this PR introduce a user-facing change?:

NONE

@codecov-io
Copy link

codecov-io commented Jan 23, 2020

Codecov Report

Merging #172 into master will increase coverage by 0.19%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #172      +/-   ##
==========================================
+ Coverage   39.27%   39.47%   +0.19%     
==========================================
  Files          17       17              
  Lines         611      608       -3     
==========================================
  Hits          240      240              
+ Misses        340      337       -3     
  Partials       31       31
Impacted Files Coverage Δ
api/v1alpha1/iochaos_types.go 32.55% <0%> (+0.73%) ⬆️
api/v1alpha1/networkchaos_types.go 14.43% <0%> (+0.14%) ⬆️
api/v1alpha1/podchaos_types.go 32.55% <0%> (+0.73%) ⬆️

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 cdb7532...2cbf319. Read the comment docs.

func (in *PodChaos) GetDuration() (time.Duration, error) {
duration, err := time.ParseDuration(in.Spec.Duration)
//GetDuration would return the duration for chaos
func (in *PodChaos) GetDuration() (*time.Duration, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@cwen0 maybe we should refine this function, there are many repeat lines

@zhouqiang-cl
Copy link
Contributor

LGTM

@zhouqiang-cl
Copy link
Contributor

@cwen0 @YangKeao @mahjonp PTAL

@@ -84,7 +84,7 @@ type IoChaosSpec struct {
// such as "300ms", "-1.5h" or "2h45m".
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
// +optional
Duration string `json:"duration"`
Duration *string `json:"duration,omitempty"`

Choose a reason for hiding this comment

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

why using pointer here? you can use empty to check the duration directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using pointer here is to make chaos API more user-friendly. If users need the chaos action always perform after they apply the chaos API, it is more reasonable that they omit the scheduler and the duration instead of leaving those as empty.

@@ -175,7 +175,16 @@ func (in *IoChaosList) DeepCopyObject() runtime.Object {
func (in *IoChaosSpec) DeepCopyInto(out *IoChaosSpec) {

Choose a reason for hiding this comment

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

seem you can use https://github.com/jinzhu/copier to simplify the codes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is auto-generated, so I suggest making it be as it generated by scripts.

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

api/v1alpha1/iochaos_types.go Outdated Show resolved Hide resolved
api/v1alpha1/networkchaos_types.go Outdated Show resolved Hide resolved
api/v1alpha1/common_types.go Outdated Show resolved Hide resolved
config/crd/bases/pingcap.com_iochaos.yaml Outdated Show resolved Hide resolved
manifests/crd.yaml Show resolved Hide resolved
api/v1alpha1/common_types.go Outdated Show resolved Hide resolved
api/v1alpha1/iochaos_types.go Outdated Show resolved Hide resolved
@Yisaer
Copy link
Contributor Author

Yisaer commented Jan 30, 2020

In this request, I also execute make yaml after I finish editing the API spec and I found that the current CRD isn't the latest which I mentioned in #173, so we can see some changes in CRD file which is not related in this request.
cc @cwen0 @mahjonp

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

Yisaer and others added 2 commits January 30, 2020 17:57
Co-Authored-By: mahjonp <junpeng.man@gmail.com>
mahjonp
mahjonp previously approved these changes Jan 30, 2020
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.

lgtm

// supported value: Pending / Running / Succeeded / Failed / Unknown
PodPhaseSelectors []string `json:"phaseSelector,omitempty"`
PodPhaseSelectors []string `json:"phaseSelectors,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

json:"podPhaseSelectors, omitempty"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

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.

lgtm

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

@Yisaer Yisaer merged commit 3837ade into chaos-mesh:master Jan 31, 2020
sjwsl pushed a commit to sjwsl/chaos-mesh that referenced this pull request May 6, 2021
* make scheduler and duration optional for apis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants