Skip to content

Commit

Permalink
feat: Pod PVC Chaos (#79)
Browse files Browse the repository at this point in the history
* feat: Pod PVC Chaos
  • Loading branch information
miketonks-form3 committed Mar 26, 2024
1 parent 324b2cb commit c69e177
Show file tree
Hide file tree
Showing 30 changed files with 6,186 additions and 512 deletions.
78 changes: 78 additions & 0 deletions api/v1alpha1/podpvcchaos_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright 2021 Chaos Mesh Authors.PodPVCChaos
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package v1alpha1

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

// +kubebuilder:object:root=true
// +chaos-mesh:experiment

// PodPVCChaos is the control script`s spec.
type PodPVCChaos struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec defines the behavior of a pod chaos experiment
Spec PodPVCChaosSpec `json:"spec"`

// +optional
// Most recently observed status of the chaos experiment about pods
Status PodPVCChaosStatus `json:"status,omitempty"`
}

// PodPVCChaosSpec defines the attributes that a user creates on a chaos experiment about pods.
type PodPVCChaosSpec struct {
PodPVCSelector `json:",inline"`

// Duration represents the duration of the chaos action.
// It is required when the action is `PodFailureAction`.
// A duration string is a possibly signed sequence of
// decimal numbers, each with optional fraction and a unit suffix,
// such as "300ms", "-1.5h" or "2h45m".
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
// +optional
Duration *string `json:"duration,omitempty" webhook:"Duration"`

// GracePeriod is used in pod-kill action. It represents the duration in seconds before the pod should be deleted.
// Value must be non-negative integer. The default value is zero that indicates delete immediately.
// +optional
// +kubebuilder:validation:Minimum=0
GracePeriod int64 `json:"gracePeriod,omitempty"`

// RemoteCluster represents the remote cluster where the chaos will be deployed
// +optional
RemoteCluster string `json:"remoteCluster,omitempty"`
}

type PodPVCSelector struct {
PodSelector `json:",inline"`

// VolumeName defines the name of the Volume to target.
VolumeName string `json:"volumeName"`
}

// PodPVCChaosStatus represents the current status of the chaos experiment about pods.
type PodPVCChaosStatus struct {
ChaosStatus `json:",inline"`
}

func (obj *PodPVCChaos) GetSelectorSpecs() map[string]interface{} {
return map[string]interface{}{
".": &obj.Spec.PodPVCSelector,
}
}
149 changes: 149 additions & 0 deletions api/v1alpha1/zz_generated.chaosmesh.go

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

63 changes: 63 additions & 0 deletions api/v1alpha1/zz_generated.chaosmesh_test.go

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

Loading

0 comments on commit c69e177

Please sign in to comment.