You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "moomman (via GitHub)" <gi...@apache.org> on 2023/03/27 11:09:07 UTC

[GitHub] [shardingsphere-on-cloud] moomman opened a new pull request, #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

moomman opened a new pull request, #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286

   1. Add basic convert type: Selector,Pod Chaos,Network Chaos,WorkFlow.
   2. Add convert functions in Controller.Add convert and create chaos logic in Reconcile function.
   3. Add ChaoKind Enums
   
   I have tested it usage in kubenetes environment.It works well As expected.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156678483


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`
+}
+
+type NetWorkParams struct {
+	// +optional
+	Delay *DelayActionParams `json:"delay,omitempty"`
+	// +optional
+	Loss *LossActionParams `json:"loss,omitempty"`
+	// +optional
+	Duplicate *DuplicateActionParams `json:"duplicate,omitempty"`
+	// +optional
+	Corrupt *CorruptActionParams `json:"corrupt,omitempty"`
+}
+
+type DelayActionParams struct {
+	// +optional
+	Latency string `json:"latency,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+	// +optional
+	Jitter string `json:"jitter,omitempty"`
+}
+
+type LossActionParams struct {
+	// +optional
+	Loss string `json:"loss,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type DuplicateActionParams struct {
+	// +optional
+	Duplicate string `json:"duplicate,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type CorruptActionParams struct {
+	// +optional
+	Corrupt string `json:"corrupt,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type NetworkChaosAction string
+
+const (
+	DelayAction NetworkChaosAction = "delay"
+
+	LossAction NetworkChaosAction = "loss"
+
+	DuplicateAction NetworkChaosAction = "duplicate"
+
+	CorruptAction NetworkChaosAction = "corrupt"
+
+	PartitionAction NetworkChaosAction = "partition"
+)
+
+type Direction string
+
+const (
+	To Direction = "to"
+
+	From Direction = "from"
+
+	Both Direction = "both"
+)
+
+//selector
+
+type PodSelector struct {
+	// +optional
+	Namespaces []string `json:"namespaces,omitempty"`
+
+	// +optional
+	LabelSelectors map[string]string `json:"labelSelectors,omitempty"`
+
+	// +optional
+	AnnotationSelectors map[string]string `json:"annotationSelectors,omitempty"`
+
+	// +optional
+	Nodes []string `json:"nodes,omitempty"`

Review Comment:
   `NodesSelector`:  Specifies the Labels of the Node to which the experiment target Pod belongs.
   `Node`: Specifies the experiment nodes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] mlycore commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "mlycore (via GitHub)" <gi...@apache.org>.
mlycore commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1152797698


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +40,475 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	InjectReqs batchV1Beta1.JobTemplateSpec `json:"injectReqs,omitempty"`

Review Comment:
   Consider update this name to InjectRequest or InjectJob?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] Xu-Wentao commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "Xu-Wentao (via GitHub)" <gi...@apache.org>.
Xu-Wentao commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1155678080


##########
shardingsphere-operator/pkg/reconcile/ShardingSphereChaos/ShardingSphereChaos_suite_test.go:
##########


Review Comment:
   you can use `fakeClient` to mock client.Client. below is a simple example.
   ```go
   var fakeClient client.Client
   // your new reconciler or controller
   var reconciler *YourReconciler
   
   // register some CRD or resources for your need.
   scheme := runtime.NewScheme()
   Expect(corev1.AddToScheme(scheme)).To(Succeed())
   Expect(appsv1.AddToScheme(scheme)).To(Succeed())
   fakeClient = fake.NewClientBuilder().WithScheme(scheme).Build()
   reconciler = &controllers.YourController{}
   req := reconcile.Request{
   			NamespacedName: client.ObjectKey{
   				Namespace: "test-namespace",
   				Name:      "test-resource",
   			},
   		}
   
   // create some resource if needed by fakeClient.Create()
   // Expect(fakeClient.Create(context.Background(), &appsv1.Deployment{})).To(Succeed())
   // ...
   
   res, err := reconciler.Reconcile(context.Background(), req)
   Expect(err).NotTo(HaveOccurred())
   // handle res if needed.
   // ...
   ```
   you can move some common code to ginkgo's `BeforeEach` and `AfterEach`. Please help yourself.



##########
shardingsphere-operator/pkg/kubernetes/chaos/chaos_mesh_impl.go:
##########


Review Comment:
   can just named this file to `chaos_mesh`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156672370


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"

Review Comment:
   maybe the `containerkill` which next to it should be lower case



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] Xu-Wentao commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "Xu-Wentao (via GitHub)" <gi...@apache.org>.
Xu-Wentao commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1155835443


##########
shardingsphere-operator/pkg/reconcile/ShardingSphereChaos/ShardingSphereChaos_suite_test.go:
##########


Review Comment:
   add an example of test with envtest:
   [testing-kubernetes-operator-envtest](https://www.infracloud.io/blogs/testing-kubernetes-operator-envtest)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] mlycore merged pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "mlycore (via GitHub)" <gi...@apache.org>.
mlycore merged PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156669790


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"

Review Comment:
   sure,it will change soon



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156666957


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"

Review Comment:
   sure,it is more complex than kubernetes Job status,maybe check job status in reconcile directly is better?
   It will be changed in commit later



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156676805


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`
+}
+
+type NetWorkParams struct {
+	// +optional
+	Delay *DelayActionParams `json:"delay,omitempty"`
+	// +optional
+	Loss *LossActionParams `json:"loss,omitempty"`
+	// +optional
+	Duplicate *DuplicateActionParams `json:"duplicate,omitempty"`
+	// +optional
+	Corrupt *CorruptActionParams `json:"corrupt,omitempty"`
+}
+
+type DelayActionParams struct {
+	// +optional
+	Latency string `json:"latency,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+	// +optional
+	Jitter string `json:"jitter,omitempty"`
+}
+
+type LossActionParams struct {
+	// +optional
+	Loss string `json:"loss,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type DuplicateActionParams struct {
+	// +optional
+	Duplicate string `json:"duplicate,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type CorruptActionParams struct {
+	// +optional
+	Corrupt string `json:"corrupt,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type NetworkChaosAction string
+
+const (
+	DelayAction NetworkChaosAction = "delay"
+
+	LossAction NetworkChaosAction = "loss"
+
+	DuplicateAction NetworkChaosAction = "duplicate"
+
+	CorruptAction NetworkChaosAction = "corrupt"
+
+	PartitionAction NetworkChaosAction = "partition"
+)
+
+type Direction string
+
+const (
+	To Direction = "to"
+
+	From Direction = "from"
+
+	Both Direction = "both"
+)
+
+//selector

Review Comment:
   Applied



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] Xu-Wentao commented on pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "Xu-Wentao (via GitHub)" <gi...@apache.org>.
Xu-Wentao commented on PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#issuecomment-1495738444

   lgtm


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156663593


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"

Review Comment:
   The Jobschedule will set when check the job status in reconcile



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156676921


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`

Review Comment:
   Appiled



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1152844304


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +40,475 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	InjectReqs batchV1Beta1.JobTemplateSpec `json:"injectReqs,omitempty"`

Review Comment:
   sure, InjectJob is a better spec,i will change it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1155688204


##########
shardingsphere-operator/pkg/kubernetes/chaos/chaos_mesh_impl.go:
##########


Review Comment:
   sure,i will change it
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] Xu-Wentao commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "Xu-Wentao (via GitHub)" <gi...@apache.org>.
Xu-Wentao commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1155683239


##########
shardingsphere-operator/pkg/reconcile/ShardingSphereChaos/ShardingSphereChaos_suite_test.go:
##########


Review Comment:
   here's a doc may help u :)
   [k8s-unittest-guide](https://xinzhao.me/posts/k8s-unittest-guide/)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] mlycore commented on pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "mlycore (via GitHub)" <gi...@apache.org>.
mlycore commented on PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#issuecomment-1500110362

   LGTM


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] mlycore commented on pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "mlycore (via GitHub)" <gi...@apache.org>.
mlycore commented on PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#issuecomment-1487199262

   Need add unit test with `ginkgo`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] Xu-Wentao commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "Xu-Wentao (via GitHub)" <gi...@apache.org>.
Xu-Wentao commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1155678080


##########
shardingsphere-operator/pkg/reconcile/ShardingSphereChaos/ShardingSphereChaos_suite_test.go:
##########


Review Comment:
   you can use `fakeClient` to mock client.Client. below is a simple example.
   ```go
   import (
           // import other needed packages...
           appsv1 "k8s.io/api/apps/v1"
   	corev1 "k8s.io/api/core/v1"
   	"k8s.io/apimachinery/pkg/runtime"
   	"sigs.k8s.io/controller-runtime/pkg/client"
   	"sigs.k8s.io/controller-runtime/pkg/client/fake"
   )
   
   var fakeClient client.Client
   // your new reconciler or controller
   var reconciler *YourReconciler
   
   // register some CRD or resources for your need.
   scheme := runtime.NewScheme()
   Expect(corev1.AddToScheme(scheme)).To(Succeed())
   Expect(appsv1.AddToScheme(scheme)).To(Succeed())
   fakeClient = fake.NewClientBuilder().WithScheme(scheme).Build()
   reconciler = &controllers.YourController{}
   req := reconcile.Request{
   			NamespacedName: client.ObjectKey{
   				Namespace: "test-namespace",
   				Name:      "test-resource",
   			},
   		}
   
   // create some resource if needed by fakeClient.Create()
   // Expect(fakeClient.Create(context.Background(), &appsv1.Deployment{})).To(Succeed())
   // ...
   
   res, err := reconciler.Reconcile(context.Background(), req)
   Expect(err).NotTo(HaveOccurred())
   // handle res if needed.
   // ...
   ```
   you can move some common code to ginkgo's `BeforeEach` and `AfterEach`. Please help yourself.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1155687817


##########
shardingsphere-operator/pkg/reconcile/ShardingSphereChaos/ShardingSphereChaos_suite_test.go:
##########


Review Comment:
   thanks,bro



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] mlycore commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "mlycore (via GitHub)" <gi...@apache.org>.
mlycore commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156655922


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"

Review Comment:
   How to describe the Job status if the  Job is under executing ?



##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"

Review Comment:
   Could we set this status from `JobFinish` to `JobCompleted`? It is more compatiable with Kubernetes Job status.



##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`
+}
+
+type NetWorkParams struct {
+	// +optional
+	Delay *DelayActionParams `json:"delay,omitempty"`
+	// +optional
+	Loss *LossActionParams `json:"loss,omitempty"`
+	// +optional
+	Duplicate *DuplicateActionParams `json:"duplicate,omitempty"`
+	// +optional
+	Corrupt *CorruptActionParams `json:"corrupt,omitempty"`
+}
+
+type DelayActionParams struct {
+	// +optional
+	Latency string `json:"latency,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+	// +optional
+	Jitter string `json:"jitter,omitempty"`
+}
+
+type LossActionParams struct {
+	// +optional
+	Loss string `json:"loss,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type DuplicateActionParams struct {
+	// +optional
+	Duplicate string `json:"duplicate,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type CorruptActionParams struct {
+	// +optional
+	Corrupt string `json:"corrupt,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type NetworkChaosAction string
+
+const (
+	DelayAction NetworkChaosAction = "delay"
+
+	LossAction NetworkChaosAction = "loss"
+
+	DuplicateAction NetworkChaosAction = "duplicate"
+
+	CorruptAction NetworkChaosAction = "corrupt"
+
+	PartitionAction NetworkChaosAction = "partition"
+)
+
+type Direction string
+
+const (
+	To Direction = "to"
+
+	From Direction = "from"
+
+	Both Direction = "both"
+)
+
+//selector
+
+type PodSelector struct {
+	// +optional
+	Namespaces []string `json:"namespaces,omitempty"`
+
+	// +optional
+	LabelSelectors map[string]string `json:"labelSelectors,omitempty"`
+
+	// +optional
+	AnnotationSelectors map[string]string `json:"annotationSelectors,omitempty"`
+
+	// +optional
+	Nodes []string `json:"nodes,omitempty"`

Review Comment:
   What's the difference between `Nodes` and `NodeSelectors` ?



##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`
+}
+
+type NetWorkParams struct {
+	// +optional
+	Delay *DelayActionParams `json:"delay,omitempty"`
+	// +optional
+	Loss *LossActionParams `json:"loss,omitempty"`
+	// +optional
+	Duplicate *DuplicateActionParams `json:"duplicate,omitempty"`
+	// +optional
+	Corrupt *CorruptActionParams `json:"corrupt,omitempty"`
+}
+
+type DelayActionParams struct {
+	// +optional
+	Latency string `json:"latency,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+	// +optional
+	Jitter string `json:"jitter,omitempty"`
+}
+
+type LossActionParams struct {
+	// +optional
+	Loss string `json:"loss,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type DuplicateActionParams struct {
+	// +optional
+	Duplicate string `json:"duplicate,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type CorruptActionParams struct {
+	// +optional
+	Corrupt string `json:"corrupt,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type NetworkChaosAction string
+
+const (
+	DelayAction NetworkChaosAction = "delay"
+
+	LossAction NetworkChaosAction = "loss"
+
+	DuplicateAction NetworkChaosAction = "duplicate"
+
+	CorruptAction NetworkChaosAction = "corrupt"
+
+	PartitionAction NetworkChaosAction = "partition"
+)
+
+type Direction string
+
+const (
+	To Direction = "to"
+

Review Comment:
   Remove the empty lines



##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`
+}
+
+type NetWorkParams struct {
+	// +optional
+	Delay *DelayActionParams `json:"delay,omitempty"`
+	// +optional
+	Loss *LossActionParams `json:"loss,omitempty"`
+	// +optional
+	Duplicate *DuplicateActionParams `json:"duplicate,omitempty"`
+	// +optional
+	Corrupt *CorruptActionParams `json:"corrupt,omitempty"`
+}
+
+type DelayActionParams struct {
+	// +optional
+	Latency string `json:"latency,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+	// +optional
+	Jitter string `json:"jitter,omitempty"`
+}
+
+type LossActionParams struct {
+	// +optional
+	Loss string `json:"loss,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type DuplicateActionParams struct {
+	// +optional
+	Duplicate string `json:"duplicate,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type CorruptActionParams struct {
+	// +optional
+	Corrupt string `json:"corrupt,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type NetworkChaosAction string
+
+const (
+	DelayAction NetworkChaosAction = "delay"
+
+	LossAction NetworkChaosAction = "loss"
+
+	DuplicateAction NetworkChaosAction = "duplicate"
+
+	CorruptAction NetworkChaosAction = "corrupt"
+
+	PartitionAction NetworkChaosAction = "partition"
+)
+
+type Direction string
+
+const (
+	To Direction = "to"
+
+	From Direction = "from"
+
+	Both Direction = "both"
+)
+
+//selector

Review Comment:
   Please update this comment.



##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"

Review Comment:
   The first letter of  `podFailure` should be uppercase



##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`

Review Comment:
   Update the word  to `Network`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere-on-cloud] moomman commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function

Posted by "moomman (via GitHub)" <gi...@apache.org>.
moomman commented on code in PR #286:
URL: https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1156676548


##########
shardingsphere-operator/api/v1alpha1/shardingsphere_chaos_types.go:
##########
@@ -36,12 +38,202 @@ type ShardingSphereChaos struct {
 	metav1.ObjectMeta `json:"metadata,omitempty"`
 
 	Spec ShardingSphereChaosSpec `json:"spec,omitempty"`
-	// +optional
+
 	Status ShardingSphereChaosStatus `json:"status,omitempty"`
 }
 
 // ShardingSphereChaosSpec defines the desired state of ShardingSphereChaos
-type ShardingSphereChaosSpec struct{}
+type ShardingSphereChaosSpec struct {
+	//InjectJob batchV1Beta1.JobTemplateSpec `json:"InjectJob,omitempty"`
+
+	ChaosKind ChaosKind `json:"chaosKind,omitempty"`
+
+	EmbedChaos `json:",inline"`
+
+	//Verify batchV1Beta1.JobTemplateSpec `json:"Verify,omitempty"`
+}
+
+type ChaosKind string
+
+const (
+	NetworkChaosKind ChaosKind = "networkChaos"
+
+	PodChaosKind ChaosKind = "podChaos"
+)
+
+type EmbedChaos struct {
+	// +optional
+	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
+	// +optional
+	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
+}
+
+type DeploymentCondition string
+
+const (
+	Creating     DeploymentCondition = "Creating"
+	AllRecovered DeploymentCondition = "AllRecovered"
+	Paused       DeploymentCondition = "Paused"
+	AllInjected  DeploymentCondition = "AllInjected"
+)
+
+type Jobschedule string
+
+const (
+	JobCreating Jobschedule = "JobCreating"
+	JobFailed   Jobschedule = "JobFailed"
+	JobFinish   Jobschedule = "JobFinish"
+)
 
 // ShardingSphereChaosStatus defines the actual state of ShardingSphereChaos
-type ShardingSphereChaosStatus struct{}
+type ShardingSphereChaosStatus struct {
+	ChaosCondition DeploymentCondition `json:"deploymentCondition"`
+	InjectStatus   Jobschedule         `json:"InjectStatus"`
+	VerifyStatus   Jobschedule         `json:"VerifyStatus"`
+}
+
+// pod chaos
+
+type PodChaosAction string
+
+var (
+	PodFailureAction    PodChaosAction = "podFailure"
+	ContainerKillAction PodChaosAction = "ContainerKill"
+)
+
+type PodChaosSpec struct {
+	PodSelector `json:",inline"`
+	Action      PodChaosAction `json:"action"`
+	// +optional
+	PodActionParam *PodActionParam `json:",inline"`
+}
+
+type PodActionParam struct {
+	//+optional
+	PodFailure *PodFailureActionParams `json:"podFailure,omitempty"`
+	//+optional
+	ContainerKill *ContainerKillActionParams `json:"containerKill,omitempty"`
+}
+
+type PodFailureActionParams struct {
+	// +optional
+	Duration string `json:"duration,omitempty"`
+}
+
+type ContainerKillActionParams struct {
+	// +optional
+	ContainerNames []string `json:"containerNames,omitempty"`
+}
+
+//network chaos
+
+type NetworkChaosSpec struct {
+	Source PodSelector `json:",inline"`
+
+	// +optional
+	Duration *string `json:"duration,omitempty"`
+
+	//+optional
+	Direction Direction `json:"direction,omitempty"`
+
+	// +optional
+	Target *PodSelector `json:"target,omitempty"`
+
+	Action NetworkChaosAction `json:"action"`
+
+	// +optional
+	NetWorkParams *NetWorkParams `json:",inline"`
+}
+
+type NetWorkParams struct {
+	// +optional
+	Delay *DelayActionParams `json:"delay,omitempty"`
+	// +optional
+	Loss *LossActionParams `json:"loss,omitempty"`
+	// +optional
+	Duplicate *DuplicateActionParams `json:"duplicate,omitempty"`
+	// +optional
+	Corrupt *CorruptActionParams `json:"corrupt,omitempty"`
+}
+
+type DelayActionParams struct {
+	// +optional
+	Latency string `json:"latency,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+	// +optional
+	Jitter string `json:"jitter,omitempty"`
+}
+
+type LossActionParams struct {
+	// +optional
+	Loss string `json:"loss,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type DuplicateActionParams struct {
+	// +optional
+	Duplicate string `json:"duplicate,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type CorruptActionParams struct {
+	// +optional
+	Corrupt string `json:"corrupt,omitempty"`
+	// +optional
+	Correlation string `json:"correlation,omitempty"`
+}
+
+type NetworkChaosAction string
+
+const (
+	DelayAction NetworkChaosAction = "delay"
+
+	LossAction NetworkChaosAction = "loss"
+
+	DuplicateAction NetworkChaosAction = "duplicate"
+
+	CorruptAction NetworkChaosAction = "corrupt"
+
+	PartitionAction NetworkChaosAction = "partition"
+)
+
+type Direction string
+
+const (
+	To Direction = "to"
+

Review Comment:
   Applied



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org