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
Make scheduler and duration optional for apis #172
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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) { |
There was a problem hiding this comment.
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
LGTM |
@@ -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"` |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest lgtm
There was a problem hiding this 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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
api/v1alpha1/common_types.go
Outdated
// supported value: Pending / Running / Succeeded / Failed / Unknown | ||
PodPhaseSelectors []string `json:"phaseSelector,omitempty"` | ||
PodPhaseSelectors []string `json:"phaseSelectors,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json:"podPhaseSelectors, omitempty"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* make scheduler and duration optional for apis
What problem does this PR solve?
#171
Make
scheduler
andduration optional
forchaos
APIs, then we can support this feature for each kind ofchaos
in parallel.What is changed and how does it work?
Make
scheduler
andduration
optional forchaos
APIs, then we can support this feature for each kind ofchaos
in parallel.chaos-manager
would reject the reconciliation if thescheduler
andduration
are not both defined currently.Check List
Tests
Code changes
Side effects
Does this PR introduce a user-facing change?: