Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
CONTROLLER_TOOLS_VERSION ?= v0.9.0
CONTROLLER_TOOLS_VERSION ?= v0.16.5

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
Expand Down
11 changes: 7 additions & 4 deletions api/litmuschaos/v1alpha1/chaosengine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ type ApplicationParams struct {
Applabel string `json:"applabel,omitempty"`
//kind of application
AppKind string `json:"appkind,omitempty"`
//LabelMatchMode specifies how to match labels (union or intersection)
LabelMatchMode string `json:"labelMatchMode,omitempty"`
}

type Selector struct {
Expand All @@ -135,10 +137,11 @@ const (
)

type Workload struct {
Kind WorkloadKind `json:"kind"`
Namespace string `json:"namespace"`
Names string `json:"names,omitempty"`
Labels string `json:"labels,omitempty"`
Kind WorkloadKind `json:"kind"`
Namespace string `json:"namespace"`
Names string `json:"names,omitempty"`
Labels string `json:"labels,omitempty"`
LabelMatchMode string `json:"labelMatchMode,omitempty"`
}

type Pod struct {
Expand Down
1 change: 0 additions & 1 deletion api/litmuschaos/v1alpha1/zz_generated.deepcopy.go

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

3,163 changes: 3,163 additions & 0 deletions config/crd/bases/litmuschaos.io_chaosengines.yaml

Large diffs are not rendered by default.

664 changes: 664 additions & 0 deletions config/crd/bases/litmuschaos.io_chaosexperiments.yaml

Large diffs are not rendered by default.

153 changes: 153 additions & 0 deletions config/crd/bases/litmuschaos.io_chaosresults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.5
name: chaosresults.litmuschaos.io
spec:
group: litmuschaos.io
names:
kind: ChaosResult
listKind: ChaosResultList
plural: chaosresults
singular: chaosresult
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ChaosResult is the Schema for the chaosresults API
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: |-
ChaosResultSpec defines the desired state of ChaosResult
The chaosresult holds the status of a chaos experiment that is listed as an item
in the chaos engine to be run against a given app.
properties:
engine:
description: EngineName defines the name of chaosEngine
type: string
experiment:
description: ExperimentName defines the name of chaosexperiment
type: string
instance:
description: InstanceID defines the instance id
type: string
required:
- experiment
type: object
status:
description: ChaosResultStatus defines the observed state of ChaosResult
properties:
experimentStatus:
description: ExperimentStatus contains the status,verdict of the experiment
properties:
errorOutput:
description: ErrorOutput defines error message and error code
properties:
errorCode:
description: ErrorCode defines error code of the experiment
type: string
reason:
description: Reason contains the error reason
type: string
type: object
phase:
description: Phase defines whether an experiment is running or
completed
type: string
probeSuccessPercentage:
description: ProbeSuccessPercentage defines the score of the probes
type: string
verdict:
description: Verdict defines whether an experiment result is pass
or fail
type: string
required:
- phase
- verdict
type: object
history:
description: History contains cumulative values of verdicts
properties:
failedRuns:
type: integer
passedRuns:
type: integer
stoppedRuns:
type: integer
targets:
items:
description: TargetDetails contains target details for the experiment
and the chaos status
properties:
chaosStatus:
type: string
kind:
type: string
name:
type: string
type: object
type: array
required:
- failedRuns
- passedRuns
- stoppedRuns
type: object
probeStatuses:
description: ProbeStatus contains the status of the probe
items:
description: ProbeStatus defines information about the status and
result of the probes
properties:
mode:
description: 'Mode defined the mode of probe, supported values:
SOT, EOT, Edge, OnChaos, Continuous'
type: string
name:
description: Name defines the name of probe
type: string
status:
description: Status defines whether a probe is pass or fail
properties:
description:
description: Description defines the description of probe
status
type: string
verdict:
description: 'Verdict defines the verdict of the probe,
range: Passed, Failed, N/A'
type: string
type: object
type:
description: 'Type defined the type of probe, supported values:
K8sProbe, HttpProbe, CmdProbe'
type: string
type: object
type: array
required:
- experimentStatus
type: object
type: object
served: true
storage: true
subresources:
status: {}
32 changes: 32 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- litmuschaos.io
resources:
- chaosengines
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- litmuschaos.io
resources:
- chaosengines/finalizers
verbs:
- update
- apiGroups:
- litmuschaos.io
resources:
- chaosengines/status
verbs:
- get
- patch
- update
17 changes: 15 additions & 2 deletions controllers/chaosengine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,13 @@ func getTargets(engine *chaosTypes.EngineInfo) string {
filter = w.Labels
}

target := strings.Join([]string{string(w.Kind), w.Namespace, fmt.Sprintf("[%v]", filter)}, ":")
// Set label match mode, default to "union" if not specified
labelMatchMode := "union"
if w.LabelMatchMode != "" {
labelMatchMode = w.LabelMatchMode
}

target := strings.Join([]string{string(w.Kind), w.Namespace, fmt.Sprintf("[%v]", filter), labelMatchMode}, ":")
targets = append(targets, target)
}
return strings.Join(targets, ";")
Expand All @@ -666,7 +672,14 @@ func getTargets(engine *chaosTypes.EngineInfo) string {
if engine.AppInfo.AppKind == "" {
engine.AppInfo.AppKind = "KIND"
}
return strings.Join([]string{engine.AppInfo.AppKind, engine.AppInfo.Appns, fmt.Sprintf("[%v]", engine.AppInfo.Applabel)}, ":")

// Set label match mode for AppInfo, default to "union" if not specified
labelMatchMode := "union"
if engine.AppInfo.LabelMatchMode != "" {
labelMatchMode = engine.AppInfo.LabelMatchMode
}

return strings.Join([]string{engine.AppInfo.AppKind, engine.AppInfo.Appns, fmt.Sprintf("[%v]", engine.AppInfo.Applabel), labelMatchMode}, ":")
}

// updateExperimentStatusesForStop updates ChaosEngine.Status.Experiment with Abort Status.
Expand Down