Skip to content

Commit

Permalink
workflow task node (chaos-mesh#1866)
Browse files Browse the repository at this point in the history
* feat: conditional branches in workflownode

Signed-off-by: STRRL <str_ruiling@outlook.com>

* feat: reconciler of task node

Signed-off-by: STRRL <str_ruiling@outlook.com>

* feat: setup one container for task node

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: address the comments by muse-dev

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: cleanup duplicated codes

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: bump controller-gen version

 compliable issue with kubernetes 1.18, detail:
kubernetes-sigs/controller-tools#480

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: bump the version of controller-gen to v0.4.1

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: restrict kubernetes version with replace

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: also restrict version for e2e-test

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: also bump the verison of controller-runtime

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: fallback to v1beta1

Signed-off-by: STRRL <str_ruiling@outlook.com>

* Revert "fix: also bump the verison of controller-runtime"

This reverts commit 8e05196.

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: fill the conditional branches if nil

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: permission of custom task about creating pod

Signed-off-by: STRRL <str_ruiling@outlook.com>

* feat: use v1 instead of v1beta1 with CRD

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: NOOP when pods exactly same

Signed-off-by: STRRL <str_ruiling@outlook.com>

* refactor: refactor the collectors

Signed-off-by: STRRL <str_ruiling@outlook.com>

* feat: finish the rest of task nodes

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: check before sync nodes in task

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: make linters happier

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: make linters happier

Signed-off-by: STRRL <str_ruiling@outlook.com>

* Update pkg/workflow/controllers/task_reconciler.go

Signed-off-by: STRRL <str_ruiling@outlook.com>

Co-authored-by: AsterNighT <klxjt99@outlook.com>

* fix: use create instead of apply

apply will create a huge annotaion which exceed the limit of size of
annotation

Signed-off-by: STRRL <str_ruiling@outlook.com>

* chore: update the comments for workflow template

Signed-off-by: STRRL <str_ruiling@outlook.com>

* fix: crd installation in e2e test

Signed-off-by: STRRL <str_ruiling@outlook.com>

Co-authored-by: AsterNighT <klxjt99@outlook.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Signed-off-by: root <root@vm3.jisiqhvhuzaupp2x5y5vff1eff.fx.internal.cloudapp.net>
  • Loading branch information
3 people authored and root committed Jun 16, 2021
1 parent cb690da commit bb62f5c
Show file tree
Hide file tree
Showing 32 changed files with 43,772 additions and 10,132 deletions.
26 changes: 24 additions & 2 deletions api/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"fmt"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -120,9 +120,19 @@ type Template struct {
Name string `json:"name"`
Type TemplateType `json:"templateType"`
Duration *string `json:"duration,omitempty"`
Tasks []string `json:"tasks,omitempty"`
// Task describes the behavior of the custom task. Only used when Type is TypeTask.
// +optional
Task *Task `json:"task,omitempty"`
// Tasks describes the children steps of serial or parallel node. Only used when Type is TypeSerial or TypeParallel.
// +optional
Tasks []string `json:"tasks,omitempty"`
// ConditionalTasks describes the conditional branches of custom tasks. Only used when Type is TypeTask.
// +optional
ConditionalTasks []ConditionalTask `json:"conditionalTasks,omitempty"`
// EmbedChaos describe the chaos to be injected with chaos nodes. Only used when Type is Type<Something>Chaos.
// +optional
*EmbedChaos `json:",inline"`
// Schedule describe the Schedule(describing scheduled chaos) to be injected with chaos nodes. Only used when Type is TypeSchedule.
// +optional
Schedule *ChaosOnlyScheduleSpec `json:"schedule,omitempty"`
}
Expand Down Expand Up @@ -151,6 +161,18 @@ type ChaosOnlyScheduleSpec struct {
EmbedChaos `json:",inline"`
}

type Task struct {
// Container is the main container image to run in the pod
Container *corev1.Container `json:"container,omitempty"`

// Volumes is a list of volumes that can be mounted by containers in a template.
// +patchStrategy=merge
// +patchMergeKey=name
Volumes []corev1.Volume `json:"volumes,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

// TODO: maybe we could specify parameters in other ways, like loading context from file
}

// +kubebuilder:object:root=true
type WorkflowList struct {
metav1.TypeMeta `json:",inline"`
Expand Down
28 changes: 27 additions & 1 deletion api/v1alpha1/workflownode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ type WorkflowNodeSpec struct {
// +optional
Deadline *metav1.Time `json:"deadline,omitempty"`
// +optional
Task *Task `json:"task,omitempty"`
// +optional
Tasks []string `json:"tasks,omitempty"`
// +optional
ConditionalTasks []ConditionalTask `json:"conditionalTasks,omitempty"`
// +optional
*EmbedChaos `json:",inline,omitempty"`
// +optional
Schedule *ScheduleSpec `json:"schedule,omitempty"`
Expand All @@ -60,6 +64,10 @@ type WorkflowNodeStatus struct {
// +optional
ChaosResource *corev1.TypedLocalObjectReference `json:"chaosResource,omitempty"`

// ConditionalBranches records the evaluation result of each ConditionalTask
// +optional
ConditionalBranches *ConditionalBranchesStatus `json:"conditionalBranches,omitempty"`

// ActiveChildren means the created children node
// +optional
ActiveChildren []corev1.LocalObjectReference `json:"activeChildren,omitempty"`
Expand All @@ -68,13 +76,31 @@ type WorkflowNodeStatus struct {
// +optional
FinishedChildren []corev1.LocalObjectReference `json:"finishedChildren,omitempty"`

// Represents the latest available observations of a worklfow node's current state.
// Represents the latest available observations of a workflow node's current state.
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []WorkflowNodeCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

type ConditionalTask struct {
Task string `json:"task"`
// +optional
Expression string `json:"expression,omitempty"`
}

type ConditionalBranchesStatus struct {
// +optional
Branches []ConditionalBranch `json:"branches"`
// +optional
Context []string `json:"context"`
}

type ConditionalBranch struct {
Task string `json:"task"`
EvaluationResult corev1.ConditionStatus `json:"run"`
}

type WorkflowNodeConditionType string

const (
Expand Down
107 changes: 107 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bb62f5c

Please sign in to comment.