-
Notifications
You must be signed in to change notification settings - Fork 850
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
Validates the scheduler #461
Conversation
Codecov Report
@@ Coverage Diff @@
## master #461 +/- ##
==========================================
+ Coverage 58.57% 60.81% +2.23%
==========================================
Files 60 68 +8
Lines 3626 4410 +784
==========================================
+ Hits 2124 2682 +558
- Misses 1333 1537 +204
- Partials 169 191 +22
Continue to review full report at Codecov.
|
/run-e2e-tests |
1 similar comment
/run-e2e-tests |
} | ||
} else if (duration == nil && scheduler != nil) || (duration != nil && scheduler == nil) { |
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.
I think duration==nil && scheduler != nil
is ok, sometimes we just want to start to chaos experiment at a specific time and last to the end time.
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.
I am not sure about that.
But I find the controllers except podchaos all need scheduler == nil && duration == nil
OR scheduler != nil && duration != nil
But podschaos has a different logic
I think the main reason for this difference is that PodKillAction
and ContainerKillAction
have different behaviors. We have addressed this difference in webhook of podschaos.
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 can be simplified to else if !(duration == nil && scheduler == nil)
api/v1alpha1/common_validation.go
Outdated
cronField := schedulerField.Child("cron") | ||
allErrs = append(validateCron(spec.Cron, cronField)) | ||
|
||
scheduler, _ := cronv3.ParseStandard(spec.Cron) |
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 ignore this 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.
validateCron
had validated the cron
.
If ParseStandard causes error, the scheduler
will be nil
So I think we can ignore this 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.
I don't suggest ignoring error here. The logic could be changed in future and we may miss the root cause when error happens.
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.
/run-e2e-tests |
/run-e2e-test |
/run-e2e-test |
1 similar comment
/run-e2e-test |
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
/run-e2e-test |
1 similar comment
/run-e2e-test |
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.
I checked the e2e test and tested this PR in my local environment. Seems the continuous failure of e2e is caused by this PR itself. @Gallardot
Tested with the time chaos example.
apiVersion: pingcap.com/v1alpha1
kind: TimeChaos
metadata:
name: time-shift-example
namespace: chaos-testing
spec:
mode: one
selector:
labelSelectors:
app: io
timeOffset: "-1h"
duration: "9m"
scheduler:
cron: "@every 10m"
} | ||
} else if (duration == nil && scheduler != nil) || (duration != nil && scheduler == nil) { |
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 can be simplified to else if !(duration == nil && scheduler == nil)
I'm terribly sorry about that. I’ll fix it right away. @yeya24 |
No worries. Thanks for your awesome work! 🚀 |
/run-e2e-test |
/run-e2e-test |
/run-e2e-test |
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
What problem does this PR solve?
#373
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
Does this PR introduce a user-facing change?: