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

Validates the scheduler #461

Merged
merged 17 commits into from
May 14, 2020
Merged

Validates the scheduler #461

merged 17 commits into from
May 14, 2020

Conversation

Gallardot
Copy link
Member

What problem does this PR solve?

#373

What is changed and how does it work?

Check List

Tests

  • Unit test

Code changes

  • Has Go code change

Side effects

  • None

Related changes

  • None

Does this PR introduce a user-facing change?:

NONE

@codecov-io
Copy link

codecov-io commented May 2, 2020

Codecov Report

Merging #461 into master will increase coverage by 2.23%.
The diff coverage is 55.94%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
api/v1alpha1/common_webhook.go 100.00% <ø> (ø)
api/v1alpha1/iochaos_types.go 60.00% <0.00%> (+27.44%) ⬆️
api/v1alpha1/kernelchaos_types.go 33.33% <0.00%> (+28.68%) ⬆️
api/v1alpha1/networkchaos_types.go 26.86% <0.00%> (+7.92%) ⬆️
api/v1alpha1/podchaos_types.go 55.55% <0.00%> (+22.99%) ⬆️
controllers/stresschaos_controller.go 0.00% <0.00%> (ø)
controllers/timechaos_controller.go 0.00% <0.00%> (ø)
pkg/chaosdaemon/netem_linux.go 26.66% <0.00%> (-17.78%) ⬇️
pkg/chaosdaemon/netlink_linux.go 0.00% <ø> (ø)
pkg/chaosdaemon/stress_server.go 0.00% <0.00%> (ø)
... and 42 more

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 15ff111...a09f725. Read the comment docs.

@zhouqiang-cl
Copy link
Contributor

/run-e2e-tests

1 similar comment
@Gallardot
Copy link
Member Author

/run-e2e-tests

}
} else if (duration == nil && scheduler != nil) || (duration != nil && scheduler == nil) {
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

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)

cronField := schedulerField.Child("cron")
allErrs = append(validateCron(spec.Cron, cronField))

scheduler, _ := cronv3.ParseStandard(spec.Cron)
Copy link
Member

Choose a reason for hiding this comment

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

why ignore this error?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've already fixed it. PTAL
@cwen0 @Yisaer

@yeya24
Copy link
Contributor

yeya24 commented May 6, 2020

/run-e2e-tests

@Gallardot Gallardot linked an issue May 7, 2020 that may be closed by this pull request
@Gallardot
Copy link
Member Author

/run-e2e-test

@yeya24
Copy link
Contributor

yeya24 commented May 9, 2020

/run-e2e-test

1 similar comment
@cwen0
Copy link
Member

cwen0 commented May 9, 2020

/run-e2e-test

cwen0
cwen0 previously approved these changes May 9, 2020
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
Copy link
Member

cwen0 commented May 9, 2020

/run-e2e-test

1 similar comment
@yeya24
Copy link
Contributor

yeya24 commented May 9, 2020

/run-e2e-test

Copy link
Contributor

@yeya24 yeya24 left a 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"

Seems the nextRecover is not correct.
image

}
} else if (duration == nil && scheduler != nil) || (duration != nil && scheduler == nil) {
Copy link
Contributor

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)

@Gallardot
Copy link
Member Author

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"

Seems the nextRecover is not correct.
image

I'm terribly sorry about that. I’ll fix it right away. @yeya24

@yeya24
Copy link
Contributor

yeya24 commented May 9, 2020

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"

Seems the nextRecover is not correct.
image

I'm terribly sorry about that. I’ll fix it right away. @yeya24

No worries. Thanks for your awesome work! 🚀

@Gallardot
Copy link
Member Author

/run-e2e-test

@Gallardot
Copy link
Member Author

I have fix the continuous failure.
I will migrate nextStart and nextRecover to status in another PR

@yeya24 @cwen0 PTAL

@yeya24
Copy link
Contributor

yeya24 commented May 12, 2020

/run-e2e-test

@yeya24
Copy link
Contributor

yeya24 commented May 13, 2020

/run-e2e-test

Copy link
Contributor

@yeya24 yeya24 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
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 4d2efcd into chaos-mesh:master May 14, 2020
@Gallardot Gallardot deleted the validate branch May 14, 2020 03:48
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate duration and cron schedule conflict in webhook
7 participants