-
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
pause and start experiment by API #542
Conversation
Signed-off-by: cwen0 <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #542 +/- ##
==========================================
- Coverage 61.39% 56.28% -5.11%
==========================================
Files 64 67 +3
Lines 4069 4301 +232
==========================================
- Hits 2498 2421 -77
- Misses 1383 1710 +327
+ Partials 188 170 -18
Continue to review full report at Codecov.
|
Signed-off-by: cwen0 <[email protected]>
Signed-off-by: cwen0 <[email protected]>
Signed-off-by: cwen0 <[email protected]>
Signed-off-by: cwen0 <[email protected]>
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.
Looks good. Just some small nits.
BTW, do you mind updating the deleteExperiment
swagger in this PR? Seems I forgot to include the failure 404
// @Success 200 "delete ok"
// @Router /api/experiments/{kind}/{namespace}/{name} [delete]
// @Failure 400 {object} utils.APIError
// @Failure 500 {object} utils.APIError
func (s *Service) deleteExperiment(c *gin.Context) {
|
||
// ChaosKindMap defines a map including all chaos kinds. | ||
type chaosKindMap struct { | ||
sync.RWMutex |
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.
Is this necessary?
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 a map, so I think it is necessary
for key, kind := range c.kinds { | ||
out[key] = &ChaosKind{ | ||
Chaos: kind.Chaos.DeepCopyObject(), | ||
ChaosList: kind.ChaosList, |
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 whether DeepCopyObject()
is necessary or not. If it is, ChaosList also supports this method. kind.ChaosList.DeepCopyObject()
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.
OK, DeepCopyObject()
is not necessary and I have removed it.
// @Param name path string true "name" | ||
// @Success 200 "start ok" | ||
// @Failure 500 {object} utils.APIError | ||
// @Failure 404 {object} utils.APIError |
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.
400 Failure
// @Success 200 "start ok" | ||
// @Failure 500 {object} utils.APIError | ||
// @Failure 404 {object} utils.APIError | ||
// @Router /api/experiments/start/{kind}/{ns}/{name} [put] |
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.
// @Router /api/experiments/start/{kind}/{namespace}/{name} [put]
// @Param name path string true "name" | ||
// @Success 200 "pause ok" | ||
// @Failure 500 {object} utils.APIError | ||
// @Failure 404 {object} utils.APIError |
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.
400 Failure is also needed
|
||
// ExperimentBase is used to identify the unique experiment from API request. | ||
type ExperimentBase struct { | ||
Kind string `uri:"kind" binding:"required,oneof=PodChaos NetworkChaos IoChaos StressChaos TimeChaos"` |
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.
KernelChaos
:D
endpoint.GET("/detail/:namespace/:name", s.getExperimentDetail) | ||
endpoint.DELETE("/:kind/:namespace/:name", s.deleteExperiment) | ||
endpoint.GET("/detail/:kind/:namespace/:name", s.getExperimentDetail) | ||
endpoint.DELETE("/delete/:kind/:namespace/:name", s.deleteExperiment) |
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.
IMO /delete/:kind/:namespace/:name
is not needed, do you mind changing this to /:kind/:namespace/:name
? We are already using the DELETE
verb here.
Signed-off-by: cwen0 <[email protected]>
/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 |
/merge |
@@ -600,3 +609,111 @@ func (s *Service) state(c *gin.Context) { | |||
|
|||
c.JSON(http.StatusOK, data) | |||
} | |||
|
|||
// ExperimentBase is used to identify the unique experiment from API request. | |||
type ExperimentBase struct { |
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.
type name will be used as experiment.ExperimentBase by other packages, and that stutters; consider calling this Base
/run-all-tests |
@cwen0 merge failed. |
/run-e2e-tests |
pause and start experiment by API (chaos-mesh#542)
Signed-off-by: cwen0 [email protected]
What problem does this PR solve?
#370
We need to support pause and start chaos experiment by API.